All pastes #1601526 Raw Edit

WAF to Actions API

public python v1 · immutable
#1601526 ·published 2009-10-07 15:19 UTC
rendered paste body
# -*- coding: utf-8 -*-## Copyright (C) 2005 - 2007, TUBITAK/UEKAE## This program is free software; you can redistribute it and/or modify it under# the terms of the GNU General Public License as published by the Free# Software Foundation; either version 2 of the License, or (at your option)# any later version.## Please read the COPYING file.# Standard Python Modulesimport osimport gettext__trans = gettext.translation('pisi', fallback=True)_ = __trans.ugettext# Pisi Modulesimport pisi.context as ctx# ActionsAPI Modulesimport pisi.actionsapiimport pisi.actionsapi.get as getfrom pisi.actionsapi.shelltools import systemfrom pisi.actionsapi.shelltools import can_access_filefrom pisi.actionsapi.shelltools import unlinkclass ConfigureError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        self.value = value        ctx.ui.error(value)class MakeError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        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)class RunTimeError(pisi.actionsapi.Error):    def __init__(self, value=''):        pisi.actionsapi.Error.__init__(self, value)        self.value = value        ctx.ui.error(value)def configure(parameters = '', argument = 'configure'):    '''configure source with given parameters = "--enable-something-useful etc."'''    if can_access_file('wscript'):        if can_access_file('waf'):            wafcmd = 'python waf'        else            wafcmd = 'waf'        args = '%s \                --prefix=/%s \                --blddir=%s \                --datadir=/%s \                --sysconfdir=/%s \                --localstatedir=/%s \                --libexecdir=/%s \                %s %s' % (wafcmd, get.defaultprefixDIR(), get.HOST(), get.dataDIR(), \                       get.confDIR(), get.localstateDIR(), get.libexecDIR(), \                       parameters, argument)        if system(args):            raise ConfigureError(_('Configure failed.'))    else:        raise ConfigureError(_('No wscript found.'))def rawConfigure(parameters = '', argument = 'configure'):    '''configure source with given parameters = "--prefix=... --enable-foobar etc."'''    if can_access_file('wscript'):        if can_access_file('waf'):            wafcmd = 'python waf'        else            wafcmd = 'waf'    if can_access_file('waf'):        if system('%s %s %s' % (wafcmd, parameters, argument)):            raise ConfigureError(_('Configure failed.'))    else:        raise ConfigureError(_('No wscript found.'))def build(parameters = 'all', argument = 'build'):    '''build source with given parameters = "all" || "doc,bin" || etc.'''    if can_access_file('wscript'):        if can_access_file('waf'):            wafcmd = 'python waf'        else            wafcmd = 'waf'    if system('%s --targets=%s %s' % (wafcmd, parameters, argument)):            raise MakeError(_('Build failed.'))def fixInfoDir():    infoDir = '%s/usr/share/info/dir' % get.installDIR()    if can_access_file(infoDir):        unlink(infoDir)def install(parameters = '', argument = 'install'):    '''install files into install directory with given parameters'''    if can_access_file('wscript'):        if can_access_file('waf'):            wafcmd = 'python waf'        else            wafcmd = 'waf'        args = '%(wafcmd)s --prefix=%(prefix)s/%(defaultprefix)s \                --datadir=%(prefix)s/%(data)s \                --localstatedir=%(prefix)s/%(localstate)s \                --sysconfdir=%(prefix)s/%(conf)s \                %(parameters)s \                %(argument)s' % {'wafcmd':wafcmd,                            'prefix': get.installDIR(),                            'defaultprefix': get.defaultprefixDIR(),                            'data': get.dataDIR(),                            'localstate': get.localstateDIR(),                            'conf': get.confDIR(),                            'parameters': parameters,                            'argument':argument}        if system(args):            raise InstallError(_('Install failed.'))        else:            fixInfoDir()    else:        raise InstallError(_('No wscript found.'))def rawInstall(parameters = '', argument = 'install'):    '''install files into install directory with given parameters'''    if can_access_file('wscript'):        if can_access_file('waf'):            wafcmd = 'python waf'        else            wafcmd = 'waf'        if system('%s %s %s' % (wafcmd, parameters, argument)):            raise InstallError(_('Install failed.'))        else:            fixInfoDir()    else:        raise InstallError(_('No wscript found.'))def clean(parameters = '', argument = 'clean'):    '''remove the build files'''    if can_access_file('wscript'):        if can_access_file('waf'):            wafcmd = 'python waf'        else            wafcmd = 'waf'        if system('%s %s %s' % (wafcmd, parameters, argument)):            raise RunTimeError(_('Clean failed.'))    else:        raise InstallError(_('No wscript found.'))