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