From: Ansgar Burchardt Date: Sat, 18 Feb 2012 13:25:59 +0000 (+0000) Subject: byhand-tag: abort on invalid data X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=63315c8c29f98dd84bfda5c2e0f4c6ef4903f916;p=dak.git byhand-tag: abort on invalid data Abort processing if we find invalid data instead of silently ignoring invalid lines. This became more important since we now allow multi-line fields and skipping lines might result in merging different entries or incomplete entries. --- diff --git a/scripts/debian/byhand-tag b/scripts/debian/byhand-tag index e05fd2f3..47f628de 100755 --- a/scripts/debian/byhand-tag +++ b/scripts/debian/byhand-tag @@ -33,9 +33,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