# Path: pisi/actionsapi/shelltools.py
# def system(command):
#     command = string.join(string.split(command))
#     retValue = run_logged(command)
# 
#     #if return value is different than 0, it means error, raise exception
#     if retValue != 0:
#         error(_("Command \"%s\" failed, return value was %d.") % (command, retValue))
# 
#     return retValue
# 
# Path: pisi/actionsapi/shelltools.py
# def can_access_file(filePath):
#     '''test the existence of file'''
#     return os.access(filePath, os.F_OK)
# 
# Path: pisi/actionsapi/shelltools.py
# def export(key, value):
#     '''export environ variable'''
#     os.environ[key] = value
# 
# Path: pisi/actionsapi/shelltools.py
# def unlink(pattern):
#     '''remove the file path'''
#     filePathGlob = glob.glob(pattern)
#     if len(filePathGlob) == 0:
#         ctx.ui.error(_("No file matched pattern \"%s\". Remove operation failed.") % pattern)
#         return
# 
#     for filePath in filePathGlob:
#         if isFile(filePath) or isLink(filePath):
#             try:
#                 os.unlink(filePath)
#             except OSError:
#                 ctx.ui.error(_('ActionsAPI [unlink]: Permission denied: %s.') % (filePath))
#         elif isDirectory(filePath):
#             ctx.ui.warning(_('ActionsAPI [unlink]: %s is not a file, use \'unlinkDir\' or \'removeDir\' to remove directories.') % filePath)
#         else:
#             ctx.ui.error(_('ActionsAPI [unlink]: File %s doesn\'t exists.') % (filePath))


import os
import glob
import gettext
import pisi.context as ctx
import pisi.actionsapi
import pisi.actionsapi.get as get
from pisi.actionsapi.shelltools import system
from pisi.actionsapi.shelltools import can_access_file
from pisi.actionsapi.shelltools import export
from pisi.actionsapi.shelltools import unlink
        self.value = value
        ctx.ui.error(value)

class InstallError(pisi.actionsapi.Error):
    def __init__(self, value=''):
        pisi.actionsapi.Error.__init__(self, value)
        self.value = value
        ctx.ui.error(value)

def configure(parameters = ''):
    '''configure source with given parameters.'''
    export('PERL_MM_USE_DEFAULT', '1')
    if can_access_file('Build.PL'):
        if system('perl Build.PL installdirs=vendor destdir=%s' % get.installDIR()):
            raise ConfigureError, _('Configure failed.')
    else:
        if system('perl Makefile.PL %s PREFIX=/usr INSTALLDIRS=vendor DESTDIR=%s' % (parameters, get.installDIR())):
            raise ConfigureError, _('Configure failed.')

def make(parameters = ''):
    '''make source with given parameters.'''
    if can_access_file('Makefile'):
        if system('make %s' % parameters):
            raise MakeError, _('Make failed.')
    else:
        if system('perl Build %s' % parameters):
            raise MakeError, _('perl build failed.')

def install(parameters = 'install'):
    '''install source with given parameters.'''

# Path: pisi/actionsapi/shelltools.py
# def system(command):
#     command = string.join(string.split(command))
#     retValue = run_logged(command)
# 
#     #if return value is different than 0, it means error, raise exception
#     if retValue != 0:
#         error(_("Command \"%s\" failed, return value was %d.") % (command, retValue))
# 
#     return retValue
# 
# Path: pisi/actionsapi/shelltools.py
# def can_access_file(filePath):
#     '''test the existence of file'''
#     return os.access(filePath, os.F_OK)
# 
# Path: pisi/actionsapi/shelltools.py
# def export(key, value):
#     '''export environ variable'''
#     os.environ[key] = value
# 
# Path: pisi/actionsapi/shelltools.py
# def unlink(pattern):
#     '''remove the file path'''
#     filePathGlob = glob.glob(pattern)
#     if len(filePathGlob) == 0:
#         ctx.ui.error(_("No file matched pattern \"%s\". Remove operation failed.") % pattern)
#         return
# 
#     for filePath in filePathGlob:
#         if isFile(filePath) or isLink(filePath):
#             try:
#                 os.unlink(filePath)
#             except OSError:
#                 ctx.ui.error(_('ActionsAPI [unlink]: Permission denied: %s.') % (filePath))
#         elif isDirectory(filePath):
#             ctx.ui.warning(_('ActionsAPI [unlink]: %s is not a file, use \'unlinkDir\' or \'removeDir\' to remove directories.') % filePath)
#         else:
#             ctx.ui.error(_('ActionsAPI [unlink]: File %s doesn\'t exists.') % (filePath))


# Path: pisi/actionsapi/perlmodules.py
import os
import glob
import gettext
import pisi.context as ctx
import pisi.actionsapi
import pisi.actionsapi.get as get
from pisi.actionsapi.shelltools import system
from pisi.actionsapi.shelltools import can_access_file
from pisi.actionsapi.shelltools import export
from pisi.actionsapi.shelltools import unlink

        self.value = value
        ctx.ui.error(value)

class InstallError(pisi.actionsapi.Error):
    def __init__(self, value=''):
        pisi.actionsapi.Error.__init__(self, value)
        self.value = value
        ctx.ui.error(value)

def configure(parameters = ''):
    '''configure source with given parameters.'''
    export('PERL_MM_USE_DEFAULT', '1')
    if can_access_file('Build.PL'):
        if system('perl Build.PL installdirs=vendor destdir=%s' % get.installDIR()):
            raise ConfigureError, _('Configure failed.')
    else:
        if system('perl Makefile.PL %s PREFIX=/usr INSTALLDIRS=vendor DESTDIR=%s' % (parameters, get.installDIR())):
            raise ConfigureError, _('Configure failed.')

def make(parameters = ''):
    '''make source with given parameters.'''
    if can_access_file('Makefile'):
        if system('make %s' % parameters):
            raise MakeError, _('Make failed.')
    else:
        if system('perl Build %s' % parameters):
            raise MakeError, _('perl build failed.')

def install(parameters = 'install'):
    '''install source with given parameters.'''

    if can_access_file('Makefile'):