From efda6e25ec7f820b44d1646c4b85836648929b7e Mon Sep 17 00:00:00 2001 From: Pim Snel Date: Fri, 5 Jan 2018 14:05:57 +0100 Subject: [PATCH] Fix problems when gpg2 is installed next to gpg (#237) * implement fixes from https://stackoverflow.com/questions/44247308/blackbox-gpg-decrypt-fails-dont-know-ctb-00 * fix problems when working with gpg2 next to gpg. Add's readme section * fix anchor --- README.md | 14 ++++++++++++++ bin/_blackbox_common.sh | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c077dee..7094204 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Table of Contents - [Using BlackBox on Windows](#using-blackbox-on-windows) - [Using BlackBox without a repo](#using-blackbox-without-a-repo) - [Some Subversion gotchas](#some-subversion-gotchas) +- [Using Blackbox when gpg2 is installed next to gpg](#using-blackbox-when-gpg2-is-installed-next-to-gpg) - [How to submit bugs or ask questions?](#how-to-submit-bugs-or-ask-questions) - [Developer Info](#developer-info) - [Alternatives](#alternatives) @@ -704,6 +705,19 @@ The current implementation will store the blackbox in `/keyrings` at the root of This was originally written for git and supports a two-phase commit, in which `commit` is a local commit and "push" sends the change upstream to the version control server when something is registered or deregistered with the system. The current implementation will immediately `commit` a file (to the upstream subversion server) when you execute a `blackbox_*` command. +Using Blackbox when gpg2 is installed next to gpg +================================================= + +In some situations, team members or automated roles need to install gpg +2.x next to the system gpg version 1.x. to catch up with the teams gpg +version. On Ubuntu 16. you can ```apt-get install gnupg2``` which +installes the binary gpg2. If you want to use this gpg2 binany run every +blackbox command with GPG=gpg2. E.g.: + +``` +GPG=gpg2 blackbox_postdeploy +``` + How to submit bugs or ask questions? ==================================== diff --git a/bin/_blackbox_common.sh b/bin/_blackbox_common.sh index b174f6c..514f87c 100755 --- a/bin/_blackbox_common.sh +++ b/bin/_blackbox_common.sh @@ -213,8 +213,15 @@ function prepare_keychain() { # NB: We must export the keys to a format that can be imported. make_self_deleting_tempfile keyringasc export LANG="C.UTF-8" - $GPG --export --no-default-keyring --keyring "$(get_pubring_path)" >"$keyringasc" - $GPG --import "$keyringasc" 2>&1 | egrep -v 'not changed$' >&2 + + #if gpg2 is installed next to gpg like on ubuntu 16 + if [[ "$GPG" != "gpg2" ]]; then + $GPG --export --no-default-keyring --keyring "$(get_pubring_path)" >"$keyringasc" + $GPG --import "$keyringasc" 2>&1 | egrep -v 'not changed$' >&2 + else + $GPG --keyring "$(get_pubring_path)" --export | $GPG --import + fi + echo '========== Importing keychain: DONE' >&2 }