Update yum repo script
[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                                                                 has_packages=true
59                                                         fi
60                                                 done
61                                         fi
62                                         for arch in $architectures; do
63                                                 mkdir -p $d/${arch}/Packages
64                                                 for f in $distdir/RPMS/${arch}/*.rpm $distdir/RPMS/noarch/*.rpm; do
65                                                     if test -f $f; then
66                                                         ln -sf $f $d/${arch}/Packages/
67                                                         has_packages=true
68                                                     fi
69                                                 done
70                                         done
71                                 fi
72                         fi
73                 done
74         done
75 done
76 # Local Variables:
77 # mode:shell-script
78 # sh-indentation: 2
79 # sh-basic-offset: 8
80 # End:
81