diff options
author | build <buildmaster@sugarlabs.org> | 2009-01-21 18:52:50 (GMT) |
---|---|---|
committer | build <buildmaster@sugarlabs.org> | 2009-01-21 18:52:50 (GMT) |
commit | 220b57d90956fe7daf09865da4de48c645350909 (patch) | |
tree | 27b2968aa763217de8c1d186ef39e6229267ab2b /sjhbuild/bundlemodule.py | |
parent | 14a2da2cd57e16bafc6d9a25848eb1094b8e2947 (diff) |
add sjhbuild dir
Diffstat (limited to 'sjhbuild/bundlemodule.py')
-rw-r--r-- | sjhbuild/bundlemodule.py | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/sjhbuild/bundlemodule.py b/sjhbuild/bundlemodule.py new file mode 100644 index 0000000..3a662c1 --- /dev/null +++ b/sjhbuild/bundlemodule.py @@ -0,0 +1,94 @@ +__metaclass__ = type + +import os + +from jhbuild.errors import BuildStateError +from jhbuild.modtypes import Package, get_branch, register_module_type + +__all__ = [ 'BundleModule' ] + +class BundleModule(Package): + type = 'bundle' + + STATE_CHECKOUT = 'checkout' + STATE_FORCE_CHECKOUT = 'force_checkout' + STATE_BUILD = 'build' + STATE_INSTALL = 'install' + + def __init__(self, name, branch, dependencies=[], after=[]): + Package.__init__(self, name, dependencies, after) + self.branch = branch + + def get_srcdir(self, buildscript): + return self.branch.srcdir + + def get_builddir(self, buildscript): + return self.get_srcdir(buildscript) + + def get_revision(self): + return self.branch.branchname + + def do_start(self, buildscript): + pass + do_start.next_state = STATE_CHECKOUT + do_start.error_states = [] + + def skip_checkout(self, buildscript, last_state): + # skip the checkout stage if the nonetwork flag is set + return buildscript.config.nonetwork + + def do_checkout(self, buildscript): + srcdir = self.get_srcdir(buildscript) + buildscript.set_action('Checking out', self) + self.branch.checkout(buildscript) + # did the checkout succeed? + if not os.path.exists(srcdir): + raise BuildStateError('source directory %s was not created' + % srcdir) + do_checkout.next_state = STATE_BUILD + do_checkout.error_states = [STATE_FORCE_CHECKOUT] + + def skip_force_checkout(self, buildscript, last_state): + return False + + def do_force_checkout(self, buildscript): + buildscript.set_action('Checking out', self) + self.branch.force_checkout(buildscript) + do_force_checkout.next_state = STATE_BUILD + do_force_checkout.error_states = [STATE_FORCE_CHECKOUT] + + def skip_build(self, buildscript, last_state): + return buildscript.config.nobuild + + def do_build(self, buildscript): + buildscript.set_action('Building', self) + srcdir = self.get_srcdir(buildscript) + builddir = self.get_builddir(buildscript) + python = os.environ.get('PYTHON', 'python') + cmd = [python, 'setup.py', 'build'] + buildscript.execute(cmd, cwd=srcdir) + do_build.next_state = STATE_INSTALL + do_build.error_states = [STATE_FORCE_CHECKOUT] + + def skip_install(self, buildscript, last_state): + return buildscript.config.nobuild + + def do_install(self, buildscript): + buildscript.set_action('Installing', self) + srcdir = self.get_srcdir(buildscript) + builddir = self.get_builddir(buildscript) + python = os.environ.get('PYTHON', 'python') + cmd = [python, 'setup.py', 'install'] + cmd.extend(['--prefix', buildscript.config.prefix]) + buildscript.execute(cmd, cwd=srcdir) + buildscript.packagedb.add(self.name, self.get_revision() or '') + do_install.next_state = Package.STATE_DONE + do_install.error_states = [] + + +def parse_bundle(node, config, uri, repositories, default_repo): + id = node.getAttribute('id') + branch = get_branch(node, repositories, default_repo, config) + return BundleModule(id, branch) + +register_module_type('bundle', parse_bundle) |