[debrepatch] 01/02: repatch: refresh d/patches only if necessary
Ximin Luo
infinity0 at debian.org
Tue Sep 20 12:55:41 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 663c06c12c9506548c65ff8326afc4f34d9d2364
Author: Ximin Luo <infinity0 at debian.org>
Date: Tue Sep 20 14:55:13 2016 +0200
repatch: refresh d/patches only if necessary
---
all-patched-pkgs | 2 +-
debpatch | 4 ++++
repatch | 49 ++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 45 insertions(+), 10 deletions(-)
diff --git a/all-patched-pkgs b/all-patched-pkgs
index 9af8672..2be332b 100755
--- a/all-patched-pkgs
+++ b/all-patched-pkgs
@@ -1,3 +1,3 @@
#!/bin/sh
scriptdir="$(readlink -f "$(dirname "$0")")"
-ls -1 "$scriptdir/patches" | cut -f1 -d_ | sort -u
+find "$scriptdir/patches/" -type f -name '*.patch' | xargs -r -n1 basename | cut -f1 -d_ | sort -u
diff --git a/debpatch b/debpatch
index 1c76fa2..93af626 100755
--- a/debpatch
+++ b/debpatch
@@ -182,7 +182,11 @@ def main(args):
patch.remove(changelog[0])
old_version, target = read_dch_patch(changelog[0])
+ # TODO: if we patched any patch in d/patches, then we should refresh *that*
+ # patch here. this is hard, but it would help us to avoid refreshing *all*
+ # patches in ./repatch, hopefully ending up with a smaller debdiff.
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())
diff --git a/repatch b/repatch
index 3cce764..b7340e0 100755
--- a/repatch
+++ b/repatch
@@ -2,7 +2,8 @@
# Depends: dpkg-dev, quilt
#
# Usage: ./repatch $package
-# e.g.: ./all-patched-pkgs | xargs -rn1 ./repatch
+# e.g.: ./all-patched-pkgs | xargs -rn1 ./repatch -y
+# watch out! if xargs gives non-0 exit code, it means there was a failure
#
scriptdir="$(readlink -f "$(dirname "$0")")"
patchdir="${patchdir:-$scriptdir/patches}"
@@ -10,13 +11,20 @@ set -e
test -n "$1" || exit
+# options: -y # answer "yes" to all questions, e.g. when naive source-build fails
# 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)
+maybe_ask() { read -p "$1 (press enter to continue) " x >&2; }
+if [ "$1" = "-y" ]; then
+ maybe_ask() { echo >&2 "$1"; }
+ shift
+fi
+export QUILT_PATCHES=debian/patches
+
srcpkg="$1"
mkdir -p "$scriptdir/build" && cd "$scriptdir/build"
@@ -31,10 +39,29 @@ for i in "$patchdir/$srcpkg"_*.patch; do
# 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
+
+build_dsc() {
+ # we give "-nc" because:
+ #
+ # (1) some packages use build-dependencies in the "clean" rule and we'd
+ # otherwise have to install them.
+ # (2) this might interfere with our ability to retry build_dsc in case it
+ # fails - e.g. because "clean" might remove source files or whatever.
+ #
+ # Since we did nothing to the package, "-nc" is fine and we can ignore
+ # dpkg-buildpackage's warning about "might contain undesired files".
+ dpkg-buildpackage -d -nc -S
+}
+
+refreshed_patches=false
+if ! build_dsc; then
+ maybe_ask "*** Failed to create source package, will refresh patches and try again."
+ { quilt pop -afq || true; while quilt push -q; do quilt refresh; done; } >/dev/null
+ refreshed_patches=true
+
+ build_dsc
+fi
+
version="$(dpkg-parsechangelog -c1 -SVersion | sed -e 's/^[0-9]*://')"
newdsc="${srcpkg}_${version}.dsc"
cd ..
@@ -42,7 +69,11 @@ 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
+# TODO: this doesn't work so well atm, the `quilt 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"
+debdiff "$olddsc" "$newdsc" > "$patchdir/$srcpkg.patch.new" || true
+echo >&2 "updated patch written to $patchdir/$srcpkg.patch.new"
+if $refreshed_patches; then
+ echo >&2 "however, we had to refresh d/patches in order to build $newdsc;"
+ echo >&2 "you should review the updated patch for unnecessary cruft before re-submitting it."
+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