]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/byhand-win32-loader
byhand-win32-loader: first argument is full path to byhand file
[dak.git] / scripts / debian / byhand-win32-loader
1 #!/bin/bash
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 WIN32_LOADER_PATH="$1"  # win32-loader_${VERSION}_${ARCH}{.exe,txt}
15 WIN32_LOADER_FILE="${WIN32_LOADER_PATH##*/}"
16 VERSION="$2"
17 ARCH="$3"
18 CHANGES="$4"    # Changes file for the upload
19
20 # Get the target suite from the Changes file
21 # NOTE: it may be better to pass this to the script as a parameter!
22 SUITE="$(grep "^Distribution:" "$CHANGES" | awk '{print $2}')"
23 case $SUITE in
24     "")
25             echo "Error: unable to determine suite from Changes file"
26         exit 1
27             ;;
28     unstable|sid)
29             : # nothing to do
30             ;;
31     *)
32             SUITE="${SUITE}-proposed-updates"
33             ;;
34 esac
35
36 case "${WIN32_LOADER_FILE}" in
37     win32-loader_*.exe|win32-loader_*.txt)
38         : # okay
39         ;;
40     *)
41         echo "Error: invalid filename for byhand-win32-loader"
42         exit 1
43         ;;
44 esac
45
46 # This must end with /
47 TARGET="${ftpdir}/tools/win32-loader/${SUITE}/"
48
49 # Prepare the target filename by removing the version and arch parts;
50 # transforms any/path/win32-loader_${VERSION}_${ARCH}.${extension} to win32-loader.${extension}
51 TARGET_FILENAME="${WIN32_LOADER_FILE%%_*}.${WIN32_LOADER_FILE##*.}"
52
53 # Check validity of the target directory
54 if [ ! -d "$TARGET" ]; then
55         mkdir -p "$TARGET"
56 fi
57
58 # Put said file into the tools directory
59 # Use --remove-destination to avoid problems with the fact that the target may
60 # be a hardlink and in that case we'd update multiple suites together
61 cp --remove-destination "$WIN32_LOADER_PATH" "${TARGET}${TARGET_FILENAME}"
62
63 # Chmod it correctly
64 chmod 0644 "${TARGET}${TARGET_FILENAME}"
65
66 exit 0