import_dataset.sh 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. # Copyright (C) 2008,2010 Joerg Jaspert <joerg@debian.org>
  3. # Permission is hereby granted, free of charge, to any person obtaining
  4. # a copy of this software and associated documentation files (the
  5. # "Software"), to deal in the Software without restriction, including
  6. # without limitation the rights to use, copy, modify, merge, publish,
  7. # distribute, sublicense, and/or sell copies of the Software, and to
  8. # permit persons to whom the Software is furnished to do so, subject to
  9. # the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be
  12. # included in all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. set -e
  22. set -u
  23. # Load up some standard variables
  24. export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
  25. . $SCRIPTVARS
  26. # This script can be called as `import_dataset.sh --from-ssh-command`.
  27. # In this case SSH_ORIGINAL_COMMAND is expected to be of the form
  28. # import_dataset.sh <suite> <md5sum>
  29. if [ "${1}" = "--from-ssh-command" ]; then
  30. set -- ${SSH_ORIGINAL_COMMAND}
  31. if [ $1 != "import_dataset.sh" ]; then
  32. echo >&2 "E: expect to be called as 'import_dataset.sh <suite> <md5sum>'"
  33. exit 1
  34. fi
  35. shift
  36. if [ $# -ne 2 ]; then
  37. echo >&2 "E: expect exacly two arguments (suite, md5sum)"
  38. exit 1
  39. fi
  40. SSH_ORIGINAL_COMMAND="${2}"
  41. fi
  42. IMPORTSUITE=${1:-"testing"}
  43. BRITNEY=""
  44. MD5SUM="${SSH_ORIGINAL_COMMAND}"
  45. case "${IMPORTSUITE}" in
  46. testing)
  47. DO_CHANGELOG="true"
  48. ;;
  49. testing-debug|testing-proposed-updates|stretch-updates|buster-updates|bullseye-updates)
  50. DO_CHANGELOG="false"
  51. ;;
  52. *)
  53. echo "You are so wrong here that I can't even believe it. Sod off."
  54. exit 42
  55. ;;
  56. esac
  57. # Change to a known safe location
  58. cd $masterdir
  59. echo "Importing new data for ${IMPORTSUITE} into database"
  60. if [ "x${DO_CHANGELOG}x" = "xtruex" ]; then
  61. rm -f ${ftpdir}/dists/${IMPORTSUITE}/ChangeLog
  62. BRITNEY=" --britney"
  63. fi
  64. tmpfile=$(mktemp)
  65. trap "rm -f ${tmpfile}" EXIT
  66. cat > ${tmpfile}
  67. if ! echo "${MD5SUM} ${tmpfile}" | md5sum -c --quiet; then
  68. exit 42
  69. fi
  70. dak control-suite --set ${IMPORTSUITE} ${BRITNEY} < ${tmpfile}
  71. if [ "x${DO_CHANGELOG}x" = "xtruex" ]; then
  72. NOW=$(date "+%Y%m%d%H%M")
  73. cd ${ftpdir}/dists/${IMPORTSUITE}/
  74. mv ChangeLog ChangeLog.${NOW}
  75. ln -s ChangeLog.${NOW} ChangeLog
  76. find . -maxdepth 1 -mindepth 1 -type f -mmin +2880 -name 'ChangeLog.*' -delete
  77. fi
  78. #echo "Regenerating Packages/Sources files, be patient"
  79. #dak generate-packages-sources2 -s ${IMPORTSUITE} >/dev/null
  80. echo "Done"
  81. exit 0