[debrepatch] 01/03: debpatch: add a --directory option for post-examination under a stable path

Ximin Luo infinity0 at debian.org
Thu Nov 17 19:10:21 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 949d2fb7c56dbb0921f93ab2cc112e871db213a8
Author: Ximin Luo <infinity0 at debian.org>
Date:   Thu Nov 17 19:38:29 2016 +0100

    debpatch: add a --directory option for post-examination under a stable path
---
 debpatch   | 14 ++++++++++----
 debrepatch |  6 ++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/debpatch b/debpatch
index 20cd852..061d63d 100755
--- a/debpatch
+++ b/debpatch
@@ -226,6 +226,9 @@ def main(args):
     group1.add_argument('--quilt-refresh', action="store_true",
         help="If the building of the new source package fails, try to refresh "
         "patches using quilt(1) then try building it again.")
+    group1.add_argument('-d', '--directory', default=None,
+        help="Extract the .dsc into this directory. If not given, then it will "
+        "be extracted to a temporary directory.")
     args = parser.parse_args(args)
     #print(args)
 
@@ -259,9 +262,11 @@ def main(args):
         parts = os.path.splitext(os.path.basename(args.orig_dsc_or_dir))
         if parts[1] != ".dsc":
             raise ValueError("unrecognised patch target: %s" % args.orig_dsc_or_dir)
-        temp_dir = tempfile.mkdtemp()
+        extractdir = args.directory if args.directory else tempfile.mkdtemp()
+        if not os.path.isdir(extractdir):
+            os.makedirs(extractdir)
         try:
-            builddir = os.path.join(temp_dir, parts[0]) # dpkg-source doesn't like existing dirs
+            builddir = os.path.join(extractdir, parts[0]) # dpkg-source doesn't like existing dirs
             C(["dpkg-source", "-x", "--skip-patches", args.orig_dsc_or_dir, builddir], stdout=stdout)
             origdir = os.getcwd()
             os.chdir(builddir)
@@ -283,10 +288,11 @@ while quilt push; do quilt refresh; done
                 else:
                     raise
         finally:
+            cleandir = builddir if args.directory else extractdir
             if args.no_clean:
-                logging.warn("you should clean up temp files in %s", temp_dir)
+                logging.warn("you should clean up temp files in %s", cleandir)
             else:
-                shutil.rmtree(temp_dir)
+                shutil.rmtree(cleandir)
 
 if __name__ == "__main__":
     sys.exit(main(sys.argv[1:]))
diff --git a/debrepatch b/debrepatch
index 23f358a..712dc29 100755
--- a/debrepatch
+++ b/debrepatch
@@ -3,8 +3,6 @@
 #
 # Depends: dpkg-dev
 #
-scriptdir="$(readlink -f "$(dirname "$0")")"
-debpatch="$scriptdir/debpatch"
 set -e
 
 USAGE="Usage: $0 [-hyuf] [-p dir] [-b dir] SOURCE_PACKAGE [post_patch_command [args ...]]"
@@ -74,7 +72,7 @@ srcdir="$srcpkg-$(echo "$oldver" | sed -re 's/([^:]*:)?(.*)-.*/\2/')"
 apt-get source "$srcpkg"
 olddsc="$(ls -1 *.dsc)" # TODO: probably more correct to use $oldver
 rm -rf "$srcdir"
-"$debpatch" --verbose --no-clean "$olddsc" "$patchfile"
+debpatch --verbose --no-clean --directory . "$olddsc" "$patchfile"
 newdsc="$(ls -1 *.dsc | grep -v -F "$olddsc")"
 
 log I "$srcpkg patched successfully"
@@ -85,7 +83,7 @@ log I "updated patch written to $patchdir/$srcpkg.patch.new"
 
 if [ -z "$*" ]; then exit 0; fi
 
-if [ "$("$debpatch" --source-version "$patchfile")" != "$oldver" ] || $force_postpatch; then
+if [ "$(debpatch --source-version "$patchfile")" != "$oldver" ] || $force_postpatch; then
     cd "$srcpkg"-* # dch sometimes renames the directory :/
     log I "running post-patch command: $*"
     exec "$@"

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