cron.unchecked 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. # No way I try to deal with a crippled sh just for POSIX foo.
  3. # Copyright (C) 2009 Joerg Jaspert <joerg@debian.org>
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; version 2.
  8. #
  9. # This program is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. # exit on errors
  18. set -e
  19. set -o pipefail
  20. # make sure to only use defined variables
  21. set -u
  22. # ERR traps should be inherited from functions too. (And command
  23. # substitutions and subshells and whatnot, but for us the functions is
  24. # the important part here)
  25. set -E
  26. # import the general variable set.
  27. export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
  28. . $SCRIPTVARS
  29. LOCKDAILY=""
  30. LOCKFILE="$lockdir/unchecked.lock"
  31. NOTICE="$lockdir/daily.lock"
  32. LOCK_BUILDD="$lockdir/buildd.lock"
  33. # our name
  34. PROGRAM="unchecked"
  35. if [ -e $NOTICE ]; then
  36. exit 0;
  37. fi
  38. ########################################################################
  39. # Functions #
  40. ########################################################################
  41. # common functions are "outsourced"
  42. . "${configdir}/common"
  43. STAMP=$(date "+%Y%m%d%H%M")
  44. cleanup() {
  45. rm -f "$LOCKFILE"
  46. if [ ! -z "$LOCKDAILY" ]; then
  47. rm -f "$NOTICE"
  48. fi
  49. }
  50. function do_buildd () {
  51. if lockfile -r3 $NOTICE; then
  52. LOCKDAILY="YES"
  53. make_buildd_dir
  54. wbtrigger
  55. fi
  56. }
  57. ########################################################################
  58. # the actual unchecked functions follow #
  59. ########################################################################
  60. # And use one locale, no matter what the caller has set
  61. export LANG=C
  62. export LC_ALL=C
  63. # only run one cron.unchecked
  64. if ! lockfile -r8 $LOCKFILE 2> /dev/null; then
  65. # echo "aborting cron.unchecked because $LOCKFILE has already been locked"
  66. exit 0
  67. fi
  68. trap cleanup 0
  69. pg_timestamp preunchecked >/dev/null
  70. # Process policy queues
  71. punew stable-new
  72. opunew oldstable-new
  73. backports_policy
  74. dak clean-suites -a backports-policy,policy
  75. # Finally deal with unchecked
  76. do_unchecked
  77. if [ ! -z "$changes" ]; then
  78. sync_debbugs
  79. do_buildd
  80. fi
  81. dak contents -l 10000 scan-binary
  82. dak contents -l 1000 scan-source
  83. pg_timestamp postunchecked >/dev/null