Fix removal of symlinks (.debs removed)
[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         # Prepare pool
33         d=pool/dists/$dist
34         if test ! -d $d; then mkdir -p $d; fi
35         mkdir -p $d/source
36         # Remove invalid symlinks (source, i386, amd64,..)
37         for l in $d/*/*; do
38                 if test -L $l; then
39                         if test ! -f $l; then
40                                 rm $l
41                         fi
42                 fi
43         done
44         # Make symlinks from the regular FTP archive
45         ln -sf /home/ftp/pub/*/$vendor/$dist/*.dsc $d/source
46         ln -sf /home/ftp/pub/*/$vendor/$dist/*.gz $d/source
47         for arch in $architectures; do
48                 mkdir -p $d/${arch}
49                 for f in /home/ftp/pub/*/$vendor/$dist/*_${arch}.* \
50                          /home/ftp/pub/*/$vendor/$dist/*_all.*; do
51                         if test -f $f; then
52                                 ln -sf $f $d/${arch}
53                         fi
54                 done
55                 #ln -sf /home/ftp/pub/*/$vendor/$dist/*_${arch}.* $d/${arch}
56                 #ln -sf /home/ftp/pub/*/$vendor/$dist/*_all.* $d/${arch}
57         done
58
59         # ${confdir}/symclean.sh $d
60
61         for arch in $architectures; do
62                 d=dists/$dist/main/binary-$arch
63                 if test ! -d $d; then mkdir -p $d; fi
64                 echo "Archive: $dist" >$d/Release
65                 echo 'Component: main' >>$d/Release
66                 echo 'Origin: Indexdata' >>$d/Release
67                 echo "Architecture: $arch" >>$d/Release
68         done
69
70         d=dists/$dist/main/source
71         if test ! -d $d; then mkdir -p $d; fi
72         echo "Archive: $dist" >$d/Release
73         echo 'Component: main' >>$d/Release
74         echo 'Origin: Indexdata' >>$d/Release
75         echo 'Architecture: source' >>$d/Release
76
77         # generate
78         echo "Begin Generate $dist"
79         F=apt-ftparchive.conf
80         sed "s/@dist@/$dist/g" <${confdir}/${F}.in |sed "s/@architectures@/${architectures}/g" > $F
81         # Don't know if clean is needed!
82         # apt-ftparchive clean apt-ftparchive.conf
83         apt-ftparchive generate apt-ftparchive.conf
84         echo "Done generate $dist"
85
86         # release
87         r=dists/$dist/Release
88         F=apt-release.conf
89         sed "s/@dist@/$dist/g" <${confdir}/${F}.in | sed "s/@architectures@/${architectures}/g" >$F
90         # Move Release file away while calling using release 
91         rm $r
92         apt-ftparchive -c $F release dists/$dist >tmp_Release
93         mv tmp_Release $r
94
95         # sign
96         if true; then
97                 r=dists/$dist/Release
98                 rm -f ${r}.gpg
99                 gpg --sign -u "Index Data" -ba -o ${r}.gpg dists/$dist/Release
100         fi
101 done
102 # Local Variables:
103 # mode:shell-script
104 # sh-indentation: 2
105 # sh-basic-offset: 8
106 # End:
107