]> git.decadent.org.uk Git - dak.git/blob - scripts/debian/mkfilesindices
8bc57e30a7274ab7cb8b7fdf1fa0959593b7396e
[dak.git] / scripts / debian / mkfilesindices
1 #!/bin/sh -e
2
3 umask 002
4
5 cd /org/ftp.debian.org/ftp/indices/files/components
6
7 ARCHLIST=$(tempfile)
8
9 echo "Querying projectb..."
10
11 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,^/org/ftp.debian.org/ftp,.,' | sort >$ARCHLIST
12
13 includedirs () {
14     perl -ne 'print; while (m,/[^/]+$,) { $_=$`; print $_ . "\n" unless $d{$_}++; }'
15 }
16
17 poolfirst () {
18     perl -e '@nonpool=(); while (<>) { if (m,^\./pool/,) { print; } else { push @nonpool, $_; } } print for (@nonpool);'
19 }
20
21 echo "Generating sources list..."
22
23 (
24   sed -n 's/|$//p' $ARCHLIST
25   cd /org/ftp.debian.org/ftp
26   find ./dists -maxdepth 1 \! -type d
27   find ./dists \! -type d | grep "/source/"
28 ) | sort -u | gzip -9 > source.list.gz
29
30 echo "Generating arch lists..."
31
32 ARCHES=$( (<$ARCHLIST sed -n 's/^.*|//p'; echo amd64) | grep . | sort -u)
33 for a in $ARCHES; do
34   (sed -n "s/|$a$//p" $ARCHLIST
35
36    cd /org/ftp.debian.org/ftp;
37    find ./dists -maxdepth 1 \! -type d
38    find ./dists \! -type d | grep -E "(proposed-updates.*_$a.changes$|/main/disks-$a/|/main/installer-$a/|/Contents-$a|/binary-$a/)"
39    if echo X sparc mips mipsel hppa X | grep -q " $a "; then
40      find ./dists/sarge/main/upgrade-kernel \! -type d
41    fi
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 /org/ftp.debian.org/ftp/dists/$suite ] || continue
56     (
57      (cd /org/ftp.debian.org/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,^/org/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 /org/ftp.debian.org/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 (cat ../arch-i386.files ../arch-amd64.files; zcat suite-stable.list.gz) |
85    sort -u | poolfirst > ../typical.files
86
87 rm -f $ARCHLIST
88
89 echo "Done!"