# Mark Huang <mlhuang@cs.princeton.edu>
# Copyright (C) 2006 The Trustees of Princeton University
#
-# $Id: packages,v 1.4 2006/07/19 14:15:15 mlhuang Exp $
+# $Id$
#
# Source function library and configuration
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
fi
for repository in $repositories ; 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=
stamps=
- # create a stamp once the package gets signed
- mkdir $repository/signed-stamps
+ yum_arch=0
+ createrepo=0
+
+ # Create a stamp once the package gets signed
+ mkdir $repository/signed-stamps 2> /dev/null
- for package in $repository/*.rpm ; do
+ for package in $(find $repository/ -name '*.rpm') ; do
stamp=$repository/signed-stamps/$(basename $package).signed
- # is package newer than stamp ?
+ # If package is newer than signature stamp
if [ $package -nt $stamp ] ; then
packages="$packages $package"
stamps="$stamps $stamp"
- else
- echo "Package $package already signed - skipped"
+ 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" \
# Update yum metadata. yum-arch createrepo sometimes leaves behind
# .oldheaders and .olddata directories accidentally.
rm -rf $repository/{.oldheaders,.olddata}
- yum-arch $repository
- check
- createrepo -g yumgroups.xml $repository
- check
+
+ type -p yum-arch > /dev/null && have_yum_arch="true"
+
+ # Old command is yum-arch
+ if [ -n "$have_yum_arch" -a $yum_arch -eq 1 ] ; then
+ yum-arch $repository
+ check
+ fi
+
+ type -p createrepo > /dev/null && have_createrepo="true"
+
+ # New command is createrepo
+ if [ -n "$have_createrepo" -a $createrepo -eq 1 ] ; then
+ if [ -f $repository/yumgroups.xml ] ; then
+ createrepo --quiet -g yumgroups.xml $repository
+ else
+ createrepo --quiet $repository
+ fi
+ check
+ fi
done
result "$MESSAGE"
for repository in $repositories ; do
rm -rf $repository/signed-stamps
+ rm -rf $repository/repodata
+ rm -rf $repository/headers
done
;;
*)