]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/byhand-task
Merged a patch from Frans Pop making byhand-task fail on uploads to anything other...
[dak.git] / scripts / debian / byhand-task
1 #!/bin/sh -ue
2
3 if [ $# -lt 4 ]; then
4         echo "Usage: $0 filename version arch changes_file"
5         exit 1
6 fi
7
8 INPUT="$1"      # Tarball to read, compressed with gzip
9 VERSION="$2"
10 ARCH="$3"
11 CHANGES="$4"    # Changes file for the upload
12
13 error() {
14         echo "$*"
15         exit 1
16 }
17
18 # Get the target suite from the Changes file
19 # NOTE: it may be better to pass this to the script as a parameter!
20 SUITE="$(grep "^Distribution:" "$CHANGES" | awk '{print $2}')"
21 case $SUITE in
22     "")
23         error "Error: unable to determine suite from Changes file"
24         ;;
25     unstable|sid)
26         : # OK for automated byband processing
27         ;;
28     *)
29         error "Reject: task overrides can only be processed automatically for uploads to unstable"
30         ;;
31 esac
32
33
34 # Regular expression used to validate tag lines
35 CHECKRE='^[a-z0-9A-Z.+-]+[[:space:]]+Task[[:space:]]+[a-z0-9:. ,{}+-]+$'
36
37 # This must end with /
38 TARGET=/srv/ftp.debian.org/scripts/external-overrides/
39
40 # Read the main directory from the tarball
41 DIR="`tar ztf \"$INPUT\" | tac | tail -n 1`"
42
43 # Create temporary files where to store the validated data
44 umask 002
45 OUTMAIN="`mktemp \"$TARGET\"task.new.XXXXXX`"
46
47 # If we fail somewhere, cleanup the temporary files
48 cleanup() {
49         rm -f "$OUTMAIN"
50 }
51 trap cleanup EXIT
52
53 # Extract the data into the temporary files
54 tar -O -zxf "$INPUT" "$DIR"task | grep -E "$CHECKRE" > "$OUTMAIN"
55
56 # Move the data to the final location
57 mv "$OUTMAIN"           "$TARGET"task
58
59 chmod 644 "$TARGET"task
60
61 (cd $TARGET && ./mk-extra-overrides.sh)
62
63 trap - EXIT
64
65 exit 0