repositories=/var/www/html/install-rpms/*
else
# else use argv
- repositories=$@
+ 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 2> /dev/null
+ ### availability of repo indexing tools
+ # old one - might be needed for old-style nodes
+ type -p yum-arch > /dev/null && have_yum_arch="true"
+ # new one
+ type -p createrepo > /dev/null && have_createrepo="true"
+ for repository in $repositories ; do
+ # the rpms that need signing
+ new_rpms=
+ # and the corresponding stamps
+ new_stamps=
+ # is there a need to refresh yum metadata
+ need_yum_arch=
+ need_createrepo=
+
+ # right after installation, no package is present
+ # but we still need to create index
+ [ -n "$have_yum_arch" -a ! -f $repository/headers/header.info ] && need_yum_arch=true
+ [ -n "$have_createrepo" -a ! -f $repository/repodata/repomd.xml ] && need_createrepo=true
+
for package in $(find $repository/ -name '*.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
+ new_rpms="$new_rpms $package"
+ new_stamps="$new_stamps $stamp"
fi
+ # Or than yum-arch headers
+ [ -n "$have_yum_arch" ] && [ $package -nt $repository/headers/header.info ] && need_yum_arch=true
+ # Or than createrepo database
+ [ -n "$have_createrepo" ] && [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
done
- if [ -n "$packages" ] ; then
+ if [ -n "$new_rpms" ] ; then
+ # Create a stamp once the package gets signed
+ mkdir $repository/signed-stamps 2> /dev/null
+
# Sign RPMS. setsid detaches rpm from the terminal,
# allowing the (hopefully blank) GPG password to be
# entered from stdin instead of /dev/tty.
--define "_signature gpg" \
--define "_gpg_path /etc/planetlab" \
--define "_gpg_name $PLC_MAIL_SUPPORT_ADDRESS" \
- --resign $packages && touch $stamps
+ --resign $new_rpms && touch $new_stamps
check
fi
- # Update yum metadata. yum-arch createrepo sometimes leaves behind
- # .oldheaders and .olddata directories accidentally.
- rm -rf $repository/{.oldheaders,.olddata}
+ # Update repository index / yum metadata.
- 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
+ if [ -n "$need_yum_arch" ] ; then
+ # yum-arch sometimes leaves behind
+ # .oldheaders and .olddata directories accidentally.
+ rm -rf $repository/{.oldheaders,.olddata}
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 [ -n "$need_createrepo" ] ; then
if [ -f $repository/yumgroups.xml ] ; then
createrepo --quiet -g yumgroups.xml $repository
else