]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/mkfilesindices
Remove / Deactivate oldstable
[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/|all$/|/;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 . | sort -u)
35 for a in $ARCHES; do
36   (sed -n "s/|$a$//p" $ARCHLIST
37
38    cd $base/ftp
39    find ./dists -maxdepth 1 \! -type d
40    find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
41   ) | sort -u | gzip -9 > arch-$a.list.gz
42 done
43
44 echo "Generating suite lists..."
45
46 suite_list () {
47     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
48
49     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
50 }
51
52 printf 'SELECT id, suite_name FROM suite\n' | psql -F' ' -At projectb |
53   while read id suite; do
54     [ -e $base/ftp/dists/$suite ] || continue
55     (
56      (cd $base/ftp
57       distname=$(cd dists; readlink $suite || echo $suite)
58       find ./dists/$distname \! -type d
59       for distdir in ./dists/*; do 
60         [ "$(readlink $distdir)" != "$distname" ] || echo $distdir
61       done
62      )
63      suite_list $id | tr -d ' ' | sed 's,^/srv/ftp.debian.org/ftp,.,'
64     ) | sort -u | gzip -9 > suite-${suite}.list.gz
65   done
66
67 echo "Finding everything on the ftp site to generate sundries $(date +"%X")..."
68
69 (cd $base/ftp; find . \! -type d \! -name 'Archive_Maintenance_In_Progress' | sort) >$ARCHLIST
70
71 rm -f sundries.list
72 zcat *.list.gz | cat - *.list | sort -u | 
73   diff - $ARCHLIST | sed -n 's/^> //p' > sundries.list
74
75 echo "Generating files list $(date +"%X")..."
76
77 for a in $ARCHES; do
78   (echo ./project/trace; zcat arch-$a.list.gz source.list.gz) | 
79     cat - sundries.list dists.list project.list docs.list indices.list |
80     sort -u | poolfirst > ../arch-$a.files
81 done
82
83 (cat ../arch-i386.files ../arch-amd64.files; zcat suite-proposed-updates.list.gz) |
84    sort -u | poolfirst > ../typical.files
85
86 rm -f $ARCHLIST
87
88 echo "Done!"