Build yum indices
[git-tools-moved-to-github.git] / update-archive / update-yum-archve.sh
1 #!/bin/sh
2 #if test ! -x /usr/bin/createrepo; then
3 #       echo "$0: /usr/bin/createrepo missing. Install createrepo"
4 #       exit 1
5 #fi
6
7 confdir=`pwd`
8 architectures="i386 x86_64"
9 for vdist in centos/5.5 rhel/5.5; do
10         dist=`basename $vdist`
11         vendor=`dirname $vdist`
12         ftpdir=/home/ftp/pub/yum/$vendor/$dist
13         if test ! -d $ftpdir; then
14                 echo "$ftpdir does not exist"
15                 exit 1
16         fi
17         cd $ftpdir      
18         sections=""
19         for section in main restricted; do
20                 # Prepare pool
21                 d=$section
22                 if test ! -d $d; then mkdir -p $d; fi
23                 if test ! -d $d/SRPMS; then mkdir -p $d/SRPMS; fi
24                 # Remove invalid symlinks (SRPMS, i386, x86_64,..)
25                 for l in $d/SRPMS/*; do
26                         if test -L "$l"; then
27                                 if test ! -f "$l"; then
28                                         rm $l
29                                 fi
30                         fi
31                 done
32                 for arch in $architectures; do
33                         for l in $d/$arch/Packages/*; do
34                                 if test -L "$l"; then
35                                         if test ! -f "$l"; then
36                                                 rm $l
37                                         fi
38                                 fi
39                         done
40                 done
41                 # Make symlinks from the regular FTP archive
42                 has_packages=false
43                 for pdir in /home/ftp/pub/*; do
44                         use=false
45                         if test -f $pdir/.htaccess -a $section != "main"; then
46                                 use=true
47                         fi
48                         if test ! -f $pdir/.htaccess -a $section = "main"; then
49                                 use=true
50                         fi
51                         if $use; then
52                                 distdir=$pdir/redhat/$vendor/$dist
53                                 if test -d $distdir; then
54                                         if test -d $distdir/SRPMS; then
55                                                 for f in $distdir/SRPMS/*.src.rpm; do
56                                                         if test -f $f; then                                                             
57                                                                 ln -sf $f $d/SRPMS/
58                                                         fi
59                                                 done
60                                         fi
61                                         for arch in $architectures; do
62                                                 mkdir -p $d/${arch}/Packages
63                                                 for f in $distdir/RPMS/${arch}/*.rpm $distdir/RPMS/noarch/*.rpm; do
64                                                     if test -f $f; then
65                                                             ln -sf $f $d/${arch}/Packages/
66                                                         has_packages=true
67                                                     fi
68                                                 done
69             createrepo --update $d/${arch}
70             gpg --detach-sign --armor $d/${arch}/repodata/repomd.xml
71                                         done
72                                 fi
73                         fi
74                 done
75         done
76 done
77 # Local Variables:
78 # mode:shell-script
79 # sh-indentation: 2
80 # sh-basic-offset: 8
81 # End:
82