From 1798c52350ce339118397db01f720fb772f63f8a Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Sun, 1 Nov 2009 22:25:02 +0100 Subject: [PATCH] make mkfilesindices a function Signed-off-by: Joerg Jaspert --- config/debian/cron.dinstall | 90 ++++++++++++++++++++++++++++++++- scripts/debian/mkfilesindices | 95 ----------------------------------- 2 files changed, 89 insertions(+), 96 deletions(-) delete mode 100755 scripts/debian/mkfilesindices diff --git a/config/debian/cron.dinstall b/config/debian/cron.dinstall index 77f6ab11..195b47fb 100755 --- a/config/debian/cron.dinstall +++ b/config/debian/cron.dinstall @@ -357,13 +357,101 @@ function copyoverrides() { done } +function mkfilesindices() { + umask 002 + cd $base/ftp/indices/files/components + + ARCHLIST=$(tempfile) + + echo "Querying projectb..." + echo 'SELECT l.path, f.filename, a.arch_string FROM location l JOIN files f ON (f.location = l.id) LEFT OUTER JOIN (binaries b JOIN architecture a ON (b.architecture = a.id)) ON (f.id = b.file)' | psql projectb -At | sed 's/|//;s,^/srv/ftp.debian.org/ftp,.,' | sort >$ARCHLIST + + includedirs () { + perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }' + } + poolfirst () { + perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);' + } + + echo "Generating sources list..." + ( + sed -n 's/|$//p' $ARCHLIST + cd $base/ftp + find ./dists -maxdepth 1 \! -type d + find ./dists \! -type d | grep "/source/" + ) | sort -u | gzip --rsyncable -9 > source.list.gz + + echo "Generating arch lists..." + + ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u) + for a in $ARCHES; do + (sed -n "s/|$a$//p" $ARCHLIST + sed -n 's/|all$//p' $ARCHLIST + + cd $base/ftp + find ./dists -maxdepth 1 \! -type d + find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)" + ) | sort -u | gzip --rsyncable -9 > arch-$a.list.gz + done + + echo "Generating suite lists..." + + suite_list () { + printf 'SELECT DISTINCT l.path, f.filename FROM (SELECT sa.source AS source FROM src_associations sa WHERE sa.suite = %d UNION SELECT b.source AS source FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) WHERE ba.suite = %d) s JOIN dsc_files df ON (s.source = df.source) JOIN files f ON (df.file = f.id) JOIN location l ON (f.location = l.id)\n' $1 $1 | psql -F' ' -A -t projectb + + printf 'SELECT l.path, f.filename FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) JOIN files f ON (b.file = f.id) JOIN location l ON (f.location = l.id) WHERE ba.suite = %d\n' $1 | psql -F' ' -A -t projectb + } + + printf 'SELECT id, suite_name FROM suite\n' | psql -F' ' -At projectb | + while read id suite; do + [ -e $base/ftp/dists/$suite ] || continue + ( + (cd $base/ftp + distname=$(cd dists; readlink $suite || echo $suite) + find ./dists/$distname \! -type d + for distdir in ./dists/*; do + [ "$(readlink $distdir)" != "$distname" ] || echo $distdir + done + ) + suite_list $id | tr -d ' ' | sed 's,^/srv/ftp.debian.org/ftp,.,' + ) | sort -u | gzip --rsyncable -9 > suite-${suite}.list.gz + done + + echo "Finding everything on the ftp site to generate sundries $(date +"%X")..." + + (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST + + rm -f sundries.list + zcat *.list.gz | cat - *.list | sort -u | + diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list + + echo "Generating files list $(date +"%X")..." + + for a in $ARCHES; do + (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) | + cat - sundries.list dists.list project.list docs.list indices.list | + sort -u | poolfirst > ../arch-$a.files + done + + (cd $base/ftp/ + for dist in sid squeeze; do + find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip --rsyncable -9 > $base/ftp/indices/files/components/translation-$dist.list.gz + done + ) + + (cat ../arch-i386.files ../arch-amd64.files; zcat suite-oldstable.list.gz suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-squeeze.list.gz) | + sort -u | poolfirst > ../typical.files + + rm -f $ARCHLIST + echo "Done!" +} function scripts() { log "Running various scripts from $scriptsdir" cd $scriptsdir mkmaintainers copyoverrides mklslar - ./mkfilesindices + mkfilesindices ./mkchecksums } diff --git a/scripts/debian/mkfilesindices b/scripts/debian/mkfilesindices deleted file mode 100755 index c16fde6a..00000000 --- a/scripts/debian/mkfilesindices +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh -e - -export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars -. $SCRIPTVARS -umask 002 - -cd $base/ftp/indices/files/components - -ARCHLIST=$(tempfile) - -echo "Querying projectb..." - -echo 'SELECT l.path, f.filename, a.arch_string FROM location l JOIN files f ON (f.location = l.id) LEFT OUTER JOIN (binaries b JOIN architecture a ON (b.architecture = a.id)) ON (f.id = b.file)' | psql projectb -At | sed 's/|//;s,^/srv/ftp.debian.org/ftp,.,' | sort >$ARCHLIST - -includedirs () { - perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }' -} - -poolfirst () { - perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);' -} - -echo "Generating sources list..." - -( - sed -n 's/|$//p' $ARCHLIST - cd $base/ftp - find ./dists -maxdepth 1 \! -type d - find ./dists \! -type d | grep "/source/" -) | sort -u | gzip --rsyncable -9 > source.list.gz - -echo "Generating arch lists..." - -ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u) -for a in $ARCHES; do - (sed -n "s/|$a$//p" $ARCHLIST - sed -n 's/|all$//p' $ARCHLIST - - cd $base/ftp - find ./dists -maxdepth 1 \! -type d - find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)" - ) | sort -u | gzip --rsyncable -9 > arch-$a.list.gz -done - -echo "Generating suite lists..." - -suite_list () { - printf 'SELECT DISTINCT l.path, f.filename FROM (SELECT sa.source AS source FROM src_associations sa WHERE sa.suite = %d UNION SELECT b.source AS source FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) WHERE ba.suite = %d) s JOIN dsc_files df ON (s.source = df.source) JOIN files f ON (df.file = f.id) JOIN location l ON (f.location = l.id)\n' $1 $1 | psql -F' ' -A -t projectb - - printf 'SELECT l.path, f.filename FROM bin_associations ba JOIN binaries b ON (ba.bin = b.id) JOIN files f ON (b.file = f.id) JOIN location l ON (f.location = l.id) WHERE ba.suite = %d\n' $1 | psql -F' ' -A -t projectb -} - -printf 'SELECT id, suite_name FROM suite\n' | psql -F' ' -At projectb | - while read id suite; do - [ -e $base/ftp/dists/$suite ] || continue - ( - (cd $base/ftp - distname=$(cd dists; readlink $suite || echo $suite) - find ./dists/$distname \! -type d - for distdir in ./dists/*; do - [ "$(readlink $distdir)" != "$distname" ] || echo $distdir - done - ) - suite_list $id | tr -d ' ' | sed 's,^/srv/ftp.debian.org/ftp,.,' - ) | sort -u | gzip --rsyncable -9 > suite-${suite}.list.gz - done - -echo "Finding everything on the ftp site to generate sundries $(date +"%X")..." - -(cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST - -rm -f sundries.list -zcat *.list.gz | cat - *.list | sort -u | - diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list - -echo "Generating files list $(date +"%X")..." - -for a in $ARCHES; do - (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) | - cat - sundries.list dists.list project.list docs.list indices.list | - sort -u | poolfirst > ../arch-$a.files -done - -(cd $base/ftp/ - for dist in sid squeeze; do - find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip --rsyncable -9 > $base/ftp/indices/files/components/translation-$dist.list.gz - done -) - -(cat ../arch-i386.files ../arch-amd64.files; zcat suite-oldstable.list.gz suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-squeeze.list.gz) | - sort -u | poolfirst > ../typical.files - -rm -f $ARCHLIST - -echo "Done!" -- 2.39.5