]> git.decadent.org.uk Git - dak.git/blobdiff - scripts/debian/byhand-tag
byhand-tag: abort on invalid data
[dak.git] / scripts / debian / byhand-tag
index e05fd2f3b574d58003b579140359873b0c0c77ec..47f628de6e2ee74d94658f7f6c67a03053176831 100755 (executable)
@@ -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