5 # Update node package repository metadata and sign packages
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
22 if [ "$PLC_BOOT_ENABLED" != "1" ] ; then
26 MESSAGE=$"Signing and indexing node packages"
32 if [[ -z "$@" ]] ; then
33 # use all subdirs in install-rpms by default
34 repositories=/var/www/html/install-rpms/*
40 for repository in $repositories ; do
46 # Create a stamp once the package gets signed
47 mkdir $repository/signed-stamps 2> /dev/null
49 for package in $(find $repository/ -name '*.rpm') ; do
50 stamp=$repository/signed-stamps/$(basename $package).signed
51 # If package is newer than signature stamp
52 if [ $package -nt $stamp ] ; then
53 packages="$packages $package"
54 stamps="$stamps $stamp"
57 if [ $package -nt $repository/headers/header.info ] ; then
60 # Or createrepo database
61 if [ $package -nt $repository/repodata/repomd.xml ] ; then
66 if [ -n "$packages" ] ; then
67 # Sign RPMS. setsid detaches rpm from the terminal,
68 # allowing the (hopefully blank) GPG password to be
69 # entered from stdin instead of /dev/tty.
71 --define "_signature gpg" \
72 --define "_gpg_path /etc/planetlab" \
73 --define "_gpg_name $PLC_MAIL_SUPPORT_ADDRESS" \
74 --resign $packages && touch $stamps
78 # Update yum metadata. yum-arch createrepo sometimes leaves behind
79 # .oldheaders and .olddata directories accidentally.
80 rm -rf $repository/{.oldheaders,.olddata}
82 type -p yum-arch > /dev/null && have_yum_arch="true"
84 # Old command is yum-arch
85 if [ -n "$have_yum_arch" -a $yum_arch -eq 1 ] ; then
90 type -p createrepo > /dev/null && have_createrepo="true"
92 # New command is createrepo
93 if [ -n "$have_createrepo" -a $createrepo -eq 1 ] ; then
94 if [ -f $repository/yumgroups.xml ] ; then
95 createrepo --quiet -g yumgroups.xml $repository
97 createrepo --quiet $repository
107 if [[ -z "$@" ]] ; then
108 # use all subdirs in install-rpms by default
109 repositories=/var/www/html/install-rpms/*
115 for repository in $repositories ; do
116 rm -rf $repository/signed-stamps
117 rm -rf $repository/repodata
118 rm -rf $repository/headers
122 echo "Usage: $0 start|clean [repo ..]"