[debrepatch] 01/01: Initial commit; add scripts to ease applying debdiff patches

Ximin Luo infinity0 at debian.org
Fri Sep 16 17:03:31 UTC 2016


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

infinity0 pushed a commit to branch master
in repository debrepatch.

commit f500950f2879a507b06c27e9aea418c4c66ea2a0
Author: Ximin Luo <infinity0 at debian.org>
Date:   Fri Sep 16 18:59:36 2016 +0200

    Initial commit; add scripts to ease applying debdiff patches
---
 .gitignore                          |   1 +
 README.rst                          |  30 ++++++
 all-patched-pkgs                    |   3 +
 debpatch                            | 196 ++++++++++++++++++++++++++++++++++++
 patches/bash_806945.patch           | 101 +++++++++++++++++++
 patches/dash_825643.patch           |  12 +++
 patches/sensible-utils_774449.patch |  45 +++++++++
 patches/shadow_817971.patch         |  29 ++++++
 patches/xz-utils_806331.patch       |  49 +++++++++
 repatch                             |  48 +++++++++
 10 files changed, 514 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..ad59ef7
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,30 @@
+Overview
+========
+
+The purpose of this repository is to reduce manual work in re-applying debian
+patches continually to the latest versions of those packages.
+
+TODO, WIP, doesn't work yet:
+Periodically and automatically, the patches defined in patches/ matching
+"$package_$bugnum.patch" will be applied against the latest version of the
+package in Debian unstable. If the patch fails to re-apply for whatever reason,
+the submitter of the bug report will be notified via email. If it does apply,
+then we will either run reprotest(1) on it, or upload it to an APT repo to be
+picked up by tests.reproducible-builds.org.
+
+Contributing
+============
+
+To add patches to this repository, name them as "$package_$bugnum.patch" and
+put them in the patches/ directory. These patches should be generated by
+`debdiff` or in a format identical to its output.
+
+Initially, we should focus on important packages, e.g. those the "required"
+set:
+
+https://tests.reproducible-builds.org/unstable/amd64/pkg_set_required.html
+
+This set is defined here:
+
+https://anonscm.debian.org/cgit/qa/jenkins.debian.net.git/tree/bin/reproducible_create_meta_pkg_sets.sh
+https://anonscm.debian.org/cgit/qa/jenkins.debian.net.git/tree/bin/meta_pkgset.csv
diff --git a/all-patched-pkgs b/all-patched-pkgs
new file mode 100755
index 0000000..9af8672
--- /dev/null
+++ b/all-patched-pkgs
@@ -0,0 +1,3 @@
+#!/bin/sh
+scriptdir="$(readlink -f "$(dirname "$0")")"
+ls -1 "$scriptdir/patches" | cut -f1 -d_ | sort -u
diff --git a/debpatch b/debpatch
new file mode 100755
index 0000000..1c76fa2
--- /dev/null
+++ b/debpatch
@@ -0,0 +1,196 @@
+#!/usr/bin/python3
+"""
+Apply a debdiff, but more smartly to avoid conflicts
+Specifically, it's smarter in how it applies updates to d/changelog.
+
+Depends on dpkg-dev, devscripts, python3-unidiff; However:
+
+- python3-unidiff unfortunately isn't in Debian yet, you can get it here:
+  https://github.com/matiasb/python-unidiff
+"""
+
+import argparse
+import io
+import logging
+import os
+import random
+import unidiff
+import subprocess
+import sys
+
+dirname = os.path.dirname
+basename = os.path.basename
+C = subprocess.check_call
+
+DCH_DUMMY_TAIL = "\n -- debpatch dummy tool <infinity0 at debian.org>  Thu, 01 Jan 1970 00:00:00 +0000\n\n"
+TRY_ENCODINGS = ["utf-8", "latin-1"]
+DISTRIBUTION_DEFAULT = "experimental"
+
+def parse_dch(dch_str, *args):
+    return subprocess.run(
+        ["dpkg-parsechangelog", "-l-", "-c1"] + list(args),
+        input=dch_str,
+        check=True,
+        universal_newlines=True,
+        stdout=subprocess.PIPE,
+        ).stdout.rstrip()
+
+def read_dch(dch_str):
+    dch = {}
+    for i in ("Version", "Distribution", "Urgency", "Maintainer"):
+        dch[i] = parse_dch(dch_str, "-S"+i)
+    dch["Changes"] = "".join(parse_dch(dch_str, "-SChanges").splitlines(True)[3:])
+    return dch
+
+def is_dch(path):
+    return (basename(path) == 'changelog'
+        and basename(dirname(path)) == 'debian'
+        and dirname(dirname(dirname(path))) == '')
+
+def hunk_lines_to_str(hunk_lines):
+    return "".join(map(lambda x: str(x)[1:], hunk_lines))
+
+def read_dch_patch(dch_patch):
+    if len(dch_patch) > 1:
+        raise ValueError("don't know how to deal with d/changelog patch that has more than one hunk")
+    hunk = dch_patch[0]
+    source_str = hunk_lines_to_str(hunk.source_lines()) + DCH_DUMMY_TAIL
+    target_str = hunk_lines_to_str(hunk.target_lines())
+    source_version = parse_dch(source_str, "-SVersion")
+    target = read_dch(target_str)
+    return source_version, target
+
+def apply_dch_patch(source_file, current, patch_name, old_version, target):
+    if patch_name in current["Changes"]:
+        logging.info("patch %s already applied to d/changelog", patch_name)
+        return
+
+    dch_args = []
+    dch_env = dict(os.environ)
+
+    if target["Distribution"] == "UNRELEASED":
+        # UNRELEASED causes hard-to-reason-about behaviours in dch, let's avoid that
+        newdist = current["Distribution"] if current["Distribution"] != "UNRELEASED" else DISTRIBUTION_DEFAULT
+        newdist = newdist + "-reproducible"
+        logging.info("using distribution '%s' instead of 'UNRELEASED'", newdist)
+        target["Distribution"] = newdist
+
+    if not old_version or not target["Version"].startswith(old_version):
+        logging.warn("don't know how to reapply version-change %s to %s" %
+            (old_version, target["Version"]))
+        logging.warn("will give -n to `dch` instead of trying to be smart; feel free to make me smarter")
+        dch_args.append("-n")
+    else:
+        version_suffix = target["Version"][len(old_version):]
+        version = current["Version"] + version_suffix
+        logging.info("using version %s based on suffix %s", version, version_suffix)
+        dch_args.extend(["-v", version])
+
+    dch_args += ["--force-distribution", "-D", target["Distribution"]]
+    dch_args += ["-u", target["Urgency"]]
+    if "Maintainer" in target:
+        dch_env["DEBEMAIL"] = target["Maintainer"]
+        del dch_env["DEBFULLNAME"]
+
+    changes = target["Changes"]
+    if changes.lstrip().startswith("["):
+        changes = "\n" + changes
+
+    # TODO: make this a bit more atomic; if any of the C()s fail we should rewind
+    token = "DEBPATCH PLACEHOLDER %s DELETEME" % random.randint(0, 2**64)
+    C(["dch", "-c", source_file] + dch_args +
+      ["Patch %s automatically applied by debpatch(1)" % patch_name])
+    C(["dch", "-c", source_file, "-a", token], env=dch_env)
+    C(["sed", "-e", "/%s/c\\\n%s" % (token, changes.replace("\n", "\\\n")), "-i", source_file])
+
+def call_patch(patch_str, *args, check=True, **kwargs):
+    return subprocess.run(
+        ["patch", "-p1"] + list(args),
+        input=patch_str,
+        universal_newlines=True,
+        check=check,
+        **kwargs)
+
+def check_patch(patch_str, *args, **kwargs):
+    return call_patch(patch_str,
+        "--dry-run", "-f", "--silent",
+        *args,
+        check=False,
+        stdout=subprocess.DEVNULL,
+        stderr=subprocess.DEVNULL,
+        **kwargs).returncode == 0
+
+def apply_patch_str(patch_name, patch_str):
+    if check_patch(patch_str, "-N"):
+        call_patch(patch_str)
+        logging.info("patch %s applies!", patch_name)
+    elif check_patch(patch_str, "-R"):
+        logging.info("patch %s already applied", patch_name)
+    else:
+        call_patch(patch_str, "--dry-run")
+        raise ValueError("patch %s doesn't apply!", patch_name)
+
+def main(args):
+    parser = argparse.ArgumentParser(
+        description='Apply a debdiff, but more smartly to avoid conflicts.')
+    parser.add_argument('-v', '--verbose', action="store_true",
+        help='Output more information')
+    parser.add_argument('-c', '--changelog', default='debian/changelog',
+        help='Path to debian/changelog; default: %(default)s')
+    parser.add_argument('-C', '--directory',
+        help="apply patches from this directory; should be the top-level source dir")
+    parser.add_argument('-i', '--interactive', action="store_true",
+        help="Run the python REPL after processing.")
+    parser.add_argument('patch_file')
+    args = parser.parse_args(args)
+
+    if args.verbose:
+        logging.getLogger().setLevel(logging.DEBUG)
+
+    patch_name = basename(args.patch_file)
+    if len(patch_name) > 60:
+        # this messes with our dch "already applied" logic detection, sorry
+        raise ValueError("pick a shorter patch name; sorry")
+
+    for enc in TRY_ENCODINGS:
+        try:
+            patch = unidiff.PatchSet.from_filename(args.patch_file, encoding=enc)
+            break
+        except:
+            if enc == TRY_ENCODINGS[-1]:
+                raise
+            else:
+                continue
+
+    # change directory before applying patches
+    if args.directory:
+        os.chdir(args.directory)
+
+    changelog = list(filter(lambda x: is_dch(x.path), patch))
+    if not changelog:
+        logging.info("no debian/changelog in patch: %s" % args.patch_file)
+        old_version = None
+        target = {
+            "Version": None,
+            "Distribution": DISTRIBUTION_DEFAULT,
+            "Urgency": "low",
+            "Changes": "  * Hopefully make this package reproducible.",
+        }
+    elif len(changelog) > 1:
+        raise ValueError("more than one debian/changelog patch???")
+    else:
+        patch.remove(changelog[0])
+        old_version, target = read_dch_patch(changelog[0])
+
+    apply_patch_str(patch_name, str(patch))
+    # only apply d/changelog patch if the rest of the patch applies
+    with open(args.changelog) as fp:
+        current = read_dch(fp.read())
+    apply_dch_patch(args.changelog, current, patch_name, old_version, target)
+
+    if args.interactive:
+        import code
+        code.interact(local=locals())
+
+if __name__ == "__main__":
+    sys.exit(main(sys.argv[1:]))
diff --git a/patches/bash_806945.patch b/patches/bash_806945.patch
new file mode 100644
index 0000000..01afa67
--- /dev/null
+++ b/patches/bash_806945.patch
@@ -0,0 +1,101 @@
+diff -Nru bash-4.3/debian/changelog bash-4.3/debian/changelog
+--- bash-4.3/debian/changelog	2015-09-01 01:04:48.000000000 +0200
++++ bash-4.3/debian/changelog	2016-06-07 11:56:09.000000000 +0200
+@@ -1,3 +1,15 @@
++bash (4.3-14.0~reproducible1) UNRELEASED; urgency=medium
++
++  [ Ximin Luo ]
++  * Non-maintainer upload.
++  * Set PGRP_PIPE unconditionally on Linux, reproducibly.
++
++  [ Reiner Herrmann ]
++  * Use the system man2html instead of the embedded one, for better build
++    reproducibility.
++
++ -- Ximin Luo <infinity0 at debian.org>  Tue, 07 Jun 2016 11:56:07 +0200
++
+ bash (4.3-14) unstable; urgency=medium
+ 
+   * Apply upstream patches 040 - 042.
+diff -Nru bash-4.3/debian/control bash-4.3/debian/control
+--- bash-4.3/debian/control	2015-01-28 17:13:32.000000000 +0100
++++ bash-4.3/debian/control	2016-06-06 03:00:38.000000000 +0200
+@@ -5,7 +5,7 @@
+ Standards-Version: 3.9.6
+ Build-Depends: autoconf, autotools-dev, bison, libncurses5-dev,
+  texinfo, texi2html, debhelper (>= 5), locales, gettext, sharutils, time,
+- xz-utils, dpkg-dev (>= 1.16.1)
++ xz-utils, dpkg-dev (>= 1.16.1), man2html
+ Build-Depends-Indep: texlive-latex-base, ghostscript, texlive-fonts-recommended
+ Homepage: http://tiswww.case.edu/php/chet/bash/bashtop.html
+ Vcs-Browser: https://code.launchpad.net/~doko/+junk/pkg-bash-debian
+diff -Nru bash-4.3/debian/patches/pgrp-pipe.diff bash-4.3/debian/patches/pgrp-pipe.diff
+--- bash-4.3/debian/patches/pgrp-pipe.diff	2013-10-23 14:41:22.000000000 +0200
++++ bash-4.3/debian/patches/pgrp-pipe.diff	2016-06-07 12:17:05.000000000 +0200
+@@ -1,11 +1,43 @@
+-# DP: Define PGRP_PIPE to avoid race condition.
+-
+---- a/config-bot.h
+-+++ b/config-bot.h
+-@@ -197,3 +197,6 @@
+- 
+- /* If you don't want bash to provide a default mail file to check. */
+- #undef DEFAULT_MAIL_DIRECTORY
+-+
+-+/* Bug #224543 */
+-+#define PGRP_PIPE 1
++Description: Set PGRP_PIPE unconditionally on Linux, reproducibly
++ The original fix to #224543 involved defining this unconditionally in
++ config-bot.h. Unfortunately, upstream has a check in configure.ac that defines
++ this conditionally in config.h, which makes the bash-builtins package 
++ unreproducible between different kernels. Here, we adopt a different approach,
++ which is to turn upstream's define into an uncondtional define. Then we can
++ also avoid touching config-bot.h.
++ .
++ More generally, installing config.h is bad practise because it fixes
++ build-time variables into everyone's installations, but that is a problem for
++ another day.
++Author: Ximin Luo <infinity0 at debian.org>
++Bug: https://lists.gnu.org/archive/html/bug-bash/2016-06/msg00053.html
++Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=806945
++---
++This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
++--- a/configure.ac
+++++ b/configure.ac
++@@ -1084,9 +1084,7 @@
++ solaris2*)	LOCAL_CFLAGS=-DSOLARIS ;;
++ lynxos*)	LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
++ linux*)		LOCAL_LDFLAGS=-rdynamic		 # allow dynamic loading
++-		case "`uname -r`" in
++-		2.[[456789]]*|3*)	AC_DEFINE(PGRP_PIPE) ;;
++-		esac ;;
+++		AC_DEFINE(PGRP_PIPE) ;;
++ *qnx6*)		LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
++ *qnx*)		LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
++ powerux*)	LOCAL_LIBS="-lgen" ;;
++--- a/configure
+++++ b/configure
++@@ -15922,10 +15922,8 @@
++ solaris2*)	LOCAL_CFLAGS=-DSOLARIS ;;
++ lynxos*)	LOCAL_CFLAGS=-DRECYCLES_PIDS ;;
++ linux*)		LOCAL_LDFLAGS=-rdynamic		 # allow dynamic loading
++-		case "`uname -r`" in
++-		2.[456789]*|3*)	$as_echo "#define PGRP_PIPE 1" >>confdefs.h
+++		$as_echo "#define PGRP_PIPE 1" >>confdefs.h
++  ;;
++-		esac ;;
++ *qnx6*)		LOCAL_CFLAGS="-Dqnx -Dqnx6" LOCAL_LIBS="-lncurses" ;;
++ *qnx*)		LOCAL_CFLAGS="-Dqnx -F -3s" LOCAL_LDFLAGS="-3s" LOCAL_LIBS="-lunix -lncurses" ;;
++ powerux*)	LOCAL_LIBS="-lgen" ;;
+diff -Nru bash-4.3/debian/rules bash-4.3/debian/rules
+--- bash-4.3/debian/rules	2015-01-28 17:55:12.000000000 +0100
++++ bash-4.3/debian/rules	2016-06-06 03:00:38.000000000 +0200
+@@ -136,7 +136,7 @@
+ bash-doc-build: stamps/stamp-build-bash-doc
+ stamps/stamp-build-bash-doc:
+ 	rm -f bash/doc/bashref.info
+-	$(MAKE) -C build-bash/doc info html
++	$(MAKE) -C build-bash/doc info html MAN2HTML=/usr/bin/man2html
+ 	$(MAKE) -C build-bash/doc bash.pdf bashref.pdf
+ 	touch stamps/stamp-build-bash-doc
+ 
diff --git a/patches/dash_825643.patch b/patches/dash_825643.patch
new file mode 100644
index 0000000..d74f0cd
--- /dev/null
+++ b/patches/dash_825643.patch
@@ -0,0 +1,12 @@
+diff -urN a/debian/rules b/debian/rules
+--- a/debian/rules	2016-06-13 01:27:12.000000000 +0200
++++ b/debian/rules	2016-06-13 01:20:28.447939088 +0200
+@@ -46,7 +46,7 @@
+ 	touch configure
+ 	(cd build-tmp && CC='$(CC)' \
+ 	  CFLAGS='$(CFLAGS)' CPPFLAGS='$(CPPFLAGS)' LDFLAGS='$(LDFLAGS)' \
+-	  exec ../configure --enable-fnmatch --disable-lineno \
++	  ../configure --enable-fnmatch --disable-lineno \
+ 	    --host='$(DEB_HOST_GNU_TYPE)')
+ 	touch configure-stamp
+ 
diff --git a/patches/sensible-utils_774449.patch b/patches/sensible-utils_774449.patch
new file mode 100644
index 0000000..d34c23c
--- /dev/null
+++ b/patches/sensible-utils_774449.patch
@@ -0,0 +1,45 @@
+diff -Nru sensible-utils-0.0.9/debian/changelog sensible-utils-0.0.9.0~reproducible1/debian/changelog
+--- sensible-utils-0.0.9/debian/changelog	2013-06-06 14:19:53.000000000 +0200
++++ sensible-utils-0.0.9.0~reproducible1/debian/changelog	2015-01-02 22:45:58.000000000 +0100
+@@ -1,3 +1,11 @@
++sensible-utils (0.0.9.0~reproducible1) UNRELEASED; urgency=low
++
++  * Make package build reproducibly:
++    - Stop recording current time when creating gzip files.
++    - Fix mtimes before creating binary packages.
++
++ -- J�r�my Bobbio <lunar at debian.org>  Fri, 02 Jan 2015 21:41:59 +0000
++
+ sensible-utils (0.0.9) unstable; urgency=low
+ 
+   * Fix bashism in select-editor
+diff -Nru sensible-utils-0.0.9/debian/rules sensible-utils-0.0.9.0~reproducible1/debian/rules
+--- sensible-utils-0.0.9/debian/rules	2012-05-14 09:23:19.000000000 +0200
++++ sensible-utils-0.0.9.0~reproducible1/debian/rules	2015-01-02 22:41:57.000000000 +0100
+@@ -9,6 +9,8 @@
+ INSTALL_SCRIPT  = $(INSTALL) -p    -o root -g root  -m  755
+ INSTALL_DIR     = $(INSTALL) -p -d -o root -g root  -m  755
+ 
++BUILD_DATE := $(shell dpkg-parsechangelog | sed -n -e 's/^Date: //p')
++
+ DEB_BUILD_ARCH_OS ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
+ DEB_BUILD_GNU_TYPE = $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+ DEB_HOST_GNU_TYPE = $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+@@ -78,7 +80,7 @@
+ 	     debian/sensible-utils/usr/share/man/de/man1 \
+ 	     debian/sensible-utils/usr/share/man/ja/man1 \
+ 	     debian/sensible-utils/usr/share/man/it/man1 \
+-             debian/sensible-utils/usr/share/doc/$(package) -type f | xargs gzip -9
++             debian/sensible-utils/usr/share/doc/$(package) -type f | xargs gzip -9n
+ 	$(INSTALL_FILE) debian/copyright debian/sensible-utils/usr/share/doc/$(package)
+ 	$(INSTALL_SCRIPT) debian/postinst debian/sensible-utils/DEBIAN/
+ 	$(INSTALL_SCRIPT) debian/postrm debian/sensible-utils/DEBIAN/
+@@ -87,6 +89,8 @@
+ 	cd debian/sensible-utils && find * -type f ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums
+ 
+ 	dpkg-gencontrol -Pdebian/sensible-utils
++	find debian/sensible-utils -depth -newermt '$(BUILD_DATE)' -print0 | \
++		xargs -0r touch --no-dereference --date='$(BUILD_DATE)'
+ 	dpkg --build debian/sensible-utils ..
+ 
+ define checkdir
diff --git a/patches/shadow_817971.patch b/patches/shadow_817971.patch
new file mode 100644
index 0000000..011d7c8
--- /dev/null
+++ b/patches/shadow_817971.patch
@@ -0,0 +1,29 @@
+>From 1d81ce999de214481a45d962a8ad03de22d293e4 Mon Sep 17 00:00:00 2001
+From: Niels Thykier <niels at thykier.net>
+Date: Sat, 12 Mar 2016 08:13:57 +0000
+Subject: [PATCH] d/rules: Explicitly set SHELL to /bin/bash
+
+Otherwise, configure will derive it from the environment and the
+package then differs based on the shell used by the builder.
+
+Signed-off-by: Niels Thykier <niels at thykier.net>
+---
+ debian/rules | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/debian/rules b/debian/rules
+index 51c0f5d..1519c38 100755
+--- a/debian/rules
++++ b/debian/rules
+@@ -19,7 +19,7 @@ DEB_DESTDIR=$(CURDIR)/debian/tmp
+ include /usr/share/cdbs/1/class/autotools.mk
+ 
+ # Adds extra options when calling the configure script:
+-DEB_CONFIGURE_EXTRA_FLAGS := --disable-shared --without-libcrack --mandir=/usr/share/man --with-libpam --enable-shadowgrp --enable-man --disable-account-tools-setuid --with-group-name-max-length=32 --without-acl --without-attr --without-tcb
++DEB_CONFIGURE_EXTRA_FLAGS := --disable-shared --without-libcrack --mandir=/usr/share/man --with-libpam --enable-shadowgrp --enable-man --disable-account-tools-setuid --with-group-name-max-length=32 --without-acl --without-attr --without-tcb SHELL=/bin/bash
+ ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+   DEB_CONFIGURE_EXTRA_FLAGS += --host=$(DEB_HOST_GNU_TYPE)
+ endif
+-- 
+2.7.0
+
diff --git a/patches/xz-utils_806331.patch b/patches/xz-utils_806331.patch
new file mode 100644
index 0000000..b328762
--- /dev/null
+++ b/patches/xz-utils_806331.patch
@@ -0,0 +1,49 @@
+diff -Nru xz-utils-5.1.1alpha+20120614/debian/changelog xz-utils-5.1.1alpha+20120614/debian/changelog
+--- xz-utils-5.1.1alpha+20120614/debian/changelog	2015-06-18 20:27:36.000000000 +0200
++++ xz-utils-5.1.1alpha+20120614/debian/changelog	2016-07-05 23:35:36.000000000 +0200
+@@ -1,3 +1,11 @@
++xz-utils (5.1.1alpha+20120614-2.2) UNRELEASED; urgency=medium
++
++  * Non-maintainer upload.
++  * Force a constant /bin/sh for installed scripts. This helps the build
++    be reproducible; /bin/sh on Debian is always POSIX. (Closes: #806331)
++
++ -- Ximin Luo <infinity0 at debian.org>  Sun, 03 Jul 2016 10:42:33 +0200
++
+ xz-utils (5.1.1alpha+20120614-2.1) unstable; urgency=medium
+ 
+   [ Helmut Grohne ]
+diff -Nru xz-utils-5.1.1alpha+20120614/debian/rules xz-utils-5.1.1alpha+20120614/debian/rules
+--- xz-utils-5.1.1alpha+20120614/debian/rules	2012-10-12 00:38:38.000000000 +0200
++++ xz-utils-5.1.1alpha+20120614/debian/rules	2016-07-03 11:01:15.000000000 +0200
+@@ -66,12 +66,14 @@
+ 
+ debian/normal-build/Makefile debian/normal-build/Doxyfile: $(configure_input)
+ 	dh_auto_configure --builddirectory debian/normal-build -- \
++		$(opt_reproduce) \
+ 		--disable-threads --disable-static \
+ 		$(opt_optimize) $(opt_quiet) \
+ 		--disable-xzdec --disable-lzmadec
+ 
+ debian/static-build/Makefile: $(configure_input)
+ 	dh_auto_configure --builddirectory debian/static-build -- \
++		$(opt_reproduce) \
+ 		--disable-threads --disable-shared \
+ 		--enable-liblzma2-compat \
+ 		$(opt_optimize) $(opt_quiet) \
+@@ -81,6 +83,7 @@
+ 
+ debian/xzdec-build/Makefile: $(configure_input)
+ 	dh_auto_configure --builddirectory debian/xzdec-build -- \
++		$(opt_reproduce) \
+ 		--disable-shared --disable-nls --disable-encoders \
+ 		--enable-small --disable-threads \
+ 		--disable-liblzma2-compat \
+@@ -97,6 +100,7 @@
+ flags_cmd = dpkg-buildflags --export=configure
+ opt_optimize = $(shell $(flags_cmd))
+ opt_optimize_small = $(shell $(small_flags_env) $(flags_cmd))
++opt_reproduce = gl_cv_posix_shell=/bin/sh
+ 
+ opt_no_act =
+ opt_quiet =
diff --git a/repatch b/repatch
new file mode 100755
index 0000000..3cce764
--- /dev/null
+++ b/repatch
@@ -0,0 +1,48 @@
+#!/bin/sh
+# Depends: dpkg-dev, quilt
+#
+# Usage: ./repatch $package
+# e.g.: ./all-patched-pkgs | xargs -rn1 ./repatch
+#
+scriptdir="$(readlink -f "$(dirname "$0")")"
+patchdir="${patchdir:-$scriptdir/patches}"
+set -e
+
+test -n "$1" || exit
+
+# TODO:
+# options: -k # don't refresh patches
+# options: -n # re-use existing dsc, don't rm
+# options: -u # upload to $HOST
+# options: -b # build using reprotest
+# options: -f # build even if no version change (diff source version = current version)
+
+srcpkg="$1"
+
+mkdir -p "$scriptdir/build" && cd "$scriptdir/build"
+rm -rf "./$srcpkg" # TODO: disable this if -n
+mkdir -p "$srcpkg" && cd "$srcpkg"
+
+apt-get source "$srcpkg"
+olddsc="$(ls -1 *.dsc)"
+cd "$srcpkg"-*
+for i in "$patchdir/$srcpkg"_*.patch; do
+    # TODO: this would *probably* not work very well if we actually have
+    # multiple patchs for any source package. Try it and see! :p
+    "$scriptdir/debpatch" -v "$i"
+done
+# TODO: make this step optional
+alias dquilt='QUILT_PATCHES=debian/patches quilt'
+{ dquilt pop -afq || true; while dquilt push -q; do dquilt refresh; done; } >/dev/null
+dpkg-buildpackage -d -S
+version="$(dpkg-parsechangelog -c1 -SVersion | sed -e 's/^[0-9]*://')"
+newdsc="${srcpkg}_${version}.dsc"
+cd ..
+
+echo >&2 "$srcpkg patched successfully"
+ls -l "$olddsc" "$newdsc"
+
+# TODO: this doesn't work so well atm, the `dquilt refresh` stuff adds lots of
+# cruft to this debdiff, but unfortunately it's necessary to build the .dsc.
+#debdiff "$olddsc" "$newdsc" > "$patchdir/$srcpkg.debdiff" || true
+#echo >&2 "refreshed patch written to $patchdir/$srcpkg.debdiff"

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



More information about the Reproducible-commits mailing list