Remove CVS Id line
[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/gutsy ubuntu/hardy ubuntu/intrepid ubuntu/jaunty ubuntu/karmic debian/squeeze debian/lenny debian/etch; do
19         dist=`basename $vdist`
20         vendor=`dirname $vdist`
21         ftpdir=/home/ftp/pub/$vendor
22         if test ! -d $ftpdir; then
23                 echo "$ftpdir does not exist"
24                 exit 1
25         fi
26         cd $ftpdir
27         test -d tmp || mkdir tmp
28         # Uncomment to clean the .db (cache)
29         # rm tmp/*
30
31         sections=""
32         for section in main restricted; 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                 has_packages=false
47                 for pdir in /home/ftp/pub/*; do
48                         use=false
49                         if test -f $pdir/.htaccess -a $section != "main"; then
50                                 use=true
51                         fi
52                         if test ! -f $pdir/.htaccess -a $section = "main"; then
53                                 use=true
54                         fi
55                         if $use; then
56                                 distdir=$pdir/$vendor/$dist
57                                 if test -d $distdir; then
58                                         ln -sf $distdir/*.dsc $d/source
59                                         ln -sf $distdir/*.gz $d/source
60                                         for arch in $architectures; do
61                                                 mkdir -p $d/${arch}
62                                                 for f in $pdir/.htaccess \
63                                                         $distdir/*_${arch}.* \
64                                                         $distdir/*_all.*; do
65                                                     if test -f $f; then
66                                                             ln -sf $f $d/${arch}
67                                                             has_packages=true
68                                                     fi
69                                                 done
70                                         done
71                                 fi
72                         fi
73                 done
74                 # ${confdir}/symclean.sh $d
75
76                 rm -f $d/Release
77                 if $has_packages; then
78                         if test -z "$sections"; then
79                                 sections="$section"
80                         else
81                                 sections="$sections $section"
82                         fi
83                         for arch in $architectures; do
84                                 d=dists/$dist/$section/binary-$arch
85                                 if test ! -d $d; then mkdir -p $d; fi
86                                 echo "Archive: $dist" >$d/Release
87                                 echo "Component: $section" >>$d/Release
88                                 echo 'Origin: Indexdata' >>$d/Release
89                                 echo "Architecture: $arch" >>$d/Release
90                         done
91                         d=dists/$dist/$section/source
92                         if test ! -d $d; then mkdir -p $d; fi
93                         echo "Archive: $dist" >$d/Release
94                         echo "Component: $section" >>$d/Release
95                         echo 'Origin: Indexdata' >>$d/Release
96                         echo 'Architecture: source' >>$d/Release
97                 fi
98         done
99         # generate
100         echo "Begin Generate $dist: $sections"
101         F=apt-ftparchive.conf
102         sed "s/@dist@/$dist/g" <${confdir}/${F}.in | \
103                 sed "s/@architectures@/${architectures}/g" | \
104                 sed "s/@sections@/${sections}/g" > $F
105         # Don't know if clean is needed!
106         # apt-ftparchive clean apt-ftparchive.conf
107         apt-ftparchive generate apt-ftparchive.conf
108         echo "Done generate $dist: $sections"
109
110         # release
111         r=dists/$dist/Release
112         F=apt-release.conf
113         sed "s/@dist@/$dist/g" <${confdir}/${F}.in | \
114                 sed "s/@architectures@/${architectures}/g" | \
115                 sed "s/@sections@/${sections}/g" > $F
116         # Move Release file away while calling using release 
117         rm $r
118         apt-ftparchive -c $F release dists/$dist >tmp_Release
119         mv tmp_Release $r
120
121         # sign
122         if true; then
123                 r=dists/$dist/Release
124                 rm -f ${r}.gpg
125                 gpg --sign -u "Index Data" -ba -o ${r}.gpg dists/$dist/Release
126         fi
127 done
128 # Local Variables:
129 # mode:shell-script
130 # sh-indentation: 2
131 # sh-basic-offset: 8
132 # End:
133