[debrepatch] 03/03: debrepatch: merge postpatch into this to avoid some boilerplate

Ximin Luo infinity0 at debian.org
Thu Nov 17 19:10:22 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 598f76193bbdeb7ad385d5944e925153255ac901
Author: Ximin Luo <infinity0 at debian.org>
Date:   Thu Nov 17 20:09:38 2016 +0100

    debrepatch: merge postpatch into this to avoid some boilerplate
---
 README.rst | 10 +++++++---
 debrepatch | 46 +++++++++++++++++++++++++++++++++++++++++-----
 postpatch  | 34 ----------------------------------
 3 files changed, 48 insertions(+), 42 deletions(-)

diff --git a/README.rst b/README.rst
index 3fa7c28..a59fb77 100644
--- a/README.rst
+++ b/README.rst
@@ -18,24 +18,28 @@ Setting up
 Required:
 $ aptitude install quilt dpkg-dev devscripts python3-unidiff
 
+Required, until we get this into devscripts
+$ which debpatch || { test -x ./debpatch && export PATH=$PWD:$PATH; }
+
 Optional, if you want to auto-upload or auto-rebuild:
 $ aptitude install dput reprotest
 
+
 Usage
 =====
 
 Examples:
 
 # Test that everything patches correctly
-$ ./all-patched-pkgs | xargs -rn1 ./debrepatch -y
+$ ./all-patched-pkgs | xargs -rn1 ./debrepatch
 
 # Patch all packages and run them through reprotest
-$ ./all-patched-pkgs | xargs -rn1 -I '{}' ./debrepatch -yf '{}' "$PWD/postpatch" \
+$ ./all-patched-pkgs | xargs -rn1 -I '{}' ./debrepatch -f '{}' \
     reprotest --diffoscope-arg=--text --diffoscope-arg="$PWD/{}.diffoscope" \
               --diffoscope-arg=--output-empty
 
 # Patch all packages and upload them to the "my-apt-repo" dput host
-$ ./all-patched-pkgs | xargs -rn1 -I '{}' ./debrepatch -yf '{}' "$PWD/postpatch" \
+$ ./all-patched-pkgs | xargs -rn1 -I '{}' ./debrepatch -f '{}' \
     dput my-apt-repo
 
 Watch out! if xargs gives non-0 exit code, it means there was a failure.
diff --git a/debrepatch b/debrepatch
index 712dc29..0f160bb 100755
--- a/debrepatch
+++ b/debrepatch
@@ -2,6 +2,7 @@
 # Apply a debdiff to the latest version of a package, and maybe run a command.
 #
 # Depends: dpkg-dev
+# Recommends: dput, reprotest
 #
 set -e
 
@@ -31,6 +32,19 @@ unpacked and patched package source directory.
                 debian/changelog in the patch file.
   -p            Directory to find patches in; default ./patches
   -b            Directory to build new packages in; default ./build
+
+post_patch_command [args ...] is one of:
+
+dput [options] [host]
+                Generate a *_source.changes, debsign it, and dput it to the
+                given host using the given options.
+
+reprotest [options] [virtual_server_args]
+                Build the package using reprotest(1).
+
+exec [args]
+                Run an arbitrary command.
+
 EOF
             exit 2
             ;;
@@ -81,10 +95,32 @@ ls -l "$olddsc" "$newdsc"
 debdiff "$olddsc" "$newdsc" > "$patchdir/$srcpkg.patch.new" || true
 log I "updated patch written to $patchdir/$srcpkg.patch.new"
 
-if [ -z "$*" ]; then exit 0; fi
+if [ -z "$*" ]; then
+    exit 0
+elif [ "$(debpatch --source-version < "$patchfile")" = "$oldver" ] && ! $force_postpatch; then
+    exit 0
+fi
 
-if [ "$(debpatch --source-version "$patchfile")" != "$oldver" ] || $force_postpatch; then
-    cd "$srcpkg"-* # dch sometimes renames the directory :/
-    log I "running post-patch command: $*"
+### Post-patch commands
+
+cd "$srcpkg"_*
+log I "running post-patch command in $PWD:"
+log I "$*"
+
+subcmd="$1"
+shift
+
+case "$subcmd" in
+dput)
+    changes="${newdsc%.dsc}_source.changes"
+    dpkg-genchanges -S > "../$changes"
+    debsign "../$changes"
+    exec dput "$@" "../$changes"
+    ;;
+reprotest)
+    exec reprotest 'debuild -us -uc -b' '../*.deb' "$@"
+    ;;
+exec)
     exec "$@"
-fi
+    ;;
+esac
diff --git a/postpatch b/postpatch
deleted file mode 100755
index 266cacb..0000000
--- a/postpatch
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/bin/sh
-# Run a command after debrepatch(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 ../"$srcpkg"*_source.changes
-    exec dput "$@" ../"$srcpkg"*_source.changes
-    ;;
-reprotest)
-    exec reprotest 'debuild -us -uc -b' '../*.deb' "$@"
-    ;;
-esac

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