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