byhand-win32-loader 1.7 KB

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