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