X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc.d%2Fpackages;h=6b02bd52b06d9972c80f6ae2b4b19b57af6b6dfd;hb=391310e122de0536c08f62bd46acd3b3b7b13964;hp=cc7a84739d06d3a8bca30329f2b8db1263089116;hpb=1d9a3cbefb0ccf40224960e375f0d3e38ff80aeb;p=myplc.git diff --git a/plc.d/packages b/plc.d/packages index cc7a847..6b02bd5 100755 --- a/plc.d/packages +++ b/plc.d/packages @@ -7,44 +7,116 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: gpg,v 1.3 2006/05/08 18:16:33 mlhuang Exp $ +# $Id: packages 129 2007-03-20 12:04:03Z thierry $ # # 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" + if [ "$PLC_BOOT_ENABLED" != "1" ] ; then + exit 0 + fi + + 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. - packages=$repository/*.rpm - if [ -n $packages ] ; then + + 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 + 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. createrepo sometimes leaves behind - # an .olddata file accidentally. - rm -rf $repository/.olddata - yum-arch $repository - check - createrepo -g yumgroups.xml $repository - check + # 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 | tr '\r' '\n' | grep -v '^ *$' + check + fi + + # New command is createrepo + if [ $createrepo -eq 1 ] ; then + if [ -f $repository/yumgroups.xml ] ; then + createrepo -g yumgroups.xml $repository | tr '\r' '\n' | grep -v '^ *$' + else + createrepo $repository | tr '\r' '\n' | grep -v '^ *$' + 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