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
11 # Source function library and configuration
12 . /etc/plc.d/functions
13 . /etc/planetlab/plc_config
20 if [ "$PLC_BOOT_ENABLED" != "1" ] ; then
24 MESSAGE=$"Signing and indexing node packages"
30 if [[ -z "$@" ]] ; then
31 # use all subdirs in install-rpms by default
32 repositories=/var/www/html/install-rpms/*
38 ### symlink vserver-PLDISTRO* and vserver-systemslices-PLDISTRO*
39 ### packages to each repository to be able to create different
40 ### flavours of vservers on nodes
41 for repository1 in $repositories; do
42 DISTRO=${PLC_FLAVOUR_SLICE_PLDISTRO}
43 VSERVER_PKG=vserver-$(basename $repository1)
44 VSERVER_SYS_SLICES_PKG=vserver-systemslices-$(basename $repository1)
45 for repository2 in $repositories; do
46 if [[ $(basename $repository1) == ${DISTRO}* ]] \
47 && [[ $(basename $repository2) == ${DISTRO}* ]] \
48 && [[ $repository1 != $repository2 ]] ; then
49 rm -rf $repository2/${VSERVER_PKG}*
50 rm -rf $repository2/${VSERVER_SYS_SLICES_PKG}*
52 ln -s $repository1/${VSERVER_PKG}* $repository2
53 ln -s $repository1/${VSERVER_SYS_SLICES_PKG}* $repository2
58 for repository in $repositories ; do
59 # the rpms that need signing
61 # and the corresponding stamps
63 # is there a need to refresh yum metadata
64 need_createrepo=true # always run createrepo as links may change for vserver packages
66 # right after installation, no package is present
67 # but we still need to create index
68 [ ! -f $repository/repodata/repomd.xml ] && need_createrepo=true
70 for package in $(find $repository/ -name '*.rpm') ; do
71 stamp=$repository/signed-stamps/$(basename $package).signed
72 # If package is newer than signature stamp
73 if [ $package -nt $stamp ] ; then
74 new_rpms="$new_rpms $package"
75 new_stamps="$new_stamps $stamp"
77 # Or than createrepo database
78 [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
81 if [ -n "$new_rpms" ] ; then
82 # Create a stamp once the package gets signed
83 mkdir $repository/signed-stamps 2> /dev/null
85 # Sign RPMS. setsid detaches rpm from the terminal,
86 # allowing the (hopefully blank) GPG password to be
87 # entered from stdin instead of /dev/tty.
89 --define "_signature gpg" \
90 --define "_gpg_path /etc/planetlab" \
91 --define "_gpg_name $PLC_MAIL_SUPPORT_ADDRESS" \
92 --resign $new_rpms && touch $new_stamps
96 # Update repository index / yum metadata.
98 if [ -n "$need_createrepo" ] ; then
99 if [ -f $repository/yumgroups.xml ] ; then
100 createrepo --quiet -g yumgroups.xml $repository
102 createrepo --quiet $repository
112 if [[ -z "$@" ]] ; then
113 # use all subdirs in install-rpms by default
114 repositories=/var/www/html/install-rpms/*
120 for repository in $repositories ; do
121 rm -rf $repository/signed-stamps
122 rm -rf $repository/repodata
123 rm -rf $repository/headers
127 echo "Usage: $0 start|clean [repo ..]"