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