dinstall.functions 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. # -*- mode:sh -*-
  2. # If we error out this one is called, *FOLLOWED* by cleanup in common
  3. function onerror() {
  4. ERRDATE=$(date "+%Y.%m.%d-%H:%M:%S")
  5. subject="ATTENTION ATTENTION!"
  6. if [[ ${error:-false} = false ]]; then
  7. subject="${subject} (continued)"
  8. else
  9. subject="${subject} (interrupted)"
  10. fi
  11. subject="${subject} dinstall error at ${ERRDATE} in ${STAGEFILE:-} - (Be quiet, Brain, or I'll stab you with a Q-tip)"
  12. if [[ -r ${STAGEFILE:-/nonexistant}.log ]]; then
  13. cat "${STAGEFILE}.log"
  14. else
  15. echo "file ${STAGEFILE:-}.log does not exist, sorry"
  16. fi | mail -s "${subject}" -a "X-Debian: DAK" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" cron@ftp-master.debian.org
  17. }
  18. ########################################################################
  19. # the actual functions follow #
  20. ########################################################################
  21. # pushing merkels QA user, part one
  22. function qa1() {
  23. log "Telling QA user that we start dinstall"
  24. ssh -n -2 -i ~dak/.ssh/push_merkel_qa -o BatchMode=yes -o SetupTimeOut=90 -o ConnectTimeout=90 qa@qa.debian.org sleep 1
  25. }
  26. function mailingliststxt() {
  27. cd ${ftpdir}/doc
  28. log "Updating archive version of mailing-lists.txt"
  29. wget ${wgetopts} https://www.debian.org/misc/mailing-lists.txt
  30. }
  31. function pseudopackages() {
  32. cd ${scriptdir}/masterfiles
  33. log "Updating archive version of pseudo-packages"
  34. for file in maintainers description; do
  35. wget ${wgetopts} https://bugs.debian.org/pseudopackages/pseudo-packages.${file}
  36. done
  37. }
  38. # Updating various files
  39. function bugdoctxt() {
  40. log "Updating Bugs docu"
  41. cd $configdir
  42. $scriptsdir/update-bugdoctxt
  43. }
  44. # The first i18n one, syncing new descriptions
  45. function i18n1() {
  46. log "Synchronizing i18n package descriptions"
  47. # First sync their newest data
  48. cd ${scriptdir}/i18nsync
  49. rsync -rtq --safe-links --chmod=F644,D755 --delete --delete-after ddtp-sync:/does/not/matter . || true
  50. # Now check if we still know about the packages for which they created the files
  51. # is the timestamp signed by us?
  52. if gpgv --keyring /srv/ftp-master.debian.org/s3kr1t/dot-gnupg/pubring.gpg timestamp.gpg timestamp; then
  53. # now read it. As its signed by us we are sure the content is what we expect, no need
  54. # to do more here. And we only test -d a directory on it anyway.
  55. TSTAMP=$(cat timestamp)
  56. # do we have the dir still?
  57. if [[ -d ${scriptdir}/i18n/${TSTAMP} ]]; then
  58. # Lets check!
  59. if ${scriptsdir}/ddtp-i18n-check.sh . ${scriptdir}/i18n/${TSTAMP}; then
  60. # Yay, worked, lets copy around
  61. for dir in ${extimportdists}; do
  62. if [[ -d dists/${dir}/ ]]; then
  63. cd dists/${dir}/main/i18n
  64. rsync -aq --delete --delete-after --exclude by-hash --exclude Translation-en.bz2 --exclude "Translation-*.diff/" . ${ftpdir}/dists/${dir}/main/i18n/.
  65. fi
  66. cd ${scriptdir}/i18nsync
  67. done
  68. else
  69. echo "ARRRR, bad guys, wrong files, ARRR"
  70. echo "Arf, Arf, Arf, bad guys, wrong files, arf, arf, arf" | mail -a "X-Debian: DAK" -s "Don't you kids take anything. I'm watching you. I've got eye implants in the back of my head." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" debian-l10n-devel@lists.alioth.debian.org
  71. fi
  72. else
  73. echo "ARRRR, missing the timestamp ${TSTAMP} directory, not updating i18n, ARRR"
  74. echo "Arf, Arf, Arf, missing the timestamp ${TSTAMP} directory, not updating i18n, arf, arf, arf" | mail -a "X-Debian: DAK" -s "Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" debian-l10n-devel@lists.alioth.debian.org
  75. fi
  76. else
  77. echo "ARRRRRRR, could not verify our timestamp signature, ARRR. Don't mess with our files, i18n guys, ARRRRR."
  78. echo "Arf, Arf, Arf, could not verify our timestamp signature, arf. Don't mess with our files, i18n guys, arf, arf, arf" | mail -a "X-Debian: DAK" -s "You can't keep blaming yourself. Just blame yourself once, and move on." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" debian-l10n-devel@lists.alioth.debian.org
  79. fi
  80. }
  81. # Syncing AppStream/DEP-11 data
  82. function dep11() {
  83. log "Synchronizing AppStream metadata"
  84. # First sync their newest data
  85. local dep11dir="${scriptdir}/dep11"
  86. mkdir -p ${dep11dir}
  87. cd ${dep11dir}
  88. rsync -rtq --safe-links --chmod=F644,D755 --delete --delete-after dep11-sync:/does/not/matter .
  89. # Lets check!
  90. if ${scriptsdir}/dep11-basic-validate.py . ${dep11dir}/; then
  91. # Yay, worked, lets copy around
  92. for dir in ${extimportdists}; do
  93. if [[ -d ${dir}/ ]]; then
  94. for comp in main contrib non-free; do
  95. mkdir -p ${ftpdir}/dists/${dir}/${comp}/dep11
  96. cd ${dir}/${comp}
  97. rsync -rtq --delete --delete-after --exclude by-hash --exclude "./*.tmp" . ${ftpdir}/dists/${dir}/${comp}/dep11/.
  98. cd ${dep11dir}
  99. done
  100. fi
  101. done
  102. else
  103. echo "ARRRR, bad guys, wrong files, ARRR"
  104. echo "Arf, Arf, Arf, bad guys, wrong files, arf, arf, arf" | mail -a "X-Debian: DAK" -s "Don't you kids take anything. I'm watching you. I've got eye implants in the back of my head." -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" mak@debian.org
  105. fi
  106. }
  107. function cruft() {
  108. log "Checking for cruft in overrides"
  109. dak check-overrides
  110. }
  111. function dominate() {
  112. log "Removing obsolete source and binary associations"
  113. dak dominate
  114. dak manage-debug-suites unstable-debug experimental-debug
  115. }
  116. function autocruft() {
  117. log "Check for obsolete binary packages"
  118. dak auto-decruft -s unstable
  119. dak auto-decruft -s experimental --if-newer-version-in unstable --if-newer-version-in-rm-msg "NVIU"
  120. dak auto-decruft -s testing-proposed-updates --if-newer-version-in testing --if-newer-version-in-rm-msg "NVIT" --decruft-equal-versions
  121. }
  122. function overrides() {
  123. log "Writing overrides into text files"
  124. cd $overridedir
  125. dak make-overrides
  126. }
  127. function mpfm() {
  128. local archiveroot
  129. log "Generating package / file mapping"
  130. for archive in "${public_archives[@]}"; do
  131. log " archive: ${archive}"
  132. archiveroot="$(get_archiveroot "${archive}")"
  133. dak make-pkg-file-mapping "${archive}" | bzip2 -9 > "${archiveroot}/indices/package-file.map.bz2"
  134. done
  135. }
  136. function packages() {
  137. log " Generating Packages/Sources for: ${public_archives[*]}"
  138. dak generate-packages-sources2 -a "${public_archives[*]}"
  139. log " Generating Contents for: ${public_archives[*]}"
  140. dak contents generate -a "${public_archives[*]}"
  141. }
  142. function pdiff() {
  143. log "Generating pdiff files"
  144. dak generate-index-diffs
  145. }
  146. function release() {
  147. log "Generating Release files"
  148. dak generate-releases -a "${public_archives[*]}"
  149. }
  150. function dedup() {
  151. log "Dedupe archive"
  152. dak archive-dedup-pool
  153. for archive in "${public_archives[@]}"; do
  154. archiveroot="$(get_archiveroot "${archive}")"
  155. cd "${archiveroot}"
  156. for dir in doc indices project tools; do
  157. if [[ -d ${dir} ]]; then
  158. jdupes --hardlink --noempty --quiet --summarize --recurse ${dir}
  159. fi
  160. done
  161. done
  162. }
  163. function mkmaintainers() {
  164. local archiveroot
  165. local mkmindices
  166. log 'Creating Maintainers index ... '
  167. for archive in "${public_archives[@]}"; do
  168. archiveroot="$(get_archiveroot "${archive}")"
  169. mkmindices="${archiveroot}/indices"
  170. if ! [[ -d ${mkmindices} ]]; then
  171. mkdir "${mkmindices}"
  172. fi
  173. cd "${mkmindices}"
  174. rm -f Maintainers Maintainers.gz Uploaders Uploaders.gz
  175. dak make-maintainers -a "${archive}" ${scriptdir}/masterfiles/pseudo-packages.maintainers
  176. gzip -9v --rsyncable --no-name <Maintainers >Maintainers.gz
  177. gzip -9v --rsyncable --no-name <Uploaders >Uploaders.gz
  178. done
  179. }
  180. function copyoverrides() {
  181. log 'Copying override files into public view ...'
  182. (
  183. shopt -s nullglob
  184. rm -f ${indices}/override.*.gz
  185. for ofile in ${overridedir}/override.{wheezy,jessie,stretch,buster,sid}.{,extra.}{main,contrib,non-free}*; do
  186. bname=${ofile##*/}
  187. gzip -9cv --rsyncable --no-name ${ofile} > ${indices}/${bname}.gz
  188. chmod g+w ${indices}/${bname}.gz
  189. done
  190. )
  191. }
  192. function mkfilesindices() {
  193. set +o pipefail
  194. umask 002
  195. rm -f $base/ftp/indices/files/*.files
  196. rm -f $base/ftp/indices/files/components/*.list.gz
  197. cd $base/ftp/indices/files/components
  198. ARCHLIST=$(tempfile)
  199. log "Querying postgres"
  200. local query="
  201. SELECT './pool/' || c.name || '/' || f.filename AS path, a.arch_string AS arch_string
  202. FROM files f
  203. JOIN files_archive_map af ON f.id = af.file_id
  204. JOIN component c ON af.component_id = c.id
  205. JOIN archive ON af.archive_id = archive.id
  206. LEFT OUTER JOIN
  207. (binaries b
  208. JOIN architecture a ON b.architecture = a.id)
  209. ON f.id = b.file
  210. WHERE archive.name = 'ftp-master'
  211. ORDER BY path, arch_string
  212. "
  213. psql -At -c "$query" >$ARCHLIST
  214. includedirs () {
  215. perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
  216. }
  217. poolfirst () {
  218. perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
  219. }
  220. log "Generating sources list"
  221. (
  222. sed -n 's/|$//p' $ARCHLIST
  223. cd $base/ftp
  224. find ./dists -maxdepth 1 \! -type d
  225. find ./dists \! -type d | grep "/source/"
  226. ) | sort -u | gzip -9 > source.list.gz
  227. log "Generating arch lists"
  228. ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u)
  229. for a in $ARCHES; do
  230. (sed -n "s/|$a$//p" $ARCHLIST
  231. sed -n 's/|all$//p' $ARCHLIST
  232. cd $base/ftp
  233. find ./dists -maxdepth 1 \! -type d
  234. find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
  235. ) | sort -u | gzip -9 > arch-$a.list.gz
  236. done
  237. log "Generating suite lists"
  238. suite_list () {
  239. local suite_id="$(printf %d $1)"
  240. local query
  241. query="
  242. SELECT DISTINCT './pool/' || c.name || '/' || f.filename
  243. FROM
  244. (SELECT sa.source AS source
  245. FROM src_associations sa
  246. WHERE sa.suite = $suite_id
  247. UNION
  248. SELECT esr.src_id
  249. FROM extra_src_references esr
  250. JOIN bin_associations ba ON esr.bin_id = ba.bin
  251. WHERE ba.suite = $suite_id
  252. UNION
  253. SELECT b.source AS source
  254. FROM bin_associations ba
  255. JOIN binaries b ON ba.bin = b.id WHERE ba.suite = $suite_id) s
  256. JOIN dsc_files df ON s.source = df.source
  257. JOIN files f ON df.file = f.id
  258. JOIN files_archive_map af ON f.id = af.file_id
  259. JOIN component c ON af.component_id = c.id
  260. JOIN archive ON af.archive_id = archive.id
  261. WHERE archive.name = 'ftp-master'
  262. "
  263. psql -F' ' -A -t -c "$query"
  264. query="
  265. SELECT './pool/' || c.name || '/' || f.filename
  266. FROM bin_associations ba
  267. JOIN binaries b ON ba.bin = b.id
  268. JOIN files f ON b.file = f.id
  269. JOIN files_archive_map af ON f.id = af.file_id
  270. JOIN component c ON af.component_id = c.id
  271. JOIN archive ON af.archive_id = archive.id
  272. WHERE ba.suite = $suite_id AND archive.name = 'ftp-master'
  273. "
  274. psql -F' ' -A -t -c "$query"
  275. }
  276. psql -F' ' -At -c "SELECT id, suite_name FROM suite" |
  277. while read id suite; do
  278. [[ -e $base/ftp/dists/$suite ]] || continue
  279. (
  280. (cd $base/ftp
  281. distname=$(cd dists; readlink $suite || echo $suite)
  282. find ./dists/$distname \! -type d
  283. for distdir in ./dists/*; do
  284. [[ $(readlink $distdir) != $distname ]] || echo $distdir
  285. done
  286. )
  287. suite_list $id
  288. ) | sort -u | gzip -9 > suite-${suite}.list.gz
  289. done
  290. log "Finding everything on the ftp site to generate sundries"
  291. (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST
  292. rm -f sundries.list
  293. zcat *.list.gz | cat - *.list | sort -u |
  294. diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list
  295. log "Generating files list"
  296. for a in $ARCHES; do
  297. (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) |
  298. cat - sundries.list dists.list project.list docs.list indices.list |
  299. sort -u | poolfirst > ../arch-$a.files
  300. done
  301. (cd $base/ftp/
  302. for dist in sid jessie stretch buster; do
  303. find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip -9 > $base/ftp/indices/files/components/translation-$dist.list.gz
  304. done
  305. )
  306. (cat ../arch-i386.files ../arch-amd64.files; zcat suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-jessie.list.gz ; zcat translation-stretch.list.gz ; zcat translation-buster.list.gz) |
  307. sort -u | poolfirst > ../typical.files
  308. rm -f $ARCHLIST
  309. log "Done!"
  310. set -o pipefail
  311. }
  312. function mkchecksums() {
  313. local archiveroot dsynclist md5list
  314. for archive in "${public_archives[@]}"; do
  315. archiveroot="$(get_archiveroot "${archive}")"
  316. dsynclist=$dbdir/dsync.${archive}.list
  317. md5list=${archiveroot}/indices/md5sums
  318. log -n "Creating md5 / dsync index file for ${archive}... "
  319. cd "$archiveroot"
  320. ${bindir}/dsync-flist -q generate $dsynclist --exclude $dsynclist --md5
  321. ${bindir}/dsync-flist -q md5sums $dsynclist | gzip -9n > ${md5list}.gz
  322. done
  323. }
  324. function mirror() {
  325. local archiveroot targetpath
  326. local -a tracepaths
  327. for archive in "${public_archives[@]}"; do
  328. archiveroot="$(get_archiveroot "${archive}")"
  329. targetpath="${mirrordir}/${archive}"
  330. log "Regenerating \"public\" mirror/${archive} hardlink fun"
  331. rsync -aH --link-dest ${archiveroot} \
  332. --delete --delete-after --delete-excluded \
  333. --exclude "Packages.*.new" --exclude "Sources.*.new" \
  334. --filter 'exclude /project/trace/*' \
  335. --filter 'protect /project/' \
  336. --filter 'protect /project/trace/' \
  337. --filter 'protect /project/trace/*' \
  338. --ignore-errors \
  339. ${archiveroot}/. ${targetpath}/.
  340. tracepaths+=("${targetpath}")
  341. done
  342. write_project_trace "${tracepaths[@]}"
  343. }
  344. function expire() {
  345. log "Expiring old database dumps..."
  346. cd ${base}/backup
  347. ${scriptsdir}/expire_dumps -d . -p -f "dump_*"
  348. }
  349. function transitionsclean() {
  350. log "Removing out of date transitions..."
  351. cd ${base}
  352. dak transitions -c -a
  353. }
  354. function dm() {
  355. log "Updating DM permissions page"
  356. dak acl export-per-source dm >${exportdir}/dm.txt
  357. }
  358. function bts() {
  359. log "Categorizing uncategorized bugs filed against ftp.debian.org"
  360. sudo -u dak-unpriv dak bts-categorize
  361. }
  362. function mirrorpush() {
  363. log "Checking the public archive copies..."
  364. local archiveroot targetpath
  365. for archive in "${public_archives[@]}"; do
  366. log "... archive: ${archive}"
  367. archiveroot="$(get_archiveroot "${archive}")"
  368. targetpath="${mirrordir}/${archive}"
  369. cd ${archiveroot}/dists
  370. broken=0
  371. for release in $(find . -name "InRelease"); do
  372. echo "Processing: ${release}"
  373. subdir=${release%/InRelease}
  374. while read SHASUM SIZE NAME; do
  375. if ! [[ -f ${subdir}/${NAME} ]]; then
  376. bname=$(basename ${NAME})
  377. if [[ "${bname}" =~ ^(Packages|Sources|Contents-[a-zA-Z0-9-]+|Translation-[a-zA-Z_]+|Components-[a-zA-Z0-9-]+\.yml|icons-(128x128|64x64)\.tar)$ ]]; then
  378. # We don't keep unpacked files, don't check for their existance.
  379. # We might want to go and check their unpacked shasum, but right now
  380. # I don't care. I believe it should be enough if all the packed shasums
  381. # match.
  382. continue
  383. fi
  384. broken=$(( broken + 1 ))
  385. echo "File ${subdir}/${NAME} is missing"
  386. continue
  387. fi
  388. # We do have symlinks in the tree (see the contents files currently).
  389. # So we use "readlink -f" to check the size of the target, as thats basically
  390. # what gen-releases does
  391. fsize=$(stat -c %s $(readlink -f "${subdir}/${NAME}"))
  392. if [[ ${fsize} -ne ${SIZE} ]]; then
  393. broken=$(( broken + 1 ))
  394. echo "File ${subdir}/${NAME} has size ${fsize}, expected is ${SIZE}"
  395. continue
  396. fi
  397. fshasum=$(sha1sum $(readlink -f "${subdir}/${NAME}"))
  398. fshasum=${fshasum%% *}
  399. if [[ ${fshasum} != ${SHASUM} ]]; then
  400. broken=$(( broken + 1 ))
  401. echo "File ${subdir}/${NAME} has checksum ${fshasum}, expected is ${SHASUM}"
  402. continue
  403. fi
  404. done < <(sed '1,/SHA1:/d' "${release}" | sed '/SHA256:/,$d')
  405. done
  406. if [[ $broken -gt 0 ]]; then
  407. log_error "Trouble with the public mirror for ${archive}, found ${broken} errors"
  408. continue
  409. else
  410. log "Starting the mirrorpush for ${archive}"
  411. case ${archive} in
  412. ftp-master)
  413. fname="mirrorstart"
  414. pusharg=""
  415. pname="debian"
  416. ;;
  417. security)
  418. fname="mirrorstart"
  419. pusharg="-a security"
  420. pname="debian-security"
  421. ;;
  422. debian-debug)
  423. pusharg="-a debug"
  424. ;;&
  425. debian-security-debug)
  426. pusharg="-a security-debug"
  427. ;;&
  428. backports)
  429. pusharg="-a backports"
  430. ;;&
  431. *)
  432. fname="mirrorstart.${archive}"
  433. pname=${archive}
  434. ;;
  435. esac
  436. mkdir -p ${webdir}/${pname}/project/trace/
  437. ln -sf ${mirrordir}/${archive}/project/trace/master ${webdir}/${pname}/project/trace/master
  438. ln -sf ${mirrordir}/${archive}/project/trace/master ${webdir}/${pname}/project/trace/ftp-master.debian.org
  439. date -u > ${webdir}/${fname}
  440. echo "Using dak v1" >> ${webdir}/${fname}
  441. echo "Running on host $(hostname -f)" >> ${webdir}/${fname}
  442. sudo -u archvsync runmirrors ${pusharg} > ~dak/runmirrors-${archive}.log 2>&1 &
  443. fi
  444. done
  445. }
  446. function mirrorpush-backports() {
  447. log "Syncing backports mirror"
  448. sudo -u backports /home/backports/bin/update-archive
  449. }
  450. function mirrorpush-release() {
  451. log "Pushing cdbuilder host"
  452. sudo -u archvsync runmirrors -a release > ~dak/runmirrors-release.log 2>&1 &
  453. }
  454. function i18n2() {
  455. log "Exporting package data foo for i18n project"
  456. STAMP=$(date "+%Y%m%d%H%M")
  457. mkdir -p ${scriptdir}/i18n/${STAMP}
  458. cd ${scriptdir}/i18n/${STAMP}
  459. for suite in stable testing unstable; do
  460. codename=$(dak admin s show ${suite}|grep '^Codename')
  461. codename=${codename##* }
  462. echo "Codename is ${codename}"
  463. dak control-suite -l ${suite} >${codename}
  464. done
  465. echo "${STAMP}" > timestamp
  466. gpg --homedir /srv/ftp-master.debian.org/s3kr1t/dot-gnupg --no-options --batch --no-tty --armour --default-key 473041FA --detach-sign -o timestamp.gpg timestamp
  467. rm -f md5sum
  468. md5sum * > md5sum
  469. cd ${webdir}/
  470. ln -sfT ${scriptdir}/i18n/${STAMP} i18n
  471. cd ${scriptdir}
  472. find ./i18n -mindepth 1 -maxdepth 1 -mtime +2 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
  473. }
  474. function stats() {
  475. log "Updating stats data"
  476. cd ${configdir}
  477. #${scriptsdir}/update-ftpstats ${base}/log/* > ${base}/misc/ftpstats.data
  478. #R --slave --vanilla < ${base}/misc/ftpstats.R
  479. dak stats arch-space > ${webdir}/arch-space
  480. dak stats pkg-nums > ${webdir}/pkg-nums
  481. }
  482. function cleantransactions() {
  483. log "Cleanup transaction ids older than 3 months"
  484. cd ${base}/backup/
  485. find -maxdepth 1 -mindepth 1 -type f -name 'txid_*' -mtime +90 -delete
  486. }
  487. function logstats() {
  488. if [ "${functionname}" = ftp-master.debian.org ]; then
  489. cd ${TMPDIR}
  490. ${masterdir}/tools/logs.py "$1"
  491. fi
  492. }
  493. # save timestamp when we start
  494. function savetimestamp() {
  495. echo ${NOW} > "${dbdir}/dinstallstart"
  496. }
  497. function maillogfile() {
  498. mail -a "X-Debian: DAK" -s "Log for dinstall run of ${NOW}" -a "From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>" cron@ftp-master.debian.org < "${LOGFILE}"
  499. }
  500. function testingsourcelist() {
  501. dak ls -s testing -f heidi -r .| egrep 'source$' > ${webdir}/testing.list
  502. }
  503. # Function to update a "statefile" telling people what we are doing
  504. # (more or less).
  505. #
  506. # This should be called with the argument(s)
  507. # - Status name we want to show.
  508. #
  509. function state() {
  510. RIGHTNOW="$(date -u +"%a %b %d %T %Z %Y (%s)")"
  511. cat >"${DINSTALLSTATE}" <<EOF
  512. Dinstall start: ${DINSTALLBEGIN}
  513. Current action: $*
  514. Action start: ${RIGHTNOW}
  515. EOF
  516. }
  517. # extract changelogs and stuff
  518. function changelogs() {
  519. log "Extracting changelogs"
  520. dak make-changelog -e -a ftp-master
  521. [[ -f ${exportdir}/changelogs/filelist.yaml ]] && xz -f ${exportdir}/changelogs/filelist.yaml
  522. mkdir -p ${exportpublic}/changelogs
  523. cd ${exportpublic}/changelogs
  524. rsync -aHW --delete --delete-after --ignore-errors ${exportdir}/changelogs/. .
  525. sudo -H -u staticsync /usr/local/bin/static-update-component metadata.ftp-master.debian.org >/dev/null 2>&1 &
  526. # dak make-changelog -e -a backports
  527. # [[ -f /srv/backports-master.debian.org/export/changelogs/filelist.yaml ]] && xz -f /srv/backports-master.debian.org/export/changelogs/filelist.yaml
  528. # mkdir -p /srv/backports-master.debian.org/rsync/export/changelogs
  529. # cd /srv/backports-master.debian.org/rsync/export/changelogs
  530. # rsync -aHW --delete --delete-after --ignore-errors /srv/backports-master.debian.org/export/changelogs/. .
  531. }
  532. # Generate a list of extra mirror files, sha256sum em and sign that
  533. function signotherfiles() {
  534. log "Signing extra mirror files"
  535. local archiveroot
  536. for archive in "${public_archives[@]}"; do
  537. log "... archive: ${archive}"
  538. archiveroot="$(get_archiveroot "${archive}")"
  539. local TMPLO=$( gettempfile )
  540. cd ${archiveroot}
  541. rm -f extrafiles
  542. sha256sum $(find * -type f | egrep -v '(pool|i18n|dep11|source)/|Contents-.*\.(gz|diff)|installer|binary-|(In)?Release(.gpg)?|\.changes' | sort) > ${TMPLO}
  543. gpg --no-options --batch --no-tty --armour --personal-digest-preferences=SHA256 --homedir /srv/ftp-master.debian.org/s3kr1t/dot-gnupg --no-options --batch --no-tty --armour --default-key 2B90D010 --clearsign --output ${archiveroot}/extrafiles ${TMPLO}
  544. rm -f ${TMPLO}
  545. done
  546. }
  547. function startup() {
  548. touch "${DINSTALLSTART}"
  549. log_timestamp "startup"
  550. trap onerror ERR
  551. }
  552. function postcronscript() {
  553. trap - ERR
  554. logstats ${LOGFILE}
  555. touch "${DINSTALLEND}"
  556. }