]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
attempting to fix 49
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 7 Jan 2009 20:31:53 +0000 (20:31 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 7 Jan 2009 20:31:53 +0000 (20:31 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@739 04377dda-e619-0410-9926-eae83683ac58

trunk/lib/common.sh
trunk/src/createpkg

index d583a92c19f5aa9a11124e9ad2602ef8c662dad4..d61dbd9088a998fc4bbae47532f15c0b1db5902d 100644 (file)
@@ -1131,18 +1131,22 @@ function gen_meta {
 
 function repo_gpg_key {
 
-  # usage: repo_gpg_key <folder>
+  # usage: repo_gpg_key <folder> [update]
 
-  local folder="$1" tmp_gpg_folder
+  local folder="$1" update="$2" tmp_gpg_folder
 
   if [ -z "$SIGN_KEYID" ]; then
     echo "GPG-KEY checking failed, no sign key id set."
     return 1
   fi
 
+  if [ "$update" == "--update" ]; then
+    update=true
+  fi
+
   if [ $SIGN_PACKAGES -eq $on ]; then
     if [ -f "$folder/GPG-KEY" ]; then
-      if ! gpg --with-colons < $folder/GPG-KEY | cut -d : -f 5 | grep -q -e "$SIGN_KEYID$"; then
+      if $update || ! gpg --with-colons < $folder/GPG-KEY | cut -d : -f 5 | grep -q -e "$SIGN_KEYID$"; then
         echo "Adding OpenPGP key id $SIGN_KEYID to $folder/GPG-KEY file..."
 
         tmp_gpg_folder="`mktemp -d $TMP/tmp_gpg_folder.XXXXXX`"
@@ -1455,6 +1459,26 @@ function check_gnupg {
 
 }
 
+function get_sign_packages_user {
+
+  # get sign package user
+  # usage: get_sign_package_user
+
+  check_gnupg $SIGN_PACKAGES_USER
+
+  if [ ! -z "$SIGN_PACKAGES_KEYID" ]; then
+    SIGN_KEYID="$SIGN_PACKAGES_KEYID"
+  else
+    if [ ! -z "$SIGN_PACKAGES_USER" ]; then
+      SIGN_KEYID="`su $SIGN_PACKAGES_USER -c \
+      "gpg --list-secret-keys --with-colons | grep ^sec | head -n 1 | cut -d : -f 5 | sed 's/^.*\(.\{8\}\)$/\1/'"`"
+    else
+      SIGN_KEYID="`gpg --list-secret-keys --with-colons | grep ^sec | head -n 1 | cut -d : -f 5 | sed 's/^.*\(.\{8\}\)$/\1/'`"
+    fi
+  fi
+
+}
+
 function rmd160sum {
 
   # computes RIPEMD-160 message digest
index c1b2c772773f68890cbdd2d835259637bbe96e10..7b23f48cef494a3a0f50e1193062e1888a8dd109 100644 (file)
@@ -57,6 +57,8 @@ ${red}DESCRIPTION${normal}
                 commit changes to binary packages' repository
             ${red}--status${normal}
                 check binary packages' svn repository status
+            ${red}--update-keyring${normal}
+                update GPG-KEY from binary repositories
             ${red}-h${normal}, ${red}--help${normal}
                 show this help
 
@@ -589,6 +591,14 @@ case $1 in
     repository_status
     exit $EXIT_CODE
   ;;
+  '--update-keyring')
+    get_sign_packages_user
+    repo_gpg_key $PACKAGES_DIR --update
+    if [ $PACKAGES_REPOS_NOARCH -eq $on ]; then
+      repo_gpg_key $NOARCH_DIR --update
+    fi
+    exit $EXIT_CODE
+  ;;
   *)
     if [ "${1:0:1}" != "-" ]; then
       PACKAGE="$1"
@@ -722,18 +732,7 @@ if [ $SIGN_PACKAGES -eq $on ]; then
 
   echo "Signing package..."
 
-  check_gnupg $SIGN_PACKAGES_USER
-
-  if [ ! -z "$SIGN_PACKAGES_KEYID" ]; then
-    SIGN_KEYID="$SIGN_PACKAGES_KEYID"
-  else
-    if [ ! -z "$SIGN_PACKAGES_USER" ]; then
-      SIGN_KEYID="`su $SIGN_PACKAGES_USER -c \
-      "gpg --list-secret-keys --with-colons | grep ^sec | head -n 1 | cut -d : -f 5 | sed 's/^.*\(.\{8\}\)$/\1/'"`"
-    else
-      SIGN_KEYID="`gpg --list-secret-keys --with-colons | grep ^sec | head -n 1 | cut -d : -f 5 | sed 's/^.*\(.\{8\}\)$/\1/'`"
-    fi
-  fi
+  get_sign_packages_user
 
   if [ ! -z "$SIGN_PACKAGES_USER" ]; then
     tmp_sign_folder="`mktemp -d $TMP/createpkg_sign.XXXXXX`"