and again
[bootstrapfs.git] / plc.d / packages
index a3a112e..2046fad 100755 (executable)
@@ -108,33 +108,49 @@ case "$1" in
 
        mode=$1; shift
 
-       if [[ -z "$@" ]] ; then
-           # use all subdirs in install-rpms by default
-           repositories=/var/www/html/install-rpms/*
-       else
-           # else use argv
+       # hack for PLC
+       # there are some very old repos there, as well as some sensitive areas
+       # so by convention the repositories that have a 'PRESERVE' file won't
+       # be touched by the cross-flavour stuff
+       # i.e. no symlinks get created to or from there,
+       # and yumgroups is untouched
+
+       # use argv if provided
+       if [[ -n "$@" ]] ; then
            repositories="$@"
+       else
+           # consider all subdirs in install-rpms by default, except the slice repos
+           # use find instead of ls - for the corner case where the dir. is empty
+           # (thanks Thomas Dreibholz for the heads up)
+           repositories=$(find /var/www/html/install-rpms -maxdepth 1 -mindepth 1 -type d \! -name 'slice-*' 2> /dev/null)
        fi
 
+       # filter out PRESERVE'd repos
+       cross_repositories=""
+       for repository in $repositories; do
+           [ -f $repository/PRESERVE ] || cross_repositories="$cross_repositories $repository"
+       done
+
        ##########
        # deal with the sliceimage packages
        # symlink all instances of plain 'sliceimage-*rpm' in all repos
        # and cleanup old links 
-       sirpms=$(find $repositories -name 'sliceimage*rpm' -a -type f)
-       silinks=$(find $repositories -name 'sliceimage*rpm' -a -type l)
+       sirpms=$(find $cross_repositories -name 'sliceimage*rpm' -a -type f)
+       # for nicer upgrades, also remove symlinks from 5.0
+       silinks=$(find $cross_repositories '(' -name 'sliceimage*rpm' -o -name 'vserver*rpm' ')' -a -type l)
 
        for silink in $silinks; do
            [ ! -e $silink ] && { echo removing old $silink; rm $silink; }
        done
 
-       for repo in $repositories; do
+       for repository in $cross_repositories; do
            for sirpm in $sirpms; do
-           # if in the repo we're dealing with, ignore
-               if [ "$(echo $sirpm | sed -e s,^$repo,,)" != $sirpm ] ; then
+           # if in the repository we're dealing with, ignore
+               if [ "$(echo $sirpm | sed -e s,^$repository,,)" != $sirpm ] ; then
                    continue
                fi
                b=$(basename $sirpm)
-               link=$repo/$b
+               link=$repository/$b
                if [ ! -e $link ] ; then
                    echo "creating symlink $link towards $sirpm"
                    ln -s $sirpm $link
@@ -144,12 +160,14 @@ case "$1" in
 
        ##########
        # now that the symlinks are OK, we can tweak yumgroups
-       for repository in $repositories; do
+       for repository in $cross_repositories; do
            hack_yumgroups $repository
        done
 
        ########## sign plain packages
        for repository in $repositories ; do
+           # skip non-directory
+           [ -d $repository ] || continue
            # the rpms that need signing
            new_rpms=
            # and the corresponding stamps
@@ -212,6 +230,22 @@ case "$1" in
 
        result "$MESSAGE"
        ;;
+    index)
+       # just rerun createrepo
+       shift
+       if [[ -z "$@" ]] ; then
+           # use all subdirs in install-rpms by default
+           repositories=/var/www/html/install-rpms/*
+       else
+           # else use argv
+           repositories=$@
+       fi
+
+       for repository in $repositories ; do
+           echo ============================== running createrepo in $repository
+           createrepo -g yumgroups.xml $repository
+       done
+       ;;
     clean)
        shift
        if [[ -z "$@" ]] ; then