7 # Update node package repository metadata and sign packages
9 # Mark Huang <mlhuang@cs.princeton.edu>
10 # 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 ### availability of repo indexing tools
41 # old one - might be needed for old-style nodes
42 type -p yum-arch > /dev/null && have_yum_arch="true"
44 type -p createrepo > /dev/null && have_createrepo="true"
47 ### copy vserver-PLDISTRO* and vserver-systemslices-PLDISTRO*
48 ### pacakges to each repository to be able to create different
49 ### flavours of vservers on nodes
50 for repository1 in $repositories; do
51 for repository2 in $repositories; do
52 if [[ $(basename $repository1) == ${PLC_FLAVOUR_NODE_PLDISTRO}* ]] \
53 && [[ $(basename $repository2) == ${PLC_FLAVOUR_NODE_PLDISTRO}* ]] \
54 && [[ $repository1 != $repository2 ]] ; then
55 cp -a $repository1/vserver{,-systemslices}-${PLC_FLAVOUR_NODE_PLDISTRO}* $repository2
61 for repository in $repositories ; do
62 # the rpms that need signing
64 # and the corresponding stamps
66 # is there a need to refresh yum metadata
70 # right after installation, no package is present
71 # but we still need to create index
72 [ -n "$have_yum_arch" -a ! -f $repository/headers/header.info ] && need_yum_arch=true
73 [ -n "$have_createrepo" -a ! -f $repository/repodata/repomd.xml ] && need_createrepo=true
75 for package in $(find $repository/ -name '*.rpm') ; do
76 stamp=$repository/signed-stamps/$(basename $package).signed
77 # If package is newer than signature stamp
78 if [ $package -nt $stamp ] ; then
79 new_rpms="$new_rpms $package"
80 new_stamps="$new_stamps $stamp"
82 # Or than yum-arch headers
83 [ -n "$have_yum_arch" ] && [ $package -nt $repository/headers/header.info ] && need_yum_arch=true
84 # Or than createrepo database
85 [ -n "$have_createrepo" ] && [ $package -nt $repository/repodata/repomd.xml ] && need_createrepo=true
88 if [ -n "$new_rpms" ] ; then
89 # Create a stamp once the package gets signed
90 mkdir $repository/signed-stamps 2> /dev/null
92 # Sign RPMS. setsid detaches rpm from the terminal,
93 # allowing the (hopefully blank) GPG password to be
94 # entered from stdin instead of /dev/tty.
96 --define "_signature gpg" \
97 --define "_gpg_path /etc/planetlab" \
98 --define "_gpg_name $PLC_MAIL_SUPPORT_ADDRESS" \
99 --resign $new_rpms && touch $new_stamps
103 # Update repository index / yum metadata.
105 if [ -n "$need_yum_arch" ] ; then
106 # yum-arch sometimes leaves behind
107 # .oldheaders and .olddata directories accidentally.
108 rm -rf $repository/{.oldheaders,.olddata}
113 if [ -n "$need_createrepo" ] ; then
114 if [ -f $repository/yumgroups.xml ] ; then
115 createrepo --quiet -g yumgroups.xml $repository
117 createrepo --quiet $repository
127 if [[ -z "$@" ]] ; then
128 # use all subdirs in install-rpms by default
129 repositories=/var/www/html/install-rpms/*
135 for repository in $repositories ; do
136 rm -rf $repository/signed-stamps
137 rm -rf $repository/repodata
138 rm -rf $repository/headers
142 echo "Usage: $0 start|clean [repo ..]"