[devscripts] 01/01: debrepro: add -s/--skip option to skip any of the supported variations

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Dec 4 20:12:13 UTC 2016


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

terceiro pushed a commit to branch master
in repository devscripts.

commit be8e87d613490a9df2622ec9038e4c23f17cd9aa
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Sun Dec 4 18:08:46 2016 -0200

    debrepro: add -s/--skip option to skip any of the supported variations
    
    Closes: #846365
---
 debian/changelog     |  3 ++
 scripts/debrepro.pod | 19 +++++++++---
 scripts/debrepro.sh  | 88 ++++++++++++++++++++++++++++++++++++++++------------
 3 files changed, 86 insertions(+), 24 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index f34511b..13faf4d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,6 +12,9 @@ devscripts (2.16.11) UNRELEASED; urgency=medium
       Debian source package.
     + fix manpage to mention what exactly is executed on each directory (i.e.
       debclean calls `debuild -- clean`, not `debian/rules clean`)
+  * debrepro:
+    + add -s/--skip option to skip any of the supported variations
+      (Closes: #846365)
 
  -- James McCoy <jamessan at debian.org>  Wed, 30 Nov 2016 00:05:18 -0500
 
diff --git a/scripts/debrepro.pod b/scripts/debrepro.pod
index 050ed10..398757a 100644
--- a/scripts/debrepro.pod
+++ b/scripts/debrepro.pod
@@ -4,7 +4,7 @@ debrepro - reproduciblity tester for Debian packages
 
 =head1 SYNOPSIS
 
-B<debrepro> [I<SOURCEDIR>]
+B<debrepro> [I<OPTIONS>] [I<SOURCEDIR>]
 
 =head1  DESCRIPTION
 
@@ -53,12 +53,12 @@ exactly what changed between the two builds.
 
 =over
 
-=item B<USER>
+=item B<user>
 
 The I<$USER> environment variable will contain different values between the
 first and second builds.
 
-=item B<PATH>
+=item B<path>
 
 During the second build, a fake, unexisting directory will be appended to the
 I<$PATH> environment variable.
@@ -75,7 +75,7 @@ Both I<$LC_ALL> and I<$LANG> will be different across the two builds.
 
 I<$TZ> will be different across builds.
 
-=item filesystem ordering
+=item filesystem-ordering
 
 If B<disorderfs> is installed, both builds will be done under a disorderfs
 overlay directory. This will cause filesystem listing operations to be return
@@ -88,6 +88,17 @@ future with regards to the current time.
 
 =back
 
+=head1 OPTIONS
+
+=over
+
+=item -s VARIATION, --skip VARIATION
+
+Don't perform the named VARIATION. Variation names are the ones used in
+their description in section B<SUPPORTED VARIATIONS>.
+
+=back
+
 =head1 EXIT STATUS
 
 =over
diff --git a/scripts/debrepro.sh b/scripts/debrepro.sh
index 21e42a8..d49943f 100755
--- a/scripts/debrepro.sh
+++ b/scripts/debrepro.sh
@@ -19,6 +19,10 @@
 
 set -eu
 
+usage() {
+  echo "usage: $0 [OPTIONS] [SOURCEDIR]"
+}
+
 first_banner=y
 banner() {
   if [ "$first_banner" = n ]; then
@@ -37,8 +41,17 @@ variation() {
 }
 
 vary() {
-  local first="$1"
-  local second="$2"
+  local var="$1"
+
+  for skipped in $skip_variations; do
+    if [ "$skipped" = "$var" ]; then
+      return
+    fi
+  done
+
+  variation "$var"
+  local first="$2"
+  local second="$3"
   if [ "$which_build" = 'first' ]; then
     if [ -n "$first" ]; then
       echo "$first"
@@ -56,34 +69,41 @@ create_build_script() {
   echo "# package"
   echo
 
-  variation PATH
-  vary '' 'export PATH="$PATH":/i/capture/the/path'
+  vary path \
+    '' \
+    'export PATH="$PATH":/i/capture/the/path'
 
-  variation USER
-  vary 'export USER=user1' 'export USER=user2'
+  vary user \
+    'export USER=user1' \
+    'export USER=user2'
 
-  variation umask
-  vary 'umask 0022' 'umask 0002'
+  vary umask \
+    'umask 0022' \
+    'umask 0002'
 
-  variation locale
-  vary 'export LC_ALL=C.UTF-8 LANG=C.UTF-8' \
+  vary locale \
+    'export LC_ALL=C.UTF-8 LANG=C.UTF-8' \
     'export LC_ALL=pt_BR.UTF-8 LANG=pt_BR.UTF-8'
 
-  variation timezone
-  vary 'export TZ=UTC' \
+  vary timezone \
+    'export TZ=UTC' \
     'export TZ=Asia/Tokyo'
 
   if which disorderfs >/dev/null; then
-    variation filesystem ordering
-    echo 'mkdir ../disorderfs'
-    echo 'disorderfs --shuffle-dirents=yes $(pwd) ../disorderfs'
-    echo 'trap "cd .. && fusermount -u disorderfs && rmdir disorderfs" INT TERM EXIT'
-    echo 'cd ../disorderfs'
+    disorderfs_commands='mkdir ../disorderfs &&
+disorderfs --shuffle-dirents=yes $(pwd) ../disorderfs &&
+trap "cd .. && fusermount -u disorderfs && rmdir disorderfs" INT TERM EXIT &&
+cd ../disorderfs'
+    vary filesystem-ordering \
+      '' \
+      "$disorderfs_commands"
   fi
 
-  variation date
-  vary 'dpkg-buildpackage -b -us -uc' \
-    'faketime +213days+7hours+13minutes dpkg-buildpackage -b -us -uc'
+  vary time \
+    'build_prefix=""' \
+    'build_prefix="faketime +213days+7hours+13minutes"'
+
+  echo '$build_prefix dpkg-buildpackage -b -us -uc'
 }
 
 
@@ -127,6 +147,34 @@ compare() {
   return "$rc"
 }
 
+TEMP=$(getopt -n "debrepro" -o 's:' \
+	      -l 'skip:' \
+	      -- "$@") || (rc=$?; usage >&2; exit $rc)
+eval set -- "$TEMP"
+
+skip_variations=""
+while true; do
+  case "$1" in
+    -s|--skip)
+      case "$2" in
+	user|path|umask|locale|timezone|filesystem-ordering)
+	  skip_variations="$skip_variations $2"
+	  ;;
+	*)
+	  echo "E: invalid variation name $2"
+	  exit 1
+	  ;;
+      esac
+      shift
+      ;;
+    --)
+      shift
+      break
+      ;;
+  esac
+  shift
+done
+
 SOURCE="${1:-}"
 if [ -z "$SOURCE" ]; then
   SOURCE="$(pwd)"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list