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