dinstall.functions 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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.*" --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 non-free-firmware; do
  95. if ! [[ -d ${dir}/${comp} ]]; then
  96. continue
  97. fi
  98. mkdir -p ${ftpdir}/dists/${dir}/${comp}/dep11
  99. cd ${dir}/${comp}
  100. rsync -rtq --delete --delete-after --exclude by-hash --exclude "./*.tmp" . ${ftpdir}/dists/${dir}/${comp}/dep11/.
  101. cd ${dep11dir}
  102. done
  103. fi
  104. done
  105. else
  106. echo "ARRRR, bad guys, wrong files, ARRR"
  107. 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
  108. fi
  109. }
  110. function cruft() {
  111. log "Checking for cruft in overrides"
  112. dak check-overrides
  113. }
  114. function dominate() {
  115. log "Removing obsolete source and binary associations"
  116. dak dominate
  117. dak manage-debug-suites unstable-debug experimental-debug stretch-backports-debug buster-backports-debug buster-backports-sloppy-debug bullseye-backports-debug bullseye-backports-sloppy-debug bookworm-backports-debug stable-backports-sloppy-debug testing-backports-debug testing-proposed-updates-debug
  118. }
  119. function autocruft() {
  120. log "Check for obsolete binary packages"
  121. dak auto-decruft -s unstable
  122. dak auto-decruft -s experimental --if-newer-version-in unstable --if-newer-version-in-rm-msg "NVIU"
  123. dak auto-decruft -s testing-proposed-updates --if-newer-version-in testing --if-newer-version-in-rm-msg "NVIT" --decruft-equal-versions
  124. }
  125. function overrides() {
  126. log "Writing overrides into text files"
  127. cd $overridedir
  128. dak make-overrides
  129. }
  130. function mpfm() {
  131. local archiveroot
  132. log "Generating package / file mapping"
  133. for archive in "${public_archives[@]}"; do
  134. log " archive: ${archive}"
  135. archiveroot="$(get_archiveroot "${archive}")"
  136. dak make-pkg-file-mapping "${archive}" | bzip2 -9 > "${archiveroot}/indices/package-file.map.bz2"
  137. done
  138. }
  139. function packages() {
  140. log " Generating Packages/Sources for: ${public_archives[*]}"
  141. dak generate-packages-sources2 -a "${public_archives[*]}"
  142. log " Generating Contents for: ${public_archives[*]}"
  143. dak contents generate -a "${public_archives[*]}"
  144. }
  145. function pdiff() {
  146. log "Generating pdiff files"
  147. dak generate-index-diffs
  148. }
  149. function release() {
  150. log "Generating Release files"
  151. dak generate-releases -a "${public_archives[*]}"
  152. }
  153. function dedup() {
  154. log "Dedupe archive"
  155. dak archive-dedup-pool
  156. for archive in "${public_archives[@]}"; do
  157. archiveroot="$(get_archiveroot "${archive}")"
  158. cd "${archiveroot}"
  159. for dir in doc indices project tools; do
  160. if [[ -d ${dir} ]]; then
  161. jdupes --hardlink --noempty --quiet --linkhard --recurse ${dir}
  162. fi
  163. done
  164. done
  165. }
  166. function mkmaintainers() {
  167. local archiveroot
  168. local mkmindices
  169. log 'Creating Maintainers index ... '
  170. for archive in "${public_archives[@]}"; do
  171. archiveroot="$(get_archiveroot "${archive}")"
  172. mkmindices="${archiveroot}/indices"
  173. if ! [[ -d ${mkmindices} ]]; then
  174. mkdir "${mkmindices}"
  175. fi
  176. cd "${mkmindices}"
  177. rm -f Maintainers Maintainers.gz Uploaders Uploaders.gz
  178. dak make-maintainers -a "${archive}" ${scriptdir}/masterfiles/pseudo-packages.maintainers
  179. gzip -9v --rsyncable --no-name <Maintainers >Maintainers.gz
  180. gzip -9v --rsyncable --no-name <Uploaders >Uploaders.gz
  181. done
  182. }
  183. function copyoverrides() {
  184. log 'Copying override files into public view ...'
  185. (
  186. shopt -s nullglob
  187. rm -f ${indices}/override.*.gz
  188. TESTING=$(dak admin suite-config get-value testing codename)
  189. STABLE=$(dak admin suite-config get-value stable codename)
  190. OLDSTABLE=$(dak admin suite-config get-value oldstable codename)
  191. OLDOLDSTABLE=$(dak admin suite-config get-value oldoldstable codename)
  192. for ofile in ${overridedir}/override.{$OLDOLDSTABLE,$OLDSTABLE,$STABLE,$TESTING,sid}.{,extra.}{main,contrib,non-free}*; do
  193. bname=${ofile##*/}
  194. gzip -9cv --rsyncable --no-name ${ofile} > ${indices}/${bname}.gz
  195. chmod g+w ${indices}/${bname}.gz
  196. done
  197. )
  198. }
  199. function mkfilesindices() {
  200. set +o pipefail
  201. umask 002
  202. rm -f $base/ftp/indices/files/*.files
  203. rm -f $base/ftp/indices/files/components/*.list.gz
  204. cd $base/ftp/indices/files/components
  205. ARCHLIST=$(mktemp)
  206. log "Querying postgres"
  207. local query="
  208. SELECT './pool/' || c.name || '/' || f.filename AS path, a.arch_string AS arch_string
  209. FROM files f
  210. JOIN files_archive_map af ON f.id = af.file_id
  211. JOIN component c ON af.component_id = c.id
  212. JOIN archive ON af.archive_id = archive.id
  213. LEFT OUTER JOIN
  214. (binaries b
  215. JOIN architecture a ON b.architecture = a.id)
  216. ON f.id = b.file
  217. WHERE archive.name = 'ftp-master'
  218. ORDER BY path, arch_string
  219. "
  220. psql -At -c "$query" >$ARCHLIST
  221. includedirs () {
  222. perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
  223. }
  224. poolfirst () {
  225. perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
  226. }
  227. log "Generating sources list"
  228. (
  229. sed -n 's/|$//p' $ARCHLIST
  230. cd $base/ftp
  231. find ./dists -maxdepth 1 \! -type d
  232. find ./dists \! -type d | grep "/source/"
  233. ) | sort -u | gzip -9 --rsyncable --no-name > source.list.gz
  234. log "Generating arch lists"
  235. ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u)
  236. for a in $ARCHES; do
  237. (sed -n "s/|$a$//p" $ARCHLIST
  238. sed -n 's/|all$//p' $ARCHLIST
  239. cd $base/ftp
  240. find ./dists -maxdepth 1 \! -type d
  241. find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
  242. ) | sort -u | gzip -9 --rsyncable --no-name > arch-$a.list.gz
  243. done
  244. log "Generating suite lists"
  245. suite_list () {
  246. local suite_id="$(printf %d $1)"
  247. local query
  248. query="
  249. SELECT DISTINCT './pool/' || c.name || '/' || f.filename
  250. FROM
  251. (SELECT sa.source AS source
  252. FROM src_associations sa
  253. WHERE sa.suite = $suite_id
  254. UNION
  255. SELECT esr.src_id
  256. FROM extra_src_references esr
  257. JOIN bin_associations ba ON esr.bin_id = ba.bin
  258. WHERE ba.suite = $suite_id
  259. UNION
  260. SELECT b.source AS source
  261. FROM bin_associations ba
  262. JOIN binaries b ON ba.bin = b.id WHERE ba.suite = $suite_id) s
  263. JOIN dsc_files df ON s.source = df.source
  264. JOIN files f ON df.file = f.id
  265. JOIN files_archive_map af ON f.id = af.file_id
  266. JOIN component c ON af.component_id = c.id
  267. JOIN archive ON af.archive_id = archive.id
  268. WHERE archive.name = 'ftp-master'
  269. "
  270. psql -F' ' -A -t -c "$query"
  271. query="
  272. SELECT './pool/' || c.name || '/' || f.filename
  273. FROM bin_associations ba
  274. JOIN binaries b ON ba.bin = b.id
  275. JOIN files f ON b.file = f.id
  276. JOIN files_archive_map af ON f.id = af.file_id
  277. JOIN component c ON af.component_id = c.id
  278. JOIN archive ON af.archive_id = archive.id
  279. WHERE ba.suite = $suite_id AND archive.name = 'ftp-master'
  280. "
  281. psql -F' ' -A -t -c "$query"
  282. }
  283. psql -F' ' -At -c "SELECT id, suite_name FROM suite" |
  284. while read id suite; do
  285. [[ -e $base/ftp/dists/$suite ]] || continue
  286. (
  287. (cd $base/ftp
  288. distname=$(cd dists; readlink $suite || echo $suite)
  289. find ./dists/$distname \! -type d
  290. for distdir in ./dists/*; do
  291. [[ $(readlink $distdir) != $distname ]] || echo $distdir
  292. done
  293. )
  294. suite_list $id
  295. ) | sort -u | gzip -9 --rsyncable --no-name > suite-${suite}.list.gz
  296. done
  297. log "Finding everything on the ftp site to generate sundries"
  298. (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST
  299. rm -f sundries.list
  300. zcat *.list.gz | cat - *.list | sort -u |
  301. diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list
  302. log "Generating files list"
  303. for a in $ARCHES; do
  304. (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) |
  305. cat - sundries.list dists.list project.list docs.list indices.list |
  306. sort -u | poolfirst > ../arch-$a.files
  307. done
  308. TESTING=$(dak admin suite-config get-value testing codename)
  309. STABLE=$(dak admin suite-config get-value stable codename)
  310. OLDSTABLE=$(dak admin suite-config get-value oldstable codename)
  311. OLDOLDSTABLE=$(dak admin suite-config get-value oldoldstable codename)
  312. (cd $base/ftp/
  313. for dist in sid $OLDOLDSTABLE $OLDSTABLE $STABLE $TESTING; do
  314. find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip -9 --rsyncable --no-name > $base/ftp/indices/files/components/translation-$dist.list.gz
  315. done
  316. )
  317. (cat ../arch-i386.files ../arch-amd64.files; zcat suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-$OLDOLDSTABLE.list.gz ; zcat translation-$OLDSTABLE.list.gz ; zcat translation-$STABLE.list.gz ; zcat translation-$TESTING.list.gz) |
  318. sort -u | poolfirst > ../typical.files
  319. rm -f $ARCHLIST
  320. log "Done!"
  321. set -o pipefail
  322. }
  323. function mkchecksums() {
  324. local archiveroot dsynclist md5list
  325. for archive in "${public_archives[@]}"; do
  326. archiveroot="$(get_archiveroot "${archive}")"
  327. dsynclist=$dbdir/dsync.${archive}.list
  328. md5list=${archiveroot}/indices/md5sums
  329. log "Creating md5 / dsync index file for ${archive}... "
  330. cd "$archiveroot"
  331. # FIXME: We should get rid of md5sums, but until then, keep it running.
  332. # People actually use this file.
  333. LD_LIBRARY_PATH=${bindir}:${LD_LIBRARY_PATH:-} ${bindir}/dsync-flist -q generate $dsynclist --exclude $dsynclist --md5
  334. LD_LIBRARY_PATH=${bindir}:${LD_LIBRARY_PATH:-} ${bindir}/dsync-flist -q md5sums $dsynclist | gzip -9 --rsyncable --no-name > ${md5list}.gz
  335. done
  336. }
  337. function mirror() {
  338. local archiveroot targetpath
  339. local -a tracepaths
  340. for archive in "${public_archives[@]}"; do
  341. archiveroot="$(get_archiveroot "${archive}")"
  342. targetpath="${mirrordir}/${archive}"
  343. if [[ ! -f ${archiveroot}/../mirror-excluded-files.list ]]; then
  344. log "Mirror exclude file should exist, even if it is empty"
  345. touch ${archiveroot}/../mirror-excluded-files.list
  346. fi
  347. log "Regenerating \"public\" mirror/${archive} hardlink fun"
  348. rsync -aH --link-dest ${archiveroot} \
  349. --delete --delete-after --delete-excluded \
  350. --exclude "Packages.*.new" --exclude "Sources.*.new" \
  351. --filter 'exclude /project/trace/*' \
  352. --filter 'protect /project/' \
  353. --filter 'protect /project/trace/' \
  354. --filter 'protect /project/trace/*' \
  355. --exclude-from=${archiveroot}/../mirror-excluded-files.list \
  356. --ignore-errors \
  357. ${archiveroot}/. ${targetpath}/.
  358. tracepaths+=("${targetpath}")
  359. done
  360. write_project_trace "${tracepaths[@]}"
  361. }
  362. function transitionsclean() {
  363. log "Removing out of date transitions..."
  364. cd ${base}
  365. dak transitions -c -a
  366. }
  367. function dm() {
  368. log "Updating DM permissions page"
  369. dak acl export-per-source dm >${exportdir}/dm.txt
  370. }
  371. function bts() {
  372. log "Categorizing uncategorized bugs filed against ftp.debian.org"
  373. sudo -u dak-unpriv dak bts-categorize
  374. }
  375. function mirrorpush() {
  376. log "Checking the public archive copies..."
  377. local archiveroot targetpath
  378. for archive in "${public_archives[@]}"; do
  379. log "... archive: ${archive}"
  380. archiveroot="$(get_archiveroot "${archive}")"
  381. targetpath="${mirrordir}/${archive}"
  382. cd ${archiveroot}/dists
  383. broken=0
  384. for release in $(find . -name "InRelease"); do
  385. echo "Processing: ${release}"
  386. subdir=${release%/InRelease}
  387. while read SHASUM SIZE NAME; do
  388. if ! [[ -f ${subdir}/${NAME} ]]; then
  389. bname=$(basename ${NAME})
  390. if [[ "${bname}" =~ ^(Packages|Sources|Contents-[a-zA-Z0-9-]+|Translation-[a-zA-Z_]+|Components-[a-zA-Z0-9-]+\.yml|icons-(128x128|64x64)\.tar)$ ]]; then
  391. # We don't keep unpacked files, don't check for their existance.
  392. # We might want to go and check their unpacked shasum, but right now
  393. # I don't care. I believe it should be enough if all the packed shasums
  394. # match.
  395. continue
  396. fi
  397. broken=$(( broken + 1 ))
  398. echo "File ${subdir}/${NAME} is missing"
  399. continue
  400. fi
  401. # We do have symlinks in the tree (see the contents files currently).
  402. # So we use "readlink -f" to check the size of the target, as thats basically
  403. # what gen-releases does
  404. fsize=$(stat -c %s $(readlink -f "${subdir}/${NAME}"))
  405. if [[ ${fsize} -ne ${SIZE} ]]; then
  406. broken=$(( broken + 1 ))
  407. echo "File ${subdir}/${NAME} has size ${fsize}, expected is ${SIZE}"
  408. continue
  409. fi
  410. fshasum=$(sha1sum $(readlink -f "${subdir}/${NAME}"))
  411. fshasum=${fshasum%% *}
  412. if [[ ${fshasum} != ${SHASUM} ]]; then
  413. broken=$(( broken + 1 ))
  414. echo "File ${subdir}/${NAME} has checksum ${fshasum}, expected is ${SHASUM}"
  415. continue
  416. fi
  417. done < <(sed '1,/SHA1:/d' "${release}" | sed '/SHA256:/,$d')
  418. done
  419. if [[ $broken -gt 0 ]]; then
  420. log_error "Trouble with the public mirror for ${archive}, found ${broken} errors"
  421. continue
  422. else
  423. log "Starting the mirrorpush for ${archive}"
  424. case ${archive} in
  425. ftp-master)
  426. fname="mirrorstart"
  427. pusharg=""
  428. pname="debian"
  429. ;;
  430. security)
  431. fname="mirrorstart"
  432. pusharg="-a security"
  433. pname="debian-security"
  434. ;;
  435. debian-debug)
  436. pusharg="-a debug"
  437. ;;&
  438. debian-security-debug)
  439. pusharg="-a security-debug"
  440. ;;&
  441. backports)
  442. pusharg="-a backports"
  443. ;;&
  444. *)
  445. fname="mirrorstart.${archive}"
  446. pname=${archive}
  447. ;;
  448. esac
  449. mkdir -p ${webdir}/${pname}/project/trace/
  450. ln -sf ${mirrordir}/${archive}/project/trace/master ${webdir}/${pname}/project/trace/master
  451. ln -sf ${mirrordir}/${archive}/project/trace/master ${webdir}/${pname}/project/trace/ftp-master.debian.org
  452. date -u > ${webdir}/${fname}
  453. echo "Using dak v1" >> ${webdir}/${fname}
  454. echo "Running on host $(hostname -f)" >> ${webdir}/${fname}
  455. sudo -u archvsync runmirrors ${pusharg} > ~dak/runmirrors-${archive}.log 2>&1 &
  456. fi
  457. done
  458. }
  459. function mirrorpush-backports() {
  460. log "Syncing backports mirror"
  461. sudo -u backports /home/backports/bin/update-archive
  462. }
  463. function mirrorpush-release() {
  464. log "Pushing cdbuilder host"
  465. sudo -u archvsync runmirrors -a release > ~dak/runmirrors-release.log 2>&1 &
  466. }
  467. function i18n2() {
  468. log "Exporting package data foo for i18n project"
  469. STAMP=$(date "+%Y%m%d%H%M")
  470. mkdir -p ${scriptdir}/i18n/${STAMP}
  471. cd ${scriptdir}/i18n/${STAMP}
  472. for suite in stable testing unstable; do
  473. codename=$(dak admin suite-config get-value ${suite} codename)
  474. echo "Codename is ${codename}"
  475. dak control-suite -l ${suite} >${codename}
  476. done
  477. echo "${STAMP}" > timestamp
  478. 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
  479. rm -f md5sum
  480. md5sum * > md5sum
  481. cd ${webdir}/
  482. ln -sfT ${scriptdir}/i18n/${STAMP} i18n
  483. cd ${scriptdir}
  484. find ./i18n -mindepth 1 -maxdepth 1 -mtime +2 -not -name "${STAMP}" -type d -print0 | xargs --no-run-if-empty -0 rm -rf
  485. }
  486. function stats() {
  487. log "Updating stats data"
  488. cd ${configdir}
  489. #${scriptsdir}/update-ftpstats ${base}/log/* > ${base}/misc/ftpstats.data
  490. #R --slave --vanilla < ${base}/misc/ftpstats.R
  491. dak stats arch-space > ${webdir}/arch-space
  492. dak stats pkg-nums > ${webdir}/pkg-nums
  493. }
  494. function cleantransactions() {
  495. log "Cleanup transaction ids older than 3 months"
  496. cd ${base}/backup/
  497. find -maxdepth 1 -mindepth 1 -type f -name 'txid_*' -mtime +90 -delete
  498. }
  499. function logstats() {
  500. if [ "${functionname}" = ftp-master.debian.org ]; then
  501. cd ${TMPDIR}
  502. ${masterdir}/tools/logs.py "$1"
  503. fi
  504. }
  505. # save timestamp when we start
  506. function savetimestamp() {
  507. echo ${NOW} > "${dbdir}/dinstallstart"
  508. }
  509. function maillogfile() {
  510. 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}"
  511. }
  512. function testingsourcelist() {
  513. dak ls -s testing -f heidi -r .| egrep 'source$' > ${webdir}/testing.list
  514. }
  515. # Function to update a "statefile" telling people what we are doing
  516. # (more or less).
  517. #
  518. # This should be called with the argument(s)
  519. # - Status name we want to show.
  520. #
  521. function state() {
  522. RIGHTNOW="$(date -u +"%a %b %d %T %Z %Y (%s)")"
  523. cat >"${DINSTALLSTATE}" <<EOF
  524. Dinstall start: ${DINSTALLBEGIN}
  525. Current action: $*
  526. Action start: ${RIGHTNOW}
  527. EOF
  528. }
  529. # extract changelogs and stuff
  530. function changelogs() {
  531. log "Extracting changelogs"
  532. dak make-changelog -e -a ftp-master
  533. [[ -f ${exportdir}/changelogs/filelist.yaml ]] && xz -f ${exportdir}/changelogs/filelist.yaml
  534. mkdir -p ${exportpublic}/changelogs
  535. cd ${exportpublic}/changelogs
  536. rsync -aHW --delete --delete-after --ignore-errors ${exportdir}/changelogs/. .
  537. sudo -H -u staticsync /usr/local/bin/static-update-component metadata.ftp-master.debian.org >/dev/null 2>&1 &
  538. # dak make-changelog -e -a backports
  539. # [[ -f /srv/backports-master.debian.org/export/changelogs/filelist.yaml ]] && xz -f /srv/backports-master.debian.org/export/changelogs/filelist.yaml
  540. # mkdir -p /srv/backports-master.debian.org/rsync/export/changelogs
  541. # cd /srv/backports-master.debian.org/rsync/export/changelogs
  542. # rsync -aHW --delete --delete-after --ignore-errors /srv/backports-master.debian.org/export/changelogs/. .
  543. }
  544. # Generate a list of extra mirror files, sha256sum em and sign that
  545. function signotherfiles() {
  546. log "Signing extra mirror files"
  547. local archiveroot
  548. for archive in "${public_archives[@]}"; do
  549. log "... archive: ${archive}"
  550. archiveroot="$(get_archiveroot "${archive}")"
  551. local TMPLO=$( gettempfile )
  552. cd ${archiveroot}
  553. rm -f extrafiles
  554. sha256sum $(find * -type f | egrep -v '(pool|i18n|dep11|source)/|Contents-.*\.(gz|diff)|installer|binary-|(In)?Release(.gpg)?|\.changes' | sort) > ${TMPLO}
  555. 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}
  556. rm -f ${TMPLO}
  557. done
  558. }
  559. function startup() {
  560. touch "${DINSTALLSTART}"
  561. log_timestamp "startup"
  562. trap onerror ERR
  563. }
  564. function postcronscript() {
  565. trap - ERR
  566. logstats ${LOGFILE}
  567. touch "${DINSTALLEND}"
  568. }