[X2Go-Commits] [buildscripts] 01/01: bin/createsusetagsrepo: fix up repository generation.

git-admin at x2go.org git-admin at x2go.org
Sun Dec 4 08:34:59 CET 2016


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository buildscripts.

commit 4859c0eef0aa277a72f79dd091db6c186b1324d8
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sun Dec 4 08:31:26 2016 +0100

    bin/createsusetagsrepo: fix up repository generation.
    
    Split up RPM GPG key generation and metadata signing. Export key, then
    create checksums and only sign metadata after all files have been
    modified.
---
 bin/createsusetagsrepo |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/bin/createsusetagsrepo b/bin/createsusetagsrepo
index b15f599..06a2e73 100755
--- a/bin/createsusetagsrepo
+++ b/bin/createsusetagsrepo
@@ -114,13 +114,10 @@ create_directory () {
   find "${prefix}" -print | sed -e "s#${prefix}##" | grep -vE '^$' | grep -v "^${file}$" > "${prefix}/${file}"
 }
 
-sign_metadata () {
-  rm -f -- 'content.asc' && gpg -a -u "${gpg_key}" --detach-sign 'content'
-  test -e 'content.key' || gpg -a --output 'content.key' --export "${gpg_key}"
-
+export_gpg_key () {
   typeset rpm_key_file_name="gpg-pubkey-"
   typeset key_id_short=""
-  key_id_short="$(gpg --keyid-format=short 'content.key' | grep -Em 1 '^pub' | sed -e '/^pub.*\/\([0-9a-fA-F]\{8\}\) .*$/!d;s//\1/')"
+  key_id_short="$(gpg --keyid-format=short --list-public-keys "${gpg_key}" | grep -Em 1 '^pub' | sed -e '/^pub.*\/\([0-9a-fA-F]\{8\}\) .*$/!d;s//\1/')"
 
   if [ -z "${key_id_short}" ]; then
     echo "Unable to get the short key ID of pub key ${gpg_key}." >&2
@@ -130,7 +127,7 @@ sign_metadata () {
   key_id_short="$(tr '[:upper:]' '[:lower:]' <<< "${key_id_short}")"
 
   typeset key_creation_date=""
-  key_creation_date="$(gpg --list-packets --verbose < 'content.key' 2>/dev/null | grep -Em 1 'created [0-9][0-9]*,' | sed -e '/.*created \([0-9][0-9]*\), .*/!d;s//\1/')"
+  key_creation_date="$(gpg -a --export "${gpg_key}" | gpg --list-packets --verbose 2>/dev/null | grep -Em 1 'created [0-9][0-9]*,' | sed -e '/.*created \([0-9][0-9]*\), .*/!d;s//\1/')"
 
   if [ -z "${key_creation_date}" ]; then
     echo "Unable to get the key creation date of pub key ${gpg_key}." >&2
@@ -148,7 +145,7 @@ sign_metadata () {
 
   rpm_key_file_name="${rpm_key_file_name}${key_id_short}-${key_creation_date}.asc"
 
-  test -e "${rpm_key_file_name}" || cp -av 'content.key' "${rpm_key_file_name}"
+  test -e "${rpm_key_file_name}" || gpg -a --output "${rpm_key_file_name}" --export "${gpg_key}"
 }
 
 generate_content_hashes () {
@@ -179,6 +176,11 @@ generate_content_hashes () {
   done
 }
 
+sign_metadata () {
+  rm -f -- 'content.asc' && gpg -a -u "${gpg_key}" --detach-sign 'content'
+  test -e 'content.key' || gpg -a --output 'content.key' --export "${gpg_key}"
+}
+
 set -e
 
 repo_top_dir="${1}"
@@ -208,9 +210,11 @@ create_descr
 
 create_directory
 
-# Sign repository metadata, otherwise zypper will fail to refresh the repository.
-sign_metadata
+export_gpg_key
 
 generate_content_hashes
 
+# Sign repository metadata, otherwise zypper will fail to refresh the repository.
+sign_metadata
+
 exit "0"

--
Alioth's /srv/git/code.x2go.org/buildscripts.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/buildscripts.git


More information about the x2go-commits mailing list