| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | export LC_ALL=C |
| 3 | set -e -o pipefail |
| 4 | |
| 5 | # Source the common prelude, which: |
| 6 | # 1. Checks if we're at the top directory of the Feather Wallet repository |
| 7 | # 2. Defines a few common functions and variables |
| 8 | # |
| 9 | # shellcheck source=libexec/prelude.bash |
| 10 | source "$(dirnamescip-shell system . . dirname. "${BASH_SOURCE[0]}")/libexec/prelude.bash" |
| 11 | |
| 12 | |
| 13 | ################### |
| 14 | ## Sanity Checks ## |
| 15 | ################### |
| 16 | |
| 17 | ################ |
| 18 | # Required non-builtin commands should be invokable |
| 19 | ################ |
| 20 | |
| 21 | check_tools cat diff gpg |
| 22 | |
| 23 | ################ |
| 24 | # Required env vars should be non-empty |
| 25 | ################ |
| 26 | |
| 27 | cmd_usagescip-shell shell feather-wallet 2.8.1+dfsg-6 cmd_usage().() { |
| 28 | catscip-shell system . . cat. <<EOF |
| 29 | Synopsis: |
| 30 | |
| 31 | env GUIX_SIGS_REPO=<path/to/feather-sigs> [ SIGNER=<signer> ] ./contrib/guix/guix-verify |
| 32 | |
| 33 | Example overriding signer's manifest to use as base |
| 34 | |
| 35 | env GUIX_SIGS_REPO=/home/user/feather-sigs SIGNER=achow101 ./contrib/guix/guix-verify |
| 36 | |
| 37 | EOF |
| 38 | } |
| 39 | |
| 40 | ############## |
| 41 | ## Verify ## |
| 42 | ############## |
| 43 | |
| 44 | OUTSIGDIR_BASE="external/feather-sigs/${VERSION}" |
| 45 | echoscip-shell system . . echo. "Looking for signature directories in '${OUTSIGDIR_BASE}'" |
| 46 | echoscip-shell system . . echo. "" |
| 47 | |
| 48 | # Usage: verify compare_manifest current_manifest |
| 49 | verifyscip-shell shell feather-wallet 2.8.1+dfsg-6 verify().() { |
| 50 | local compare_manifest="$1" |
| 51 | local current_manifest="$2" |
| 52 | if ! gpgscip-shell system . . gpg. --quiet --batch --verify "$current_manifest".asc "$current_manifest" 1>&2; then |
| 53 | echoscip-shell system . . echo. "ERR: Failed to verify GPG signature in '${current_manifest}'" |
| 54 | echoscip-shell system . . echo. "" |
| 55 | echoscip-shell system . . echo. "Hint: Either the signature is invalid or the public key is missing" |
| 56 | echoscip-shell system . . echo. "" |
| 57 | failure=1 |
| 58 | elif ! diffscip-shell system . . diff. --report-identical "$compare_manifest" "$current_manifest" 1>&2; then |
| 59 | echoscip-shell system . . echo. "ERR: The SHA256SUMS attestation in these two directories differ:" |
| 60 | echoscip-shell system . . echo. " '${compare_manifest}'" |
| 61 | echoscip-shell system . . echo. " '${current_manifest}'" |
| 62 | echoscip-shell system . . echo. "" |
| 63 | failure=1 |
| 64 | else |
| 65 | echoscip-shell system . . echo. "Verified: '${current_manifest}'" |
| 66 | echoscip-shell system . . echo. "" |
| 67 | fi |
| 68 | } |
| 69 | |
| 70 | shopt -s nullglob |
| 71 | all_all=( "$OUTSIGDIR_BASE"/*/all.SHA256SUMS ) |
| 72 | shopt -u nullglob |
| 73 | |
| 74 | echoscip-shell system . . echo. "--------------------" |
| 75 | echoscip-shell system . . echo. "" |
| 76 | if (( ${#all_all[@]} )); then |
| 77 | compare_all="${all_all[0]}" |
| 78 | if [[ -n "$SIGNER" ]]; then |
| 79 | signer_all="$OUTSIGDIR_BASE/$SIGNER/all.SHA256SUMS" |
| 80 | if [[ -f "$signer_all" ]]; then |
| 81 | echoscip-shell system . . echo. "Using $SIGNER's manifest as the base to compare against" |
| 82 | compare_all="$signer_all" |
| 83 | else |
| 84 | echoscip-shell system . . echo. "Unable to find $SIGNER's manifest, using the first one found" |
| 85 | fi |
| 86 | else |
| 87 | echoscip-shell system . . echo. "No SIGNER provided, using the first manifest found" |
| 88 | fi |
| 89 | |
| 90 | for current_manifest in "${all_all[@]}"; do |
| 91 | verifyscip-shell shell feather-wallet 2.8.1+dfsg-6 verify(). "$compare_all" "$current_manifest" |
| 92 | done |
| 93 | |
| 94 | echoscip-shell system . . echo. "DONE: Checking output signatures for all.SHA256SUMS" |
| 95 | echoscip-shell system . . echo. "" |
| 96 | else |
| 97 | echoscip-shell system . . echo. "WARN: No signature directories with all.SHA256SUMS found" |
| 98 | echoscip-shell system . . echo. "" |
| 99 | fi |
| 100 | |
| 101 | echoscip-shell system . . echo. "====================" |
| 102 | echoscip-shell system . . echo. "" |
| 103 | if (( ${#all_all[@]} == 0 )); then |
| 104 | echoscip-shell system . . echo. "ERR: Unable to perform any verifications as no signature directories" |
| 105 | echoscip-shell system . . echo. " were found" |
| 106 | echoscip-shell system . . echo. "" |
| 107 | exit 1 |
| 108 | fi |
| 109 | |
| 110 | if [scip-shell system . . `[`. -n "$failure" ]; then |
| 111 | exit 1 |
| 112 | fi |