From fe8d50639af71c7e7f8ffec1a8568180e5338a51 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 15:13:30 -0700 Subject: Fetch and check git with what the system has --- Makefile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 7d38fde..4b3b59c 100644 --- a/Makefile +++ b/Makefile @@ -134,14 +134,25 @@ cleanall: clean @if test -e $(GITDIR)/Makefile; then $(MAKE) -C $(GITDIR) clean; fi # The tarball is checked against its sum before anything is unpacked from it. -# An older macOS has no sha256sum, but its shasum reads the same format. +# Each system ships its own fetcher and sum tool (curl or wget on Linux and +# macOS, fetch on FreeBSD, ftp on OpenBSD and NetBSD, sha256 on the BSDs), so +# the first one present is used, and xz is piped to tar for a tar that cannot +# read it, as OpenBSD's cannot. .PHONY: get-git get-git: mkdir -p $(dir $(GITDIR)) - curl -fL -o $(GIT_TARBALL) $(GIT_URL) - @if command -v sha256sum >/dev/null; then sum=sha256sum; else sum='shasum -a 256'; fi; \ - echo '$(GIT_SHA256) $(GIT_TARBALL)' | $$sum -c - || { $(RM) $(GIT_TARBALL); exit 1; } - tar -xJf $(GIT_TARBALL) && rm -rf $(GITDIR) && mv git-$(GIT_VERSION) $(GITDIR) + @if command -v curl >/dev/null; then curl -fL -o $(GIT_TARBALL) $(GIT_URL); \ + elif command -v wget >/dev/null; then wget -O $(GIT_TARBALL) $(GIT_URL); \ + elif command -v fetch >/dev/null; then fetch -o $(GIT_TARBALL) $(GIT_URL); \ + else ftp -o $(GIT_TARBALL) $(GIT_URL); fi + @if command -v sha256sum >/dev/null; then sum=$$(sha256sum $(GIT_TARBALL)); \ + elif command -v shasum >/dev/null; then sum=$$(shasum -a 256 $(GIT_TARBALL)); \ + elif command -v sha256 >/dev/null; then sum=$$(sha256 -q $(GIT_TARBALL)); \ + else sum=$$(openssl dgst -sha256 -r $(GIT_TARBALL)); fi; \ + test "$${sum%% *}" = '$(GIT_SHA256)' || \ + { echo 'get-git: $(GIT_TARBALL) does not match its sum' >&2; $(RM) $(GIT_TARBALL); exit 1; } + @if command -v xz >/dev/null; then xz -dc $(GIT_TARBALL) | tar -xf -; else tar -xJf $(GIT_TARBALL); fi + rm -rf $(GITDIR) && mv git-$(GIT_VERSION) $(GITDIR) $(RM) $(GIT_TARBALL) .PHONY: tags -- cgit