Skip to content

scripts: Fix portability issues in asmap-verify (BSD diff and GPG) - #76

Open
AlphaSparrow wants to merge 1 commit into
bitcoin-core:mainfrom
AlphaSparrow:fix-asmap-verify-portability
Open

AlphaSparrow wants to merge 1 commit into
bitcoin-core:mainfrom
AlphaSparrow:fix-asmap-verify-portability

Conversation

@AlphaSparrow

Copy link
Copy Markdown

This PR addresses two portability issues in asmap-verify to improve compatibility across environments:

  1. Replace GNU-specific diff --report-identical with diff -s
    The script currently uses the long flag --report-identical, which is not supported by the default BSD diff found on macOS and FreeBSD (resulting in an "illegal option" error). It has been replaced with the equivalent short flag -s, which is supported natively across BSD, macOS, and GNU environments while preserving the identical file output logging.

  2. Respect $GPG environment variable overrides
    Currently, asmap-verify hardcodes the gpg binary, which causes failures for users whose package managers (e.g., Homebrew) install GnuPG v2 as gpg2. This PR brings the logic into alignment with asmap-attest by defaulting to gpg but respecting the $GPG environment variable, safely parsing it for tool validation.

This fixes two bugs that prevent macOS users (and anyone using GPG v2) from successfully running the verification script:

- Uses the BSD/GNU-compatible short flag \-s\ instead of the GNU-only \diff --report-identical\ long flag, preserving identical file output logging without breaking on macOS.

- Sources the GPG binary from the environment variable (if set), safely stripping flags for validation and mimicking the logic in \�smap-attest\.
@fjahr
fjahr requested a review from jurraca October 8, 2026 15:23

@jurraca jurraca left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks. Tested and confirmed behavior on Linux.

Would've been better as two commits but not a big deal in this case.

Would like some Mac users to test and confirm.

Comment thread asmap-verify
Comment on lines +39 to +40
# shellcheck disable=SC2206
GPG_ARRAY=($GPG)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.shellcheck.net/wiki/SC2206 indicates this is just in order to avoid having to add quotes. Is there some reason quotes would not work here? Opting for the comment instead seems more verbose.

Suggested change
# shellcheck disable=SC2206
GPG_ARRAY=($GPG)
GPG_ARRAY=("$GPG")

Comment thread asmap-verify
Comment on lines +36 to +41
check_tools cat diff basename date

GPG=${GPG:-gpg}
# shellcheck disable=SC2206
GPG_ARRAY=($GPG)
check_tools "${GPG_ARRAY[0]}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sufficient:

Suggested change
check_tools cat diff basename date
GPG=${GPG:-gpg}
# shellcheck disable=SC2206
GPG_ARRAY=($GPG)
check_tools "${GPG_ARRAY[0]}"
GPG=${GPG:-gpg}
check_tools cat diff basename date "$GPG"

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants