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