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 #check if root has rpm macros
25 architectures="i386 x86_64"
27 for vdist in centos/5.5 rhel/5.5; do
28 dist=`basename $vdist`
29 vendor=`dirname $vdist`
30 ftpdir=/home/ftp/pub/yum/$vendor/$dist
31 if test ! -d $ftpdir; then
32 echo "$ftpdir does not exist"
37 for section in main restricted; do
40 if test ! -d $d; then mkdir -p $d; fi
41 if test ! -d $d/SRPMS; then mkdir -p $d/SRPMS; fi
42 # Remove invalid symlinks (SRPMS, i386, x86_64,..)
43 for l in $d/SRPMS/*; do
45 if test ! -f "$l"; then
50 for arch in $architectures; do
51 dirs_to_upd="${dirs_to_upd} ${ftpdir}/${d}/${arch}"
52 for l in $d/$arch/Packages/*; do
54 if test ! -f "$l"; then
60 # Make symlinks from the regular FTP archive
62 for pdir in /home/ftp/pub/*; do
64 if test -f $pdir/.htaccess -a $section != "main"; then
67 if test ! -f $pdir/.htaccess -a $section = "main"; then
71 distdir=$pdir/redhat/$vendor/$dist
72 if test -d $distdir; then
73 if test -d $distdir/SRPMS; then
74 for f in $distdir/SRPMS/*.src.rpm; do
80 for arch in $architectures; do
81 mkdir -p $d/${arch}/Packages
82 for f in $distdir/RPMS/${arch}/*.rpm $distdir/RPMS/noarch/*.rpm; do
84 pkgs_to_sign="${pkgs_to_sign} $f"
85 ln -sf $f $d/${arch}/Packages/
95 echo "Signing pakages (default ID PPH is empty):"
96 rpm --addsign ${pkgs_to_sign}
97 chgrp staff ${pkgs_to_sign}
98 chmod g+w ${pkgs_to_sign}
99 echo "Updating repository meta:"
100 for rdir in ${dirs_to_upd}; do
101 echo "Section ${rdir}"
102 if test -d $rdir && ls -A $rdir; then
103 createrepo --update ${rdir}
104 if test -f ${rdir}/repodata/repomd.xml.asc; then
105 rm ${rdir}/repodata/repomd.xml.asc
107 gpg --detach-sign -u "Index Data" --armor ${rdir}/repodata/repomd.xml