[reprotest] 01/01: Support >2 builds using the new --extra-build flag

Ximin Luo infinity0 at debian.org
Fri Sep 15 13:04:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository reprotest.

commit e5fabcc5af466c46e8494f0ea1ed369f9daa6795
Author: Ximin Luo <infinity0 at debian.org>
Date:   Fri Sep 15 15:04:09 2017 +0200

    Support >2 builds using the new --extra-build flag
---
 debian/changelog      |  1 +
 reprotest/__init__.py | 23 ++++++++++++++++++-----
 reprotest/build.py    |  4 +++-
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e01b721..82d4217 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ reprotest (0.7) UNRELEASED; urgency=medium
   * Add a variation config language to be able to configure the specifics of
     different variations, and to make it easier to configure further builds.
   * Deprecate the --dont-vary flag, add a --vary flag for better composability.
+  * Support >2 builds using the new --extra-build flag.
 
   [ Mattia Rizzolo ]
   * Bump Standards-Version to 4.0.0.
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index 31a285a..16b4fc9 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -243,11 +243,12 @@ def check(build_command, artifact_pattern, virtual_server_args, source_root,
                 traceback.print_exc()
                 return 2
 
-        retcodes = [
-            run_diff(build_contexts[0].local_dist, bctx.local_dist, diffoscope_args, store_dir)
-            for bctx in build_contexts[1:]]
+        retcodes = collections.OrderedDict(
+            (bctx.build_name,
+             run_diff(build_contexts[0].local_dist, bctx.local_dist, diffoscope_args, store_dir))
+            for bctx in build_contexts[1:])
 
-        retcode = max(retcodes)
+        retcode = max(retcodes.values())
         if retcode == 0:
             print("=======================")
             print("Reproduction successful")
@@ -257,7 +258,11 @@ def check(build_command, artifact_pattern, virtual_server_args, source_root,
                 'SHA256SUMS', store_dir,
                 cwd=os.path.join(build_contexts[0].local_dist, VSRC_DIR))
         else:
+            if 0 in retcodes.values():
+                print("Reproduction failed but partially successful: in %s" %
+                    ", ".join(name for name, r in retcodes.items() if r == 0))
             # a slight hack, to trigger no_clean_on_error
+            # TODO: this is out-of-date, see debian/TODO
             raise SystemExit(retcode)
         return retcode
 
@@ -363,6 +368,11 @@ def cli_parser():
         help='Like --variations, but appends to previous --vary values '
         'instead of overwriting them. Furthermore, the last value set for '
         '--variations is treated implicitly as the zeroth --vary value.')
+    group1.add_argument('--extra-build', metavar='VARIATIONS', default=[], action='append',
+        help='Perform another build with the given VARIATIONS (which may be '
+        'empty) to be applied on top of what was given for --variations and '
+        '--vary. Each occurence of this flag specifies another build, so e.g. '
+        'given twice this will make reprotest perform 4 builds in total.')
     # TODO: remove after reprotest 0.8
     group1.add_argument('--dont-vary', default=[], action='append', help=argparse.SUPPRESS)
 
@@ -510,7 +520,10 @@ def run(argv, check):
         logging.warn("--dont-vary is deprecated; use --vary=-$variation instead")
         variations += ["-%s" % a for x in parsed_args.dont_vary for a in x.split(",")]
     spec = VariationSpec().extend(variations)
-    build_variations = Variations.of(spec, verbosity=verbosity)
+    specs = [spec]
+    for extra_build in parsed_args.extra_build:
+        specs.append(spec.extend(extra_build))
+    build_variations = Variations.of(*specs, verbosity=verbosity)
 
     # Remaining args
     host_distro = parsed_args.host_distro
diff --git a/reprotest/build.py b/reprotest/build.py
index e4e9704..ccf0287 100644
--- a/reprotest/build.py
+++ b/reprotest/build.py
@@ -317,7 +317,7 @@ def user_group(ctx, build, vary):
     # disorderfs needs to run as a different user.
     # we prefer that to running it as root, principle of least-privilege.
     _ = _.append_setup_exec('sh', '-ec', r'''
-mkdir "{0}"
+mkdir -p "{0}"
 printf '#!/bin/sh\n{1} /usr/bin/disorderfs "$@"\n' > "{0}"/disorderfs
 chmod +x "{0}"/disorderfs
 printf '#!/bin/sh\n{1} /bin/mkdir "$@"\n' > "{0}"/mkdir
@@ -325,6 +325,8 @@ chmod +x "{0}"/mkdir
 printf '#!/bin/sh\n{1} /bin/fusermount "$@"\n' > "{0}"/fusermount
 chmod +x "{0}"/fusermount
 '''.format(binpath, " ".join(map(shlex.quote, sudo_command))))
+    _ = _.prepend_cleanup_exec('sh', '-ec',
+        'cd "{0}" && rm -f disorderfs mkdir fusermount'.format(binpath))
     _ = _.append_setup_exec_raw('export', 'PATH="%s:$PATH"' % binpath)
     if user != olduser:
         _ = _.append_setup_exec('sudo', 'chown', '-h', '-R', '--from=%s' % olduser, user, build.tree)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git



More information about the Reproducible-commits mailing list