make YUM archive update non-interactive
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 6 Jul 2012 10:34:44 +0000 (12:34 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 6 Jul 2012 10:34:44 +0000 (12:34 +0200)
Pass empty password to it , using expect

update-archive/update-yum-archive.sh

index 72b1b81..4010b7b 100755 (executable)
@@ -19,9 +19,13 @@ if test ! -x /usr/bin/gpg; then
   exit 1
 fi
 
+if test ! -x /usr/bin/expect; then
+  echo "$0: /usr/bin/expect missing. Install expect"
+  exit 1
+fi
+
 #check if root has rpm macros
 confdir=`pwd`
-pkgs_to_sign=""
 architectures="i386 x86_64"
 dirs_to_upd=""
 for vdist in centos/5.5 rhel/5.5; do
@@ -58,7 +62,6 @@ for vdist in centos/5.5 rhel/5.5; do
       done
     done
     # Make symlinks from the regular FTP archive
-    has_packages=false
     for pdir in /home/ftp/pub/*; do
       use=false
       if test -f $pdir/.htaccess -a $section != "main"; then
@@ -72,7 +75,7 @@ for vdist in centos/5.5 rhel/5.5; do
         if test -d $distdir; then
           if test -d $distdir/SRPMS; then
             for f in $distdir/SRPMS/*.src.rpm; do
-              if test -f $f; then                                                              
+              if test -f $f; then
                 ln -sf $f $d/SRPMS/
               fi
             done
@@ -81,9 +84,19 @@ for vdist in centos/5.5 rhel/5.5; do
             mkdir -p $d/${arch}/Packages
             for f in $distdir/RPMS/${arch}/*.rpm $distdir/RPMS/noarch/*.rpm; do
               if test -f $f; then
-                pkgs_to_sign="${pkgs_to_sign} $f"
                 ln -sf $f $d/${arch}/Packages/
-                has_packages=true
+               if rpm -K $f|grep -q ' gpg' >/dev/null; then
+                 echo "Already signed $f"
+                else
+                 expect << __EOF
+                  spawn rpm --addsign $f
+expect -exact "Enter pass phrase: "
+send -- "\r"
+expect eof
+__EOF
+                  chgrp staff $f
+                  chmod g+w $f
+                fi
               fi
             done
           done
@@ -92,10 +105,6 @@ for vdist in centos/5.5 rhel/5.5; do
     done
   done
 done
-echo "Signing packages (default ID PPH is empty):"
-rpm --addsign ${pkgs_to_sign}
-chgrp staff ${pkgs_to_sign}
-chmod g+w ${pkgs_to_sign}
 echo "Updating repository meta:"
 for rdir in ${dirs_to_upd}; do
   echo "Section ${rdir}"