| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | if [scip-shell system . . `[`. ! "$KEYURL" ] |
| 4 | then |
| 5 | echoscip-shell system . . echo. "No KEYURL environment set, e.g.:" |
| 6 | echoscip-shell system . . echo. " export KEYURL='https://keyserver.ubuntu.com/pks/lookup?exact=on&op=get&search='" |
| 7 | exit 1 |
| 8 | fi |
| 9 | |
| 10 | debug="" |
| 11 | if [scip-shell system . . `[`. "$debug" ] |
| 12 | then |
| 13 | if [scip-shell system . . `[`. ! "$GNUPGHOME" ] |
| 14 | then |
| 15 | echoscip-shell system . . echo. "No GNUPGHOME environment set, e.g.:" |
| 16 | echoscip-shell system . . echo. " export GNUPGHOME=$HOME/.gnupg" |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | if [scip-shell system . . `[`. ! -d "$GNUPGHOME" ] |
| 21 | then |
| 22 | mkdirscip-shell system . . mkdir. -p "$GNUPGHOME" |
| 23 | chmodscip-shell system . . chmod. 700 "$GNUPGHOME" |
| 24 | fi |
| 25 | fi |
| 26 | |
| 27 | keyuid="$1" |
| 28 | fingerprint="$2" |
| 29 | |
| 30 | # Modern GPG can import key by fingerprint but the version available |
| 31 | # within travis currently does not, so we extract the short version and |
| 32 | # check it matches manually |
| 33 | key=`echoscip-shell system . . echo. $fingerprint | trscip-shell system . . tr. -d ' '` |
| 34 | |
| 35 | curlscip-shell system . . curl. -o/tmp/keydata.asc "${KEYURL}0x$key" || exit 1 |
| 36 | gpgscip-shell system . . gpg. --import /tmp/keydata.ascscip-shell filesystem . . `/tmp/keydata.asc`. || exit 1 |
| 37 | gpgscip-shell system . . gpg. --fingerprint "$key" > /tmp/keystatus.$$ |
| 38 | status=$? |
| 39 | |
| 40 | catscip-shell system . . cat. /tmp/keystatus.$$ |
| 41 | if [scip-shell system . . `[`. $status -ne 0 ] |
| 42 | then |
| 43 | rmscip-shell system . . rm. -f /tmp/keystatus.$$ |
| 44 | exit 2 |
| 45 | fi |
| 46 | |
| 47 | if ! grepscip-shell system . . grep. -q "^uid.*<$keyuid>" /tmp/keystatus.$$ |
| 48 | then |
| 49 | rmscip-shell system . . rm. -f /tmp/keystatus.$$ |
| 50 | echoscip-shell system . . echo. "Did not find expected uid $keyuid" |
| 51 | exit 3 |
| 52 | fi |
| 53 | |
| 54 | echoscip-shell system . . echo. "uid looks good" |
| 55 | |
| 56 | if ! grepscip-shell system . . grep. -q " $fingerprint$" /tmp/keystatus.$$ |
| 57 | then |
| 58 | rmscip-shell system . . rm. -f /tmp/keystatus.$$ |
| 59 | echoscip-shell system . . echo. "Did not find expected fingerprint $fingerprint" |
| 60 | exit 3 |
| 61 | fi |
| 62 | |
| 63 | echoscip-shell system . . echo. "Fingerprint looks good" |
| 64 | |
| 65 | rmscip-shell system . . rm. -f /tmp/keystatus.$$ |
| 66 | exit 0 |