]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-gpg.sh
tests: replace binary GPG keyrings with ASCII-armored keys
[thirdparty/git.git] / t / lib-gpg.sh
CommitLineData
37d3e859
JK
1#!/bin/sh
2
be194d53 3gpg_version=$(gpg --version 2>&1)
37d3e859
JK
4if test $? = 127; then
5 say "You do not seem to have gpg installed"
6else
7 # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19
8 # the gpg version 1.0.6 didn't parse trust packets correctly, so for
9 # that version, creation of signed tags using the generated key fails.
10 case "$gpg_version" in
11 'gpg (GnuPG) 1.0.6'*)
12 say "Your version of gpg (1.0.6) is too buggy for testing"
13 ;;
14 *)
15 # key generation info: gpg --homedir t/lib-gpg --gen-key
16 # Type DSA and Elgamal, size 2048 bits, no expiration date.
17 # Name and email: C O Mitter <committer@example.com>
18 # No password given, to enable non-interactive operation.
b41a36e6
CH
19 mkdir ./gpghome
20 chmod 0700 ./gpghome
37d3e859
JK
21 GNUPGHOME="$(pwd)/gpghome"
22 export GNUPGHOME
b41a36e6 23 gpg --homedir "${GNUPGHOME}" --import \
1e3eefbc 24 "$TEST_DIRECTORY"/lib-gpg/keyring.gpg
b41a36e6
CH
25 gpg --homedir "${GNUPGHOME}" --import-ownertrust \
26 "$TEST_DIRECTORY"/lib-gpg/ownertrust
37d3e859 27 test_set_prereq GPG
c0e0ed6e
CH
28 if echo | gpg --homedir "${GNUPGHOME}" -b --rfc1991 >/dev/null 2>&1
29 then
30 test_set_prereq RFC1991
31 fi
37d3e859
JK
32 ;;
33 esac
34fi
e2b23972
MG
35
36sanitize_pgp() {
37 perl -ne '
38 /^-----END PGP/ and $in_pgp = 0;
39 print unless $in_pgp;
40 /^-----BEGIN PGP/ and $in_pgp = 1;
41 '
42}