Skip to content

[Scripts] gitian-build.py: ask brew for the coreutils prefix - #2991

Open
Liquid369 wants to merge 1 commit into
PIVX-Project:masterfrom
Liquid369:2026_gitian_build_brew_prefix
Open

Liquid369 wants to merge 1 commit into
PIVX-Project:masterfrom
Liquid369:2026_gitian_build_brew_prefix

Conversation

@Liquid369

Copy link
Copy Markdown
Member

contrib/gitian-build.py hardcodes /usr/local for Homebrew in three places. That is the
prefix on Intel only; on Apple Silicon Homebrew lives at /opt/homebrew, so the GNU
coreutils gnubin directory never reaches PATH.

The visible failure is the osslsigncode hash check:

echo '<sha256> inputs/osslsigncode-2.0.tar.gz' | sha256sum -c

Without GNU coreutils ahead of /sbin, sha256sum resolves to Apple's own build, which
takes the checksum list only as a file argument and answers a list on stdin with
usage: sha256sum [-bctwz] [files ...] and exit 1. check_call then raises before any
descriptor runs.

Measured on arm64, same command both ways:

PATH=/usr/local/opt/coreutils/libexec/gnubin:...        -> usage error, rc 1
PATH=$(brew --prefix)/opt/coreutils/libexec/gnubin:...   -> OK, rc 0

Asking brew --prefix falls back to /usr/local when brew is absent, so Intel hosts see
no change in behaviour.

The gsha256sum probe moves to shutil.which, which finds it under either prefix. The
old /usr/local/bin/gsha256sum test cannot match on arm64, so every run added
coreutils to the brew install list whether or not it was already there.

Testing

--build ran end to end on an arm64 host for v6.0.0-alpha.0, 1h23m30s, and the resulting
assertions matched another signer on all three OSes.

setup_darwin is not reached by --build, so the --setup path carries the same change
unexercised.

Two PATH prepends and the gsha256sum probe hardcoded /usr/local, which is
Homebrew's prefix on Intel only; on Apple Silicon it is /opt/homebrew. With that
gnubin directory absent from PATH, the osslsigncode hash check

    echo '<sha256> inputs/osslsigncode-2.0.tar.gz' | sha256sum -c

resolves sha256sum to Apple's /sbin build, which takes the checksum list only as
a file argument and answers a list on stdin with
"usage: sha256sum [-bctwz] [files ...]" and exit 1, so check_call raises before
any descriptor runs. Measured both ways on arm64: absent prefix gives the usage
error, brew's prefix gives "OK".

Asking brew keeps /usr/local when brew is missing, so Intel hosts see no change.

The probe moves to shutil.which, which finds gsha256sum under either prefix. The
old path test could not match on arm64, so every run added coreutils to the brew
install list whether or not it was present.

The --build path is the change that ran end to end on an arm64 host for
v6.0.0-alpha.0, 1h23m30s, matching another signer on all three OSes. setup_darwin
is not reached by --build, so --setup stays unverified.
@Liquid369
Liquid369 force-pushed the 2026_gitian_build_brew_prefix branch from cfd59a6 to 26da275 Compare November 26, 2026 05:04
@Fuzzbawls Fuzzbawls added this to the 6.0.0 milestone Nov 26, 2026
@Fuzzbawls Fuzzbawls changed the title [Build] gitian-build.py: ask brew for the coreutils prefix [Scripts] gitian-build.py: ask brew for the coreutils prefix Nov 26, 2026

@Fuzzbawls Fuzzbawls 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.

utACK 26da275

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants