]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/mkfilesindices
First pass at lenny release branch
[dak.git] / scripts / debian / mkfilesindices
1 #!/bin/sh -e
2
3 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
4 . $SCRIPTVARS
5 umask 002
6
7 cd $base/ftp/indices/files/components
8
9 ARCHLIST=$(tempfile)
10
11 echo "Querying projectb..."
12
13 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
14
15 includedirs () {
16     perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
17 }
18
19 poolfirst () {
20     perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
21 }
22
23 echo "Generating sources list..."
24
25 (
26   sed -n 's/|$//p' $ARCHLIST
27   cd $base/ftp
28   find ./dists -maxdepth 1 \! -type d
29   find ./dists \! -type d | grep "/source/"
30 ) | sort -u | gzip -9 > source.list.gz
31
32 echo "Generating arch lists..."
33
34 ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | grep -v all | sort -u)
35 for a in $ARCHES; do
36   (sed -n "s/|$a$//p" $ARCHLIST
37    sed -n 's/|all$//p' $ARCHLIST
38
39    cd $base/ftp
40    find ./dists -maxdepth 1 \! -type d
41    find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
42   ) | sort -u | gzip -9 > arch-$a.list.gz
43 done
44
45 echo "Generating suite lists..."
46
47 suite_list () {
48     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
49
50     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
51 }
52
53 printf 'SELECT id, suite_name FROM suite\n' | psql -F' ' -At projectb |
54   while read id suite; do
55     [ -e $base/ftp/dists/$suite ] || continue
56     (
57      (cd $base/ftp
58       distname=$(cd dists; readlink $suite || echo $suite)
59       find ./dists/$distname \! -type d
60       for distdir in ./dists/*; do 
61         [ "$(readlink $distdir)" != "$distname" ] || echo $distdir
62       done
63      )
64      suite_list $id | tr -d ' ' | sed 's,^/srv/ftp.debian.org/ftp,.,'
65     ) | sort -u | gzip -9 > suite-${suite}.list.gz
66   done
67
68 echo "Finding everything on the ftp site to generate sundries $(date +"%X")..."
69
70 (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST
71
72 rm -f sundries.list
73 zcat *.list.gz | cat - *.list | sort -u | 
74   diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list
75
76 echo "Generating files list $(date +"%X")..."
77
78 for a in $ARCHES; do
79   (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) | 
80     cat - sundries.list dists.list project.list docs.list indices.list |
81     sort -u | poolfirst > ../arch-$a.files
82 done
83
84 (cd $base/ftp/
85         for dist in sid lenny; do
86                 find ./dists/$dist/main/i18n/ \! -type d | sort -u | gzip -9 > $base/ftp/indices/files/components/translation-$dist.list.gz
87         done
88 )
89
90 (cat ../arch-i386.files ../arch-amd64.files; zcat suite-oldstable.list.gz suite-proposed-updates.list.gz ; zcat translation-sid.list.gz ; zcat translation-lenny.list.gz) |
91    sort -u | poolfirst > ../typical.files
92
93 rm -f $ARCHLIST
94
95 echo "Done!"