byhand-task 1.5 KB

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