X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=scripts%2Fdebian%2Fbyhand-tag;h=f9840cfd89237aba5b0c25a2a783ea55fecae6cf;hb=a48e18b7123f73fc618ded1332a199965821e515;hp=e9cb43acc6b07c9031d94193612fc5f8c974fb04;hpb=16f731a893f0ba036a995c25b8b5f3490394070e;p=dak.git diff --git a/scripts/debian/byhand-tag b/scripts/debian/byhand-tag index e9cb43ac..f9840cfd 100755 --- a/scripts/debian/byhand-tag +++ b/scripts/debian/byhand-tag @@ -1,16 +1,23 @@ -#!/bin/sh -ue +#!/bin/bash + +set -u +set -e +set -o pipefail + +export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars +. $SCRIPTVARS # Tarball to read, compressed with gzip 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.debian.org/scripts/external-overrides/ +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 @@ -27,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 @@ -38,7 +54,11 @@ mv "$OUTNONFREE" "$TARGET"tag.non-free chmod 644 "$TARGET"tag "$TARGET"tag.contrib "$TARGET"tag.non-free -(cd $TARGET && ./mk-extra-overrides.sh) +(cd "$TARGET" \ + && dak external-overrides import unstable main Tag