[jhbuild/wip/packaging: 5/6] Add --binpkg option for "buildone"
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/wip/packaging: 5/6] Add --binpkg option for "buildone"
- Date: Thu, 5 May 2011 23:24:14 +0000 (UTC)
commit b8122708ae24501f46329a21dc7289b820c11298
Author: Colin Walters <walters verbum org>
Date: Wed May 4 17:26:25 2011 -0400
Add --binpkg option for "buildone"
This moves us architecturally even closer to dpkg/rpm; we now
have the option to use the "fakeroot" command to generate
a binary tarball of the results.
https://bugzilla.gnome.org/show_bug.cgi?id=647231
jhbuild/commands/base.py | 3 ++
jhbuild/config.py | 4 ++-
jhbuild/defaults.jhbuildrc | 1 +
jhbuild/modtypes/__init__.py | 62 +++++++++++++++++++++++++++++++++--------
jhbuild/modtypes/autotools.py | 18 +++++------
5 files changed, 65 insertions(+), 23 deletions(-)
---
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index 2338d98..2ed7cad 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -335,6 +335,9 @@ class cmd_buildone(Command):
make_option('--min-age', metavar='TIME-SPEC',
action='store', dest='min_age', default=None,
help=_('skip modules installed less than the given time ago')),
+ make_option('', '--binpkg',
+ action='store', dest='binpkg', default=None,
+ help=_('create a tarball of the resulting build')),
])
def run(self, config, options, args, help=None):
diff --git a/jhbuild/config.py b/jhbuild/config.py
index f4734d4..fab3770 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -44,7 +44,7 @@ _known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
'autogenargs', 'makeargs',
'installprog', 'repos', 'branches', 'noxvfb', 'xvfbargs',
'builddir_pattern', 'module_autogenargs', 'module_makeargs',
- 'interact', 'buildscript', 'nonetwork',
+ 'interact', 'buildscript', 'nonetwork', 'binpkg',
'alwaysautogen', 'nobuild', 'makeclean', 'makecheck', 'module_makecheck',
'use_lib64', 'tinderbox_outputdir', 'sticky_date',
'tarballdir', 'pretty_print', 'svn_program', 'makedist',
@@ -524,6 +524,8 @@ class Config:
if hasattr(options, 'dist') and (
options.dist and not 'dist' in self.build_targets):
self.build_targets.append('dist')
+ if hasattr(options, 'binpkg') and options.binpkg:
+ self.binpkg = options.binpkg
if hasattr(options, 'distcheck') and (
options.distcheck and not 'distcheck' in self.build_targets):
self.build_targets.append('distcheck')
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 94784f3..d99bb4b 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -81,6 +81,7 @@ makedistcheck = False # run make distcheck after building
trycheckout = False # try to force checkout and autogen on failure
nopoison = False # don't poison modules on failure
forcecheck = False # run make check even when not building
+binpkg = None # Generate a binary tarball
build_targets = ['install','test']
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index a744392..4540280 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -28,6 +28,7 @@ __all__ = [
]
import os
+import tempfile
import shutil
from jhbuild.errors import FatalError, CommandError, BuildStateError, \
@@ -134,6 +135,8 @@ class Package:
self.tags = []
self.moduleset_name = None
self.supports_install_destdir = False
+
+ self._fakeroot_db = None
def __repr__(self):
return "<%s '%s'>" % (self.__class__.__name__, self.name)
@@ -147,17 +150,12 @@ class Package:
def get_builddir(self, buildscript):
raise NotImplementedError
- def _get_destdir(self, buildscript):
+ def get_destdir(self, buildscript):
return os.path.join(buildscript.config.workdir, 'root-%s' % (self.name, ))
- def prepare_installroot(self, buildscript):
- assert self.supports_install_destdir
- """Return a directory suitable for use as e.g. DESTDIR with "make install"."""
- destdir = self._get_destdir(buildscript)
- if os.path.exists(destdir):
- shutil.rmtree(destdir)
- os.makedirs(destdir)
- return destdir
+ def _get_fakeroot_command_prefix(self):
+ assert self._fakeroot_db is not None
+ return ['fakeroot', '-i', self._fakeroot_db, '-s', self._fakeroot_db]
def _clean_la_files(self, installroot):
assert os.path.isabs(installroot)
@@ -197,14 +195,54 @@ them into the prefix."""
else:
os.rename(src_path, dest_path)
- def process_install(self, buildscript, revision):
+ def _create_binpkg(self, buildscript, destdir):
+ cmd = self._get_fakeroot_command_prefix()
+ destdir = self.get_destdir(buildscript)
+ print "%r" % (buildscript.config.binpkg, )
+ assert isinstance(buildscript.config.binpkg, str)
+ cmd = cmd + ['tar', 'cjf', buildscript.config.binpkg, '.']
+ buildscript.execute(cmd, cwd = destdir)
+
+ def _prepare_install(self, buildscript):
+ """Return a directory suitable for use as e.g. DESTDIR with
+"make install", as well as a command prefix."""
assert self.supports_install_destdir
- destdir = self._get_destdir(buildscript)
+
+ assert self._fakeroot_db is None
+ (fd, path) = tempfile.mkstemp(prefix='jhbuild-fakeroot-')
+ os.close(fd)
+ self._fakeroot_db = path
+
+ destdir = self.get_destdir(buildscript)
+ if os.path.exists(destdir):
+ shutil.rmtree(destdir)
+ os.makedirs(destdir)
+ if buildscript.config.binpkg:
+ return (destdir, self._get_fakeroot_command_prefix())
+ return (destdir, None)
+
+ def process_install(self, buildscript, revision, cmd):
+ """Called by subclasses to implement DESTDIR= style install."""
+ assert self.supports_install_destdir
+
+ buildscript.set_action(_('Installing'), self)
+ (destdir, cmd_prefix) = self._prepare_install(buildscript)
+ if cmd_prefix is not None:
+ cmd = cmd_prefix + cmd
+ buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
+ extra_env = self.extra_env)
+
self._clean_la_files(destdir)
buildscript.packagedb.add(self.name, revision or '', destdir)
- self._process_install_files(destdir, destdir, buildscript.config.prefix)
+
+ if buildscript.config.binpkg:
+ self._create_binpkg(buildscript, destdir)
+ else:
+ self._process_install_files(destdir, destdir, buildscript.config.prefix)
+
try:
os.rmdir(destdir)
+ os.unlink(self._fakeroot_db)
except:
pass
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index f9c576f..5e420e6 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -262,18 +262,16 @@ class AutogenModule(Package, DownloadableModule):
do_dist.error_phases = [PHASE_FORCE_CHECKOUT, PHASE_CONFIGURE]
def do_install(self, buildscript):
- buildscript.set_action(_('Installing'), self)
- destdir = self.prepare_installroot(buildscript)
+ destdir = self.get_destdir(buildscript)
if self.makeinstallargs:
- cmd = '%s %s DESTDIR=%s' % (os.environ.get('MAKE', 'make'),
- self.makeinstallargs,
- destdir)
+ cmd = [os.environ.get('MAKE', 'make'),
+ self.makeinstallargs,
+ 'DESTDIR=' + destdir]
else:
- cmd = '%s install DESTDIR=%s' % (os.environ.get('MAKE', 'make'),
- destdir)
- buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
- extra_env = self.extra_env)
- self.process_install(buildscript, self.get_revision())
+ cmd = [os.environ.get('MAKE', 'make'),
+ 'install',
+ 'DESTDIR=' + destdir]
+ self.process_install(buildscript, self.get_revision(), cmd)
do_install.depends = [PHASE_BUILD]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]