X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=scripts%2Fdebian%2Fbyhand-tag;h=f9840cfd89237aba5b0c25a2a783ea55fecae6cf;hb=50f26809b94b7ead43838cec97e878e8fcfd0261;hp=81a8946676a8a3af626813d7e4ac4c8798b98c90;hpb=f0bfd37e7286156598d79b53501ebe2000bb7924;p=dak.git diff --git a/scripts/debian/byhand-tag b/scripts/debian/byhand-tag index 81a89466..f9840cfd 100755 --- a/scripts/debian/byhand-tag +++ b/scripts/debian/byhand-tag @@ -1,4 +1,8 @@ -#!/bin/sh -ue +#!/bin/bash + +set -u +set -e +set -o pipefail export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars . $SCRIPTVARS @@ -7,13 +11,13 @@ export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars INPUT="${1:?"Usage: $0 filename"}" # Regular expression used to validate tag lines -CHECKRE='^[a-z0-9A-Z.+-]+[[:space:]]+Tag[[:space:]]+[a-z0-9:. ,{}+-]+$' +CHECKRE='^([a-z0-9A-Z.+-]+[[:space:]]+Tag)?[[:space:]]+[A-Za-z0-9:. ,{}+-]+$' # This must end with / TARGET=/srv/ftp-master.debian.org/scripts/external-overrides/ # Read the main directory from the tarball -DIR="`tar ztf \"$INPUT\" | tac | tail -n 1`" +DIR="`tar ztf \"$INPUT\" | tail -n 1 | cut -d/ -f1`" # Create temporary files where to store the validated data umask 002 @@ -30,9 +34,18 @@ cleanup() { trap cleanup EXIT # Extract the data into the temporary files -tar -O -zxf "$INPUT" "$DIR"tag | grep -E "$CHECKRE" > "$OUTMAIN" -tar -O -zxf "$INPUT" "$DIR"tag.contrib | grep -E "$CHECKRE" > "$OUTCONTRIB" -tar -O -zxf "$INPUT" "$DIR"tag.non-free | grep -E "$CHECKRE" > "$OUTNONFREE" +tar -O -zxf "$INPUT" "$DIR"/tag > "$OUTMAIN" +tar -O -zxf "$INPUT" "$DIR"/tag.contrib > "$OUTCONTRIB" +tar -O -zxf "$INPUT" "$DIR"/tag.non-free > "$OUTNONFREE" + +# check temporary files for invalid contents +status=0 +grep -vq -E "$CHECKRE" "$OUTMAIN" "$OUTCONTRIB" "$OUTNONFREE" || status=$? +# checking just $? != 0 is not enough. grep can return 2 on other errors. +if [ $status != 1 ]; then + echo "Aborting automatic import (invalid data found)." >&2 + exit 1 +fi # Move the data to the final location mv "$OUTMAIN" "$TARGET"tag @@ -41,7 +54,11 @@ mv "$OUTNONFREE" "$TARGET"tag.non-free chmod 644 "$TARGET"tag "$TARGET"tag.contrib "$TARGET"tag.non-free -(cd $TARGET && $scriptsdir/mk-extra-overrides.sh) +(cd "$TARGET" \ + && dak external-overrides import unstable main Tag