byhand-ftpsync 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #! /bin/bash
  2. #
  3. # byhand-ftpsync - automatic BYHAND handling for ftpsync
  4. #
  5. # This file is part of dak.
  6. #
  7. # Copyright 2017, Joerg Jaspert <joerg@debian.org>
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License along
  19. # with this program; if not, write to the Free Software Foundation, Inc.,
  20. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. set -e
  22. set -u
  23. export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
  24. . ${SCRIPTVARS}
  25. scriptname=byhand-ftpsync
  26. if [ $# -lt 5 ]; then
  27. echo "usage: ${scriptname} <byhand-file> <version> <arch> <changes-file> <suite>" >&2
  28. exit 1
  29. fi
  30. byhand_path="${1}"
  31. byhand_file="${byhand_path##*/}"
  32. version="${2}"
  33. architecture="${3}"
  34. changes="${4}"
  35. suite="${5}"
  36. GNUPGHOME="${base}/s3kr1t/dot-gnupg"
  37. case "${suite}" in
  38. unstable|sid)
  39. : # okay
  40. ;;
  41. *)
  42. echo "$0: not targeted at unstable" >&2
  43. exit 1
  44. ;;
  45. esac
  46. error() {
  47. echo "$0:" "$@" >&2
  48. exit 1
  49. }
  50. # Check validity of version number
  51. # Expected: YYYYMMDD
  52. if ! echo "$version" | grep -Eq "^[0-9]{8}$"; then
  53. error "Invalid version: '$version"
  54. fi
  55. if [[ ! "${byhand_file}" =~ ^ftpsync_[0-9]{8}_all.tar.gz$ ]]; then
  56. error "unknown file '${byhand_file}'"
  57. fi
  58. target="${ftpdir}/project/ftpsync/"
  59. if [ ! -d "${target}" ]; then
  60. mkdir -p "${target}"
  61. fi
  62. target_filename="ftpsync-$version.tar.gz"
  63. target_file="${target}/${target_filename}"
  64. # Use --remove-destination to avoid problems with the fact that the target may
  65. # be a hardlink and in that case we'd update multiple suites together
  66. cp --remove-destination "${byhand_path}" "${target_file}"
  67. cd ${target}
  68. chmod 0644 "${target_file}"
  69. ln -sf "${target_filename}" ftpsync-current.tar.gz
  70. echo ${version} > LATEST.VERSION
  71. for csum in md5sum sha512sum; do
  72. /usr/bin/${csum} * | grep -v 'sum' > ${csum}
  73. SIGNINGKEY=2B90D010
  74. GNUPGHOME=${GNUPGHOME} gpg --no-options --batch --no-tty --armour --default-key ${SIGNINGKEY} --clearsign -o "${target}/${csum}.txt" "${target}/${csum}"
  75. mv "${target}/${csum}.txt" "${target}/${csum}"
  76. done