2 if [ "$(id -u)" != "0" -o $HOME != "/root" ]; then
3 echo "This script must be run as root (not sudo) to perform package singning." 1>&2
7 if test ! -f ~/.rpmmacros; then
8 echo "$0: Make sure ~/.rpmmacros file exsits and contains macros from git-tools/update-archive/root-rpmmacros"
12 if test ! -x /usr/bin/createrepo; then
13 echo "$0: /usr/bin/createrepo missing. Install createrepo"
17 if test ! -x /usr/bin/gpg; then
18 echo "$0: /usr/bin/gpg missing. Install gpg"
22 if test ! -x /usr/bin/expect; then
23 echo "$0: /usr/bin/expect missing. Install expect"
28 # sign if newer than signage (86400=24 hrs)
30 #check if root has rpm macros
32 architectures="i386 x86_64"
34 for vdist in centos/5.5 rhel/5.5 centos/6 centos/7; do
35 dist=`basename $vdist`
36 vendor=`dirname $vdist`
37 ftpdir=/home/ftp/pub/yum/$vendor/$dist
38 if test ! -d $ftpdir; then
39 echo "$ftpdir does not exist"
44 for section in main restricted; do
47 if test ! -d $d; then mkdir -p $d; fi
48 if test ! -d $d/SRPMS; then mkdir -p $d/SRPMS; fi
49 # Remove invalid symlinks (SRPMS, i386, x86_64,..)
50 for l in $d/SRPMS/*; do
52 if test ! -f "$l"; then
57 for arch in $architectures; do
58 dirs_to_upd="${dirs_to_upd} ${ftpdir}/${d}/${arch}"
59 for l in $d/$arch/Packages/*; do
61 if test ! -f "$l"; then
67 # Make symlinks from the regular FTP archive
68 for pdir in /home/ftp/pub/*; do
70 if test -f $pdir/.htaccess -a $section != "main"; then
73 if test ! -f $pdir/.htaccess -a $section = "main"; then
77 distdir=$pdir/redhat/$vendor/$dist
78 if test -d $distdir; then
79 if test -d $distdir/SRPMS; then
80 for f in $distdir/SRPMS/*.src.rpm; do
86 for arch in $architectures; do
87 mkdir -p $d/${arch}/Packages
88 for f in $distdir/RPMS/${arch}/*.rpm $distdir/RPMS/noarch/*.rpm; do
92 age=`stat --printf='%Y' $f`
93 if expr $now - $age \< $signage >/dev/null; then
96 if test ! -f $d/${arch}/Packages/$b; then
100 ln -sf $f $d/${arch}/Packages/
101 if rpm -K $f|grep -q 'GPG' >/dev/null; then
102 echo "Already signed $f"
105 spawn rpm --addsign $f
106 expect -exact "Enter pass phrase: "
122 echo "Updating repository meta:"
123 for rdir in ${dirs_to_upd}; do
124 echo "Section ${rdir}"
125 if test -d $rdir && ls -A $rdir; then
126 # Get rid of createrepo warnings
127 # https://bugs.launchpad.net/ubuntu/+source/createrepo/+bug/530015
128 createrepo -q --update ${rdir} 2>&1 |
129 grep -v DeprecationWarning:|grep -v ' import'
130 if test -f ${rdir}/repodata/repomd.xml.asc; then
131 rm ${rdir}/repodata/repomd.xml.asc
133 gpg --detach-sign -u "Index Data" --armor ${rdir}/repodata/repomd.xml