Skip sections not in use for each distro
[git-tools-moved-to-github.git] / update-archive / update-archive.sh
1 #!/bin/sh
2 # $Id: update-archive.sh,v 1.13 2008-10-20 10:24:15 adam Exp $
3 if test ! -f apt-ftparchive.conf.in; then
4         echo "$0: apt-ftparchive.conf.in must be located in current directory"
5         exit 1
6 fi
7
8 if test ! -x /usr/bin/apt-ftparchive; then
9         echo "$0: /usr/bin/apt-ftparchive missing. Install apt-utils"
10         exit 1
11 fi
12
13 # gpg -a -d -o Release.gpg Release
14
15 confdir=`pwd`
16
17 architectures="i386 amd64"
18
19 for vdist in ubuntu/gutsy ubuntu/hardy ubuntu/intrepid ubuntu/jaunty ubuntu/karmic debian/squeeze debian/lenny debian/etch; do
20         dist=`basename $vdist`
21         vendor=`dirname $vdist`
22         ftpdir=/home/ftp/pub/$vendor
23         if test ! -d $ftpdir; then
24                 echo "$ftpdir does not exist"
25                 exit 1
26         fi
27         cd $ftpdir
28         test -d tmp || mkdir tmp
29         # Uncomment to clean the .db (cache)
30         # rm tmp/*
31
32         sections=""
33         for section in main restricted; do
34                 # Prepare pool
35                 d=pool/dists/$dist/$section
36                 if test ! -d $d; then mkdir -p $d; fi
37                 mkdir -p $d/source
38                 # Remove invalid symlinks (source, i386, amd64,..)
39                 for l in $d/*/*; do
40                         if test -L "$l"; then
41                                 if test ! -f "$l"; then
42                                         rm $l
43                                 fi
44                         fi
45                 done
46                 # Make symlinks from the regular FTP archive
47                 has_packages=false
48                 for pdir in /home/ftp/pub/*; do
49                         use=false
50                         if test -f $pdir/.htaccess -a $section != "main"; then
51                                 use=true
52                         fi
53                         if test ! -f $pdir/.htaccess -a $section = "main"; then
54                                 use=true
55                         fi
56                         if $use; then
57                                 distdir=$pdir/$vendor/$dist
58                                 if test -d $distdir; then
59                                         ln -sf $distdir/*.dsc $d/source
60                                         ln -sf $distdir/*.gz $d/source
61                                         for arch in $architectures; do
62                                                 mkdir -p $d/${arch}
63                                                 for f in $pdir/.htaccess \
64                                                         $distdir/*_${arch}.* \
65                                                         $distdir/*_all.*; do
66                                                     if test -f $f; then
67                                                             ln -sf $f $d/${arch}
68                                                             has_packages=true
69                                                     fi
70                                                 done
71                                         done
72                                 fi
73                         fi
74                 done
75                 # ${confdir}/symclean.sh $d
76
77                 rm -f $d/Release
78                 if $has_packages; then
79                         if test -z "$sections"; then
80                                 sections="$section"
81                         else
82                                 sections="$sections $section"
83                         fi
84                         for arch in $architectures; do
85                                 d=dists/$dist/$section/binary-$arch
86                                 if test ! -d $d; then mkdir -p $d; fi
87                                 echo "Archive: $dist" >$d/Release
88                                 echo "Component: $section" >>$d/Release
89                                 echo 'Origin: Indexdata' >>$d/Release
90                                 echo "Architecture: $arch" >>$d/Release
91                         done
92                         d=dists/$dist/$section/source
93                         if test ! -d $d; then mkdir -p $d; fi
94                         echo "Archive: $dist" >$d/Release
95                         echo "Component: $section" >>$d/Release
96                         echo 'Origin: Indexdata' >>$d/Release
97                         echo 'Architecture: source' >>$d/Release
98                 fi
99         done
100         # generate
101         echo "Begin Generate $dist: $sections"
102         F=apt-ftparchive.conf
103         sed "s/@dist@/$dist/g" <${confdir}/${F}.in | \
104                 sed "s/@architectures@/${architectures}/g" | \
105                 sed "s/@sections@/${sections}/g" > $F
106         # Don't know if clean is needed!
107         # apt-ftparchive clean apt-ftparchive.conf
108         apt-ftparchive generate apt-ftparchive.conf
109         echo "Done generate $dist: $sections"
110
111         # release
112         r=dists/$dist/Release
113         F=apt-release.conf
114         sed "s/@dist@/$dist/g" <${confdir}/${F}.in | \
115                 sed "s/@architectures@/${architectures}/g" | \
116                 sed "s/@sections@/${sections}/g" > $F
117         # Move Release file away while calling using release 
118         rm $r
119         apt-ftparchive -c $F release dists/$dist >tmp_Release
120         mv tmp_Release $r
121
122         # sign
123         if true; then
124                 r=dists/$dist/Release
125                 rm -f ${r}.gpg
126                 gpg --sign -u "Index Data" -ba -o ${r}.gpg dists/$dist/Release
127         fi
128 done
129 # Local Variables:
130 # mode:shell-script
131 # sh-indentation: 2
132 # sh-basic-offset: 8
133 # End:
134