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