X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc.d%2Fpackages;h=dab7fca8e7704f5858c65c3dd31f83f804414b08;hb=fd3b83dd785a1e16c2e45795091fc1ac275cdfe5;hp=6c6862c34a9c5a818e540ab68d589cda86b3fb16;hpb=81e21afee0518a7e511dd3af1ba275ad3c3fdddd;p=myplc.git diff --git a/plc.d/packages b/plc.d/packages index 6c6862c..dab7fca 100755 --- a/plc.d/packages +++ b/plc.d/packages @@ -7,47 +7,112 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: packages,v 1.1 2006/05/18 17:36:39 mlhuang Exp $ +# $Id: packages,v 1.6 2007/01/30 15:56:53 thierry Exp $ # # Source function library and configuration . /etc/plc.d/functions . /etc/planetlab/plc_config +# Be verbose +set -x + case "$1" in start) - MESSAGE=$"Signing node packages" + MESSAGE=$"Signing and indexing node packages" dialog "$MESSAGE" shopt -s nullglob - for repository in /var/www/html/install-rpms/* ; do - # Sign all RPMS. setsid detaches rpm from the terminal, - # allowing the (hopefully blank) GPG password to be - # entered from stdin instead of /dev/tty. + + 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 packages= + stamps= + yum_arch=0 + createrepo=0 + + # Create a stamp once the package gets signed + mkdir $repository/signed-stamps + for package in $repository/*.rpm ; do - packages="$packages $package" + stamp=$repository/signed-stamps/$(basename $package).signed + # If package is newer than signature stamp + if [ $package -nt $stamp ] ; then + packages="$packages $package" + stamps="$stamps $stamp" + fi + # Or yum-arch headers + if [ $package -nt $repository/headers/header.info ] ; then + yum_arch=1 + fi + # Or createrepo database + if [ $package -nt $repository/repodata/repomd.xml ] ; then + createrepo=1 + fi done + if [ -n "$packages" ] ; then + # Sign RPMS. setsid detaches rpm from the terminal, + # allowing the (hopefully blank) GPG password to be + # entered from stdin instead of /dev/tty. echo | setsid rpm \ --define "_signature gpg" \ --define "_gpg_path /etc/planetlab" \ --define "_gpg_name $PLC_MAIL_SUPPORT_ADDRESS" \ - --resign $packages + --resign $packages && touch $stamps + check + fi + + # Update yum metadata. yum-arch createrepo sometimes leaves behind + # .oldheaders and .olddata directories accidentally. + rm -rf $repository/{.oldheaders,.olddata} + + # Old command is yum-arch + if [ $yum_arch -eq 1 ] ; then + yum-arch $repository check fi - # Update yum metadata. createrepo sometimes leaves behind - # an .olddata file accidentally. - rm -rf $repository/.olddata - yum-arch $repository - check - createrepo -g yumgroups.xml $repository - check + # New command is createrepo + if [ $createrepo -eq 1 ] ; then + if [ -f $repository/yumgroups.xml ] ; then + createrepo -g yumgroups.xml $repository + else + createrepo $repository + fi + check + fi done result "$MESSAGE" ;; + clean) + 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 + rm -rf $repository/signed-stamps + rm -rf $repository/repodata + rm -rf $repository/headers + done + ;; + *) + echo "Usage: $0 start|clean [repo ..]" + ;; esac exit $ERRORS