[debrepatch] 01/01: repatch: add a postpatch utility and some extra examples

Ximin Luo infinity0 at debian.org
Mon Sep 26 16:53:26 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 03d932b4054a1adbfe218f5fb273efc4552af9e2
Author: Ximin Luo <infinity0 at debian.org>
Date:   Mon Sep 26 18:43:29 2016 +0200

    repatch: add a postpatch utility and some extra examples
---
 README.rst | 12 ++++++++++++
 postpatch  | 34 ++++++++++++++++++++++++++++++++++
 repatch    | 14 ++++++--------
 3 files changed, 52 insertions(+), 8 deletions(-)

diff --git a/README.rst b/README.rst
index ad59ef7..52a6519 100644
--- a/README.rst
+++ b/README.rst
@@ -12,6 +12,18 @@ 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.
 
+Usage
+=====
+
+Examples:
+
+$ ./all-patched-pkgs | xargs -I '{}' -rn1 ./repatch -yf '{}' "$PWD/postpatch" \
+    reprotest --diffoscope-arg=--text --diffoscope-arg="$PWD/{}.diffoscope"
+$ ./all-patched-pkgs | xargs -I '{}' -rn1 ./repatch -yf '{}' "$PWD/postpatch" \
+    dput my-apt-repo
+
+Watch out! if xargs gives non-0 exit code, it means there was a failure.
+
 Contributing
 ============
 
diff --git a/postpatch b/postpatch
new file mode 100755
index 0000000..6c8f9e8
--- /dev/null
+++ b/postpatch
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Run a command after repatch(1) succeeds.
+#
+# Usage: $0 dput [options] [host]
+# Usage: $0 reprotest [options] [virtual_server_args]
+#
+# Depends: dput, reprotest
+#
+set -e
+
+subcmd="$1"
+shift
+
+log() {
+    # TODO: add some colours based on $1
+    echo >&2 "$0: $2"
+}
+
+srcpkg="$(dpkg-parsechangelog -SSource)"
+
+case "$subcmd" in
+dput)
+    if [ "$(ls -1 ../"$srcpkg"*_source.changes | wc -l)" -gt 1 ]; then
+        log W "more than one ${srcpkg}*_source.changes detected; abort"
+        ls -l ../"$srcpkg"*_source.changes
+        exit 1
+    fi
+    debsign ../*_source.changes
+    exec dput "$@" ../*_source.changes
+    ;;
+reprotest)
+    exec reprotest 'debuild -us -uc -b' '../*.deb' "$@"
+    ;;
+esac
diff --git a/repatch b/repatch
index 1af9381..409eeb1 100755
--- a/repatch
+++ b/repatch
@@ -1,15 +1,13 @@
 #!/bin/sh
-# Depends: dpkg-dev, quilt
+# Apply a debdiff to the latest version of a package, and maybe run a command.
 #
-# Usage: ./repatch $package
-# e.g.: ./all-patched-pkgs | xargs -rn1 ./repatch -y
-# watch out! if xargs gives non-0 exit code, it means there was a failure
+# Depends: dpkg-dev, quilt
 #
 scriptdir="$(readlink -f "$(dirname "$0")")"
 debpatch="$scriptdir/debpatch"
 set -e
 
-USAGE="Usage: $0 [-hyuf] [-d patchdir] SOURCE_PACKAGE [post_patch_command [args ...]]"
+USAGE="Usage: $0 [-hyuf] [-b dir] [-d dir] SOURCE_PACKAGE [post_patch_command [args ...]]"
 force_yes=false
 auto_update=false
 force_postpatch=false
@@ -61,7 +59,7 @@ shift
 
 if [ "$(ls -1 "$patchdir/$srcpkg"_*.patch | wc -l)" -gt 1 ]; then
     log W "not sure how to apply more than 1 patch: "
-    ls -1 "$patchdir/$srcpkg"_*.patch
+    ls -l "$patchdir/$srcpkg"_*.patch
     exit 1
 fi
 patchfile="$(readlink -f "$patchdir/$srcpkg"_*.patch)"
@@ -125,7 +123,7 @@ fi
 if [ -z "$*" ]; then exit 0; fi
 
 if [ "$("$debpatch" --source-version "$patchfile")" != "$oldver" ] || $force_postpatch; then
-    cd "$srcdir"
-    log I "running post-patch command:" "$@"
+    cd "$srcpkg"-* # dch sometimes renames the directory :/
+    log I "running post-patch command: $*"
     exec "$@"
 fi

-- 
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