[jhbuild/wip/nacho/export] Implement export checkout mode for git and tarballs
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild/wip/nacho/export] Implement export checkout mode for git and tarballs
- Date: Wed, 10 Jul 2019 07:29:28 +0000 (UTC)
commit f89b02364daf392c05bb0d364df93cc34e25ca8c
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date: Wed Jul 10 09:26:21 2019 +0200
Implement export checkout mode for git and tarballs
For git it generates a zip file with the specific revision
of the checked out source and for tarballs it creates a zip
containing the tarball and any patches it might have
doc/C/index.docbook | 13 ++++++++++++-
jhbuild/config.py | 2 +-
jhbuild/defaults.jhbuildrc | 4 ++++
jhbuild/frontends/buildscript.py | 9 +++++++++
jhbuild/versioncontrol/git.py | 11 ++++++++++-
jhbuild/versioncontrol/tarball.py | 31 ++++++++++++++++++++++++++++++-
6 files changed, 66 insertions(+), 4 deletions(-)
---
diff --git a/doc/C/index.docbook b/doc/C/index.docbook
index 2e00e0be..0c2ac4ee 100644
--- a/doc/C/index.docbook
+++ b/doc/C/index.docbook
@@ -1787,7 +1787,7 @@ Optional packages: (JHBuild will build the missing packages)
<literal>update</literal> (update checkout directory),
<literal>clobber</literal> (wipe out directory before checking out
the sources), <literal>export</literal> (wipe out directory then
- create an unversioned copy of the sources) and
+ create a tarball of the sources containing any patches) and
<literal>copy</literal> (checkout in a directory different from
the one it will build).</simpara>
</listitem>
@@ -1815,6 +1815,17 @@ Optional packages: (JHBuild will build the missing packages)
checkout directory.</simpara>
</listitem>
</varlistentry>
+ <varlistentry id="cfg-export-dir">
+ <term>
+ <varname>export_dir</varname>
+ </term>
+ <listitem>
+ <simpara>A string specifying the directory to export to, if the export
+ <link linkend="cfg-checkout-mode">
+ <varname>checkout_mode</varname></link> is in use. Defaults to the
+ checkout directory.</simpara>
+ </listitem>
+ </varlistentry>
<varlistentry id="cfg-cvs-program">
<term>
<varname>cvs_program</varname>
diff --git a/jhbuild/config.py b/jhbuild/config.py
index 3d994862..c4c9b513 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -52,7 +52,7 @@ _known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
'system_libdirs', 'tinderbox_outputdir', 'sticky_date', 'tarballdir',
'pretty_print', 'svn_program', 'makedist', 'makedistcheck',
'nonotify', 'notrayicon', 'cvs_program', 'checkout_mode',
- 'copy_dir', 'module_checkout_mode', 'build_policy',
+ 'copy_dir', 'export_dir', 'module_checkout_mode', 'build_policy',
'trycheckout', 'min_age', 'nopoison', 'module_nopoison',
'forcecheck', 'makecheck_advisory', 'quiet_mode',
'progress_bar', 'module_extra_env', 'jhbuildbot_master',
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index bb211464..1bc3888c 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -139,6 +139,10 @@ module_checkout_mode = {}
# checkout dir
copy_dir = None
+# in case we use the export checkout mode, we can set up a export dir. Defaults
+# to checkout dir
+export_dir = None
+
# attempt to detect the system library path
extra_prefixes = []
try:
diff --git a/jhbuild/frontends/buildscript.py b/jhbuild/frontends/buildscript.py
index 59eaf25d..ee1ff017 100644
--- a/jhbuild/frontends/buildscript.py
+++ b/jhbuild/frontends/buildscript.py
@@ -60,6 +60,15 @@ class BuildScript:
if not os.access(self.config.copy_dir, os.R_OK|os.W_OK|os.X_OK):
raise FatalError(_('checkout copy dir (%s) must be writable') % self.config.copy_dir)
+ if self.config.export_dir and not os.path.exists(self.config.export_dir):
+ try:
+ os.makedirs(self.config.export_dir)
+ except OSError:
+ raise FatalError(
+ _('checkout export dir (%s) can not be created') % self.config.export_dir)
+ if not os.access(self.config.export_dir, os.R_OK|os.W_OK|os.X_OK):
+ raise FatalError(_('checkout export dir (%s) must be writable') % self.config.export_dir)
+
self.subprocess_nice_args = []
if config.nice_build:
chrt_args = ['chrt', '--idle', '0']
diff --git a/jhbuild/versioncontrol/git.py b/jhbuild/versioncontrol/git.py
index 610893fe..6a0e82b4 100644
--- a/jhbuild/versioncontrol/git.py
+++ b/jhbuild/versioncontrol/git.py
@@ -367,9 +367,18 @@ class GitBranch(Branch):
% (cmd_desc, stdout))
def _export(self, buildscript):
- # FIXME: should implement this properly
self._checkout(buildscript)
+ filename = self.get_module_basename() + '-' + self.tag + '.zip'
+
+ if self.config.export_dir is not None:
+ path = os.path.join(self.config.export_dir, filename)
+ else:
+ path = os.path.join(self.checkoutroot, filename)
+
+ git_extra_args = {'cwd': self.get_checkoutdir(), 'extra_env': get_git_extra_env()}
+ buildscript.execute(['git', 'archive', '-o', path, 'HEAD'], **git_extra_args)
+
def _update_submodules(self, buildscript):
if os.path.exists(os.path.join(self.get_checkoutdir(), '.gitmodules')):
cmd = ['git', 'submodule', 'init']
diff --git a/jhbuild/versioncontrol/tarball.py b/jhbuild/versioncontrol/tarball.py
index b3815f15..363669fa 100644
--- a/jhbuild/versioncontrol/tarball.py
+++ b/jhbuild/versioncontrol/tarball.py
@@ -28,6 +28,7 @@ except ImportError:
import urlparse
import urllib2
import logging
+import zipfile
from jhbuild.errors import FatalError, CommandError, BuildStateError
from jhbuild.versioncontrol import Repository, Branch, register_repo_type
@@ -253,7 +254,9 @@ class TarballBranch(Branch):
if self.patches:
self._do_patches(buildscript)
- def _do_patches(self, buildscript):
+ def _get_patch_files(self, buildscript):
+ patch_files = []
+
# now patch the working tree
for (patch, patchstrip) in self.patches:
patchfile = ''
@@ -298,6 +301,14 @@ class TarballBranch(Branch):
else:
raise CommandError(_('Failed to find patch: %s') % patch)
+ patch_files.append((patchfile, patch, patchstrip))
+
+ return patch_files
+
+ def _do_patches(self, buildscript):
+ # now patch the working tree
+ patch_files = self._get_patch_files(buildscript)
+ for (patchfile, patch, patchstrip) in patch_files:
buildscript.set_action(_('Applying patch'), self, action_target=patch)
# patchfile can be a relative file
buildscript.execute('patch -p%d < "%s"'
@@ -323,6 +334,21 @@ class TarballBranch(Branch):
cwd=self.srcdir,
extra_env={'QUILT_PATCHES' : self.quilt.srcdir})
+ def _export(self, buildscript):
+ filename = os.path.basename(self.raw_srcdir) + '.zip'
+
+ if self.config.export_dir is not None:
+ path = os.path.join(self.config.export_dir, filename)
+ else:
+ path = os.path.join(self.checkoutroot, filename)
+
+ with zipfile.ZipFile(path, 'w') as zipped_path:
+ patch_files = self._get_patch_files(buildscript)
+ for (patchfile, patch, patchstrip) in patch_files:
+ zipped_path.write(patchfile, arcname='patches/' + patch)
+
+ zipped_path.write(self._local_tarball, arcname=os.path.basename(self._local_tarball))
+
def checkout(self, buildscript):
if self.checkout_mode == 'clobber':
self._wipedir(buildscript, self.raw_srcdir)
@@ -331,6 +357,9 @@ class TarballBranch(Branch):
if self.quilt:
self._quilt_checkout(buildscript)
+ if self.checkout_mode == 'export':
+ self._export(buildscript)
+
def may_checkout(self, buildscript):
if os.path.exists(self._local_tarball):
return True
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]