X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=scripts%2Fdebian%2Fbyhand-tag;h=f9840cfd89237aba5b0c25a2a783ea55fecae6cf;hb=50f26809b94b7ead43838cec97e878e8fcfd0261;hp=9c24fb66c1013480834730732df570764286b054;hpb=903c9d56e9a495c830be585a921c0fcd139c8cb6;p=dak.git diff --git a/scripts/debian/byhand-tag b/scripts/debian/byhand-tag index 9c24fb66..f9840cfd 100755 --- a/scripts/debian/byhand-tag +++ b/scripts/debian/byhand-tag @@ -1,7 +1,8 @@ -#!/bin/sh +#!/bin/bash set -u set -e +set -o pipefail export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars . $SCRIPTVARS @@ -10,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 @@ -33,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 @@ -44,8 +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" && cat tag tag.contrib tag.non-free | dak external-overrides import Tag) +(cd "$TARGET" \ + && dak external-overrides import unstable main Tag