From 2e01f340edf8f675bf51f08a07ff96ae0436d2b6 Mon Sep 17 00:00:00 2001 From: Sascha Silbe Date: Tue, 05 Jul 2011 16:51:39 +0000 Subject: bundle support: adapt to upstream changes We now base on the upstream distutils module, only implementing those parts where we need to deviate from the standard distutils interface. Once SL#2947 has been fixed and MANIFEST support been removed, we can switch to using the distutils module type for all activities. Signed-off-by: Sascha Silbe --- diff --git a/sjhbuild/bundlemodule.py b/sjhbuild/bundlemodule.py index 2d1b389..621d5a1 100644 --- a/sjhbuild/bundlemodule.py +++ b/sjhbuild/bundlemodule.py @@ -3,97 +3,61 @@ __metaclass__ = type import os from jhbuild.errors import BuildStateError -from jhbuild.modtypes import Package, get_branch, register_module_type +from jhbuild.modtypes import distutils, get_branch, get_dependencies, register_module_type __all__ = ['BundleModule'] -class BundleModule(Package): +class BundleModule(distutils.DistutilsModule): type = 'bundle' - PHASE_CHECKOUT = 'checkout' - PHASE_FORCE_CHECKOUT = 'force_checkout' - PHASE_BUILD = 'build' - PHASE_INSTALL = 'install' - - def __init__(self, name, branch, dependencies=None, after=None): - Package.__init__(self, name, dependencies or [], after or []) - 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_phase = PHASE_CHECKOUT - do_start.error_phases = [] - - 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_phase = PHASE_BUILD - do_checkout.error_phases = [PHASE_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_phase = PHASE_BUILD - do_force_checkout.error_phases = [PHASE_FORCE_CHECKOUT] - - def skip_build(self, buildscript, last_state): - return buildscript.config.nobuild - def do_build(self, buildscript): - buildscript.set_action('Building', self) + 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', 'fix_manifest'] - buildscript.execute(cmd, cwd=srcdir) - cmd = [python, 'setup.py', 'build'] - buildscript.execute(cmd, cwd=srcdir) - do_build.next_phase = PHASE_INSTALL - do_build.error_phases = [PHASE_FORCE_CHECKOUT] - do_build.depends = [PHASE_CHECKOUT] + if srcdir != builddir: + cmd.extend(['--build-base', builddir]) + buildscript.execute(cmd, cwd = srcdir, extra_env = self.extra_env) - def skip_install(self, buildscript, last_state): - return buildscript.config.nobuild + cmd = [python, 'setup.py', 'build'] + if srcdir != builddir: + cmd.extend(['--build-base', builddir]) + buildscript.execute(cmd, cwd = srcdir, extra_env = self.extra_env) def do_install(self, buildscript): - buildscript.set_action('Installing', self) + buildscript.set_action(_('Installing'), self) srcdir = self.get_srcdir(buildscript) + builddir = self.get_builddir(buildscript) + destdir = self.prepare_installroot(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_phase = Package.PHASE_DONE - do_install.error_phases = [] - do_install.depends = [PHASE_BUILD] + cmd = [python, 'setup.py'] + if srcdir != builddir: + cmd.extend(['build', '--build-base', builddir]) + # sugar.activity.bundlebuilder doesn't support --root (SL#2947) + cmd.extend(['install', + '--prefix', buildscript.config.prefix]) + buildscript.execute(cmd, cwd = srcdir, extra_env = self.extra_env) + self.process_install(buildscript, self.get_revision()) def parse_bundle(node, config, uri, repositories, default_repo): bundle_id = node.getAttribute('id') + # sugar.activity.bundlebuilder doesn't support --build-base (SL#2947) + supports_non_srcdir_builds = False + + if node.hasAttribute('supports-non-srcdir-builds'): + supports_non_srcdir_builds = \ + (node.getAttribute('supports-non-srcdir-builds') != 'no') + dependencies, after, suggests = get_dependencies(node) branch = get_branch(node, repositories, default_repo, config) - return BundleModule(bundle_id, branch) + return BundleModule(bundle_id, branch, + dependencies = dependencies, after = after, + suggests = suggests, + supports_non_srcdir_builds = supports_non_srcdir_builds) + register_module_type('bundle', parse_bundle) -- cgit v0.9.1