Modernize debcheck scripts
authorChristoph Berg <myon@debian.org>
Sat, 6 Aug 2016 14:03:05 +0000 (16:03 +0200)
committerChristoph Berg <myon@debian.org>
Sat, 6 Aug 2016 14:03:05 +0000 (16:03 +0200)
Requires dose3 backport

jenkins/builddebcheck-pgapt
jenkins/debcheck-pgapt

index 5e02970a5142157141a9e7a5edbb5da1a5b86642..70de085aec23faeb46c87e76f20455e7ac8830c0 100755 (executable)
@@ -1,27 +1,47 @@
 #!/bin/sh
 
+# expected parameters:
+#   distribution (without -pgdg)
+#   architecture
+#   stage (testing or production)
+# expected directories: chroots in /home/chroot
+# needs dose3 >= 4
+
 set -eu
 
+error () {
+  echo "Error: $@" >&2
+  exit 2
+}
+
+: ${distribution:=sid} ${architecture:=amd64} ${stage:=testing}
+
 LISTSDIR="/home/chroot/$distribution-$architecture/var/lib/apt/lists"
+[ -d "$LISTSDIR" ] || error "$LISTSDIR not found"
 BPODIR="/home/chroot/$distribution-$architecture/var/lib/apt/backports"
 HOMEDIR="/home/jenkins"
-DISTSDIR="$HOMEDIR/dists"
-PGAPTDIR="$HOMEDIR/apt.postgresql.org/jenkins"
 
+# where to find packages.backports
+PGAPTDIR="$HOMEDIR/apt.postgresql.org/jenkins"
 test -d $PGAPTDIR && cd $PGAPTDIR
 
+if [ -d ../repo/dists ]; then
+  DISTSDIR="../repo/dists"
+elif [ -d "$HOMEDIR/dists" ]; then
+  DISTSDIR="$HOMEDIR/dists"
+else
+  error "No dists directory found."
+fi
+
 # main package list
 PKG="$LISTSDIR/*_dists_${distribution}_main_binary-${architecture}_Packages"
 
-trap 'rm -f ${TMPPKG:-} ${MAINSRC:-} ${BPOSRC:-}' 0 2 3 15
+trap 'rm -f ${MAINSRC:-} ${BPOSRC:-}' 0 2 3 15
 
 # include universe on ubuntu
 for FILE in $LISTSDIR/*_dists_${distribution}_universe_binary-${architecture}_Packages ; do
-       [ -f "$FILE" ] || continue
-       # work around dose-debcheck dying on a Python_ field
-       TMPPKG=$(mktemp ${distribution}_universe_binary-${architecture}_Packages.XXXXXX)
-       sed -e 's/^Python_/Python-/' $FILE > $TMPPKG
-       PKG="$PKG $TMPPKG"
+  [ -f "$FILE" ] || continue
+  PKG="$PKG $FILE"
 done
 
 # packages not depending on backports
@@ -30,6 +50,7 @@ zcat $DISTSDIR/$distribution-pgdg-testing/main/source/Sources.gz > $MAINSRC
 
 case $distribution in
   squeeze|wheezy|jessie)
+    [ -f packages.backports ] || error "packages.backports not found"
     for pkg in $(cat packages.backports); do
       grep-dctrl --not -S $pkg $MAINSRC > $MAINSRC.tmp
       mv $MAINSRC.tmp $MAINSRC
@@ -43,6 +64,7 @@ case $distribution in
     done
 
     # include backports on debian
+    [ -d "$BPODIR" ] || error "$BPODIR not found"
     for FILE in $BPODIR/*_dists_${distribution}-backports_main_binary-${architecture}_Packages ; do
       [ -f "$FILE" ] || continue
       BPO="$FILE"
@@ -61,7 +83,7 @@ case $stage in
                DIST="$distribution-pgdg-testing"
                PKG="$PKG $DISTSDIR/$DIST/main/binary-${architecture}/Packages"
                ;;
-       *) echo "Bad stage $stage" ; exit 1 ;;
+       *) error "Bad stage $stage" ;;
 esac
 
 set -x
index 75e07f9d2bf25faf2b9ada781a01f26b5ab482ca..37704a0517ca15d58e2509932f70addd0bb459e9 100755 (executable)
@@ -1,29 +1,49 @@
 #!/bin/sh
 
+# expected parameters:
+#   distribution (without -pgdg)
+#   architecture
+#   stage (testing or production)
+# expected directories: chroots in /home/chroot
+# needs dose3 >= 4
+
 set -eu
 
+error () {
+  echo "Error: $@" >&2
+  exit 2
+}
+
+: ${distribution:=sid} ${architecture:=amd64} ${stage:=testing}
+
 LISTSDIR="/home/chroot/$distribution-$architecture/var/lib/apt/lists"
+[ -d "$LISTSDIR" ] || error "$LISTSDIR not found"
 HOMEDIR="/home/jenkins"
-DISTSDIR="$HOMEDIR/dists"
-PGAPTDIR="$HOMEDIR/apt.postgresql.org/jenkins"
 
+# where to find packages.backports
+PGAPTDIR="$HOMEDIR/apt.postgresql.org/jenkins"
 test -d $PGAPTDIR && cd $PGAPTDIR
 
+if [ -d ../repo/dists ]; then
+  DISTSDIR="../repo/dists"
+elif [ -d "$HOMEDIR/dists" ]; then
+  DISTSDIR="$HOMEDIR/dists"
+else
+  error "No dists directory found."
+fi
+
 case $stage in
        production) DIST="$distribution-pgdg" ;;
        testing)    DIST="$distribution-pgdg-testing" ;;
-       *) echo "Bad stage $stage" ; exit 1 ;;
+       *) error "Bad stage $stage" ;;
 esac
 
-trap 'rm -f ${TMPPKG:-} ${MAINPKG:-} ${BPOPKG:-}' 0 2 3 15
+trap 'rm -f ${MAINPKG:-} ${BPOPKG:-}' 0 2 3 15
 
 # include universe on ubuntu
 for FILE in $LISTSDIR/*_dists_${distribution}_universe_binary-${architecture}_Packages ; do
-       [ -f "$FILE" ] || continue
-       # work around dose-debcheck dying on a Python_ field
-       TMPPKG=$(mktemp ${distribution}_universe_binary-${architecture}_Packages.XXXXXX)
-       sed -e 's/^Python_/Python-/' $FILE > $TMPPKG
-       EXTRABG="--bg $TMPPKG"
+  [ -f "$FILE" ] || continue
+  EXTRABG="--bg $FILE"
 done
 
 # include latest N.N components on sid