Skip to content

Commit a364d11

Browse files
vdyemjcheetham
authored andcommitted
Merge pull request #472 from vdye/ms/macos-build-options
Fixes for MacOS release build & build options
2 parents f52a15d + 4803709 commit a364d11

File tree

4 files changed

+89
-6
lines changed

4 files changed

+89
-6
lines changed

.github/macos-installer/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ GIT_PREFIX := $(PREFIX)/git
2121
BUILD_DIR := $(GITHUB_WORKSPACE)/payload
2222
DESTDIR := $(PWD)/stage/git-$(ARCH_UNIV)-$(VERSION)
2323
ARTIFACTDIR := build-artifacts
24-
SUBMAKE := $(MAKE) C_INCLUDE_PATH="$(C_INCLUDE_PATH)" CPLUS_INCLUDE_PATH="$(CPLUS_INCLUDE_PATH)" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" TARGET_FLAGS="$(TARGET_FLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" NO_GETTEXT=1 NO_DARWIN_PORTS=1 prefix=$(GIT_PREFIX) DESTDIR=$(DESTDIR)
24+
SUBMAKE := $(MAKE) C_INCLUDE_PATH="$(C_INCLUDE_PATH)" CPLUS_INCLUDE_PATH="$(CPLUS_INCLUDE_PATH)" LD_LIBRARY_PATH="$(LD_LIBRARY_PATH)" TARGET_FLAGS="$(TARGET_FLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" NO_GETTEXT=1 NO_DARWIN_PORTS=1 prefix=$(GIT_PREFIX) GIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)" DESTDIR=$(DESTDIR)
2525
CORES := $(shell bash -c "sysctl hw.ncpu | awk '{print \$$2}'")
2626

2727
# Guard against environment variables

.github/workflows/build-git-installers.yml

+71
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ jobs:
430430
431431
make -C git -j$(sysctl -n hw.physicalcpu) GIT-VERSION-FILE dist dist-doc
432432
433+
export GIT_BUILT_FROM_COMMIT=$(gunzip -c git/git-$VERSION.tar.gz | git get-tar-commit-id) ||
434+
die "Could not determine commit for build"
435+
433436
# Extract tarballs
434437
mkdir payload manpages
435438
tar -xvf git/git-$VERSION.tar.gz -C payload
@@ -592,12 +595,80 @@ jobs:
592595
*.deb
593596
# End build and sign Debian package
594597

598+
# Validate installers
599+
validate-installers:
600+
name: Validate installers
601+
strategy:
602+
matrix:
603+
component:
604+
- os: ubuntu-latest
605+
artifact: linux-artifacts
606+
command: git
607+
- os: macos-latest-xl-arm64
608+
artifact: macos-artifacts
609+
command: git
610+
- os: macos-latest
611+
artifact: macos-artifacts
612+
command: git
613+
- os: windows-latest
614+
artifact: win-installer-x86_64
615+
command: $PROGRAMFILES\Git\cmd\git.exe
616+
runs-on: ${{ matrix.component.os }}
617+
needs: [prereqs, windows_artifacts, create-macos-artifacts, create-linux-artifacts]
618+
steps:
619+
- name: Download artifacts
620+
uses: actions/download-artifact@v3
621+
with:
622+
name: ${{ matrix.component.artifact }}
623+
624+
- name: Install Windows
625+
if: contains(matrix.component.os, 'windows')
626+
shell: pwsh
627+
run: |
628+
$exePath = Get-ChildItem -Path ./*.exe | %{$_.FullName}
629+
Start-Process -Wait -FilePath "$exePath" -ArgumentList "/SILENT /VERYSILENT /NORESTART /SUPPRESSMSGBOXES /ALLOWDOWNGRADE=1"
630+
631+
- name: Install Linux
632+
if: contains(matrix.component.os, 'ubuntu')
633+
run: |
634+
debpath=$(find ./*.deb)
635+
sudo apt install $debpath
636+
637+
- name: Install macOS
638+
if: contains(matrix.component.os, 'macos')
639+
run: |
640+
# avoid letting Homebrew's `git` in `/opt/homebrew/bin` override `/usr/local/bin/git`
641+
arch="$(uname -m)"
642+
test arm64 != "$arch" ||
643+
brew uninstall git
644+
645+
pkgpath=$(find ./*universal*.pkg)
646+
sudo installer -pkg $pkgpath -target /
647+
648+
- name: Validate
649+
shell: bash
650+
run: |
651+
"${{ matrix.component.command }}" --version | sed 's/git version //' >actual
652+
echo ${{ needs.prereqs.outputs.tag_version }} >expect
653+
cmp expect actual || exit 1
654+
655+
- name: Validate universal binary CPU architecture
656+
if: contains(matrix.component.os, 'macos')
657+
shell: bash
658+
run: |
659+
set -ex
660+
git version --build-options >actual
661+
cat actual
662+
grep "cpu: $(uname -m)" actual
663+
# End validate installers
664+
595665
create-github-release:
596666
runs-on: ubuntu-latest
597667
permissions:
598668
contents: write
599669
id-token: write # required for Azure login via OIDC
600670
needs:
671+
- validate-installers
601672
- create-linux-artifacts
602673
- create-macos-artifacts
603674
- windows_artifacts

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/fuzz_corpora
22
/GIT-BUILD-DIR
33
/GIT-BUILD-OPTIONS
4+
/GIT-BUILT-FROM-COMMIT
45
/GIT-CFLAGS
56
/GIT-LDFLAGS
67
/GIT-PREFIX

Makefile

+16-5
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,10 @@ include shared.mak
321321
# Define GIT_USER_AGENT if you want to change how git identifies itself during
322322
# network interactions. The default is "git/$(GIT_VERSION)".
323323
#
324+
# Define GIT_BUILT_FROM_COMMIT if you want to force the commit hash identified
325+
# in 'git version --build-options' to a specific value. The default is the
326+
# commit hash of the current HEAD.
327+
#
324328
# Define DEFAULT_HELP_FORMAT to "man", "info" or "html"
325329
# (defaults to "man") if you want to have a different default when
326330
# "git help" is called without a parameter specifying the format.
@@ -2385,6 +2389,15 @@ GIT-USER-AGENT: FORCE
23852389
echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
23862390
fi
23872391

2392+
GIT_BUILT_FROM_COMMIT = $(eval GIT_BUILT_FROM_COMMIT := $$(shell \
2393+
GIT_CEILING_DIRECTORIES="$$(CURDIR)/.." \
2394+
git rev-parse -q --verify HEAD 2>/dev/null))$(GIT_BUILT_FROM_COMMIT)
2395+
GIT-BUILT-FROM-COMMIT: FORCE
2396+
@if test x'$(GIT_BUILT_FROM_COMMIT)' != x"`cat GIT-BUILT-FROM-COMMIT 2>/dev/null`" ; then \
2397+
echo >&2 " * new built-from commit"; \
2398+
echo '$(GIT_BUILT_FROM_COMMIT)' >GIT-BUILT-FROM-COMMIT; \
2399+
fi
2400+
23882401
ifdef DEFAULT_HELP_FORMAT
23892402
BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
23902403
endif
@@ -2522,13 +2535,11 @@ PAGER_ENV_CQ_SQ = $(subst ','\'',$(PAGER_ENV_CQ))
25222535
pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \
25232536
-DPAGER_ENV='$(PAGER_ENV_CQ_SQ)'
25242537

2525-
version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
2538+
version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT GIT-BUILT-FROM-COMMIT
25262539
version.sp version.s version.o: EXTRA_CPPFLAGS = \
25272540
'-DGIT_VERSION="$(GIT_VERSION)"' \
25282541
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)' \
2529-
'-DGIT_BUILT_FROM_COMMIT="$(shell \
2530-
GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
2531-
git rev-parse -q --verify HEAD 2>/dev/null)"'
2542+
'-DGIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)"'
25322543

25332544
$(BUILT_INS): git$X
25342545
$(QUIET_BUILT_IN)$(RM) $@ && \
@@ -3699,7 +3710,7 @@ dist: git-archive$(X) configure
36993710
@$(MAKE) -C git-gui TARDIR=../.dist-tmp-dir/git-gui dist-version
37003711
./git-archive --format=tar \
37013712
$(GIT_ARCHIVE_EXTRA_FILES) \
3702-
--prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
3713+
--prefix=$(GIT_TARNAME)/ HEAD > $(GIT_TARNAME).tar
37033714
@$(RM) -r .dist-tmp-dir
37043715
gzip -f -9 $(GIT_TARNAME).tar
37053716

0 commit comments

Comments
 (0)