]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/byhand-tag
Merge commit 'godog/master' into merge
[dak.git] / scripts / debian / byhand-tag
1 #!/bin/sh -ue
2
3 # Tarball to read, compressed with gzip
4 INPUT="${1:?"Usage: $0 filename"}"
5
6 # Regular expression used to validate tag lines
7 CHECKRE='^[a-z0-9A-Z.+-]+[[:space:]]+Tag[[:space:]]+[a-z0-9:. ,{}+-]+$'
8
9 # This must end with /
10 TARGET=/srv/ftp.debian.org/scripts/external-overrides/
11
12 # Read the main directory from the tarball
13 DIR="`tar ztf \"$INPUT\" | tac | tail -n 1`"
14
15 # Create temporary files where to store the validated data
16 umask 002
17 OUTMAIN="`mktemp \"$TARGET\"tag.new.XXXXXX`"
18 OUTCONTRIB="`mktemp \"$TARGET\"tag.contrib.new.XXXXXX`"
19 OUTNONFREE="`mktemp \"$TARGET\"tag.non-free.new.XXXXXX`"
20
21 # If we fail somewhere, cleanup the temporary files
22 cleanup() {
23         rm -f "$OUTMAIN"
24         rm -f "$OUTCONTRIB"
25         rm -f "$OUTNONFREE"
26 }
27 trap cleanup EXIT
28
29 # Extract the data into the temporary files
30 tar -O -zxf "$INPUT" "$DIR"tag | grep -E "$CHECKRE" > "$OUTMAIN"
31 tar -O -zxf "$INPUT" "$DIR"tag.contrib | grep -E "$CHECKRE" > "$OUTCONTRIB"
32 tar -O -zxf "$INPUT" "$DIR"tag.non-free | grep -E "$CHECKRE" > "$OUTNONFREE"
33
34 # Move the data to the final location
35 mv "$OUTMAIN"           "$TARGET"tag
36 mv "$OUTCONTRIB"        "$TARGET"tag.contrib
37 mv "$OUTNONFREE"        "$TARGET"tag.non-free
38
39 chmod 644 "$TARGET"tag "$TARGET"tag.contrib "$TARGET"tag.non-free
40
41 (cd $TARGET && ./mk-extra-overrides.sh)
42
43 trap - EXIT
44
45 exit 0