Skip to content

Commit 25fbe34

Browse files
vdyedscho
authored andcommitted
Merge pull request #472 from vdye/ms/macos-build-options
Fixes for MacOS release build & build options
2 parents 4fe5a88 + 3e282e7 commit 25fbe34

File tree

4 files changed

+89
-6
lines changed

4 files changed

+89
-6
lines changed

.github/macos-installer/Makefile

Lines changed: 1 addition & 1 deletion
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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,9 @@ jobs:
427427
428428
make -C git -j$(sysctl -n hw.physicalcpu) GIT-VERSION-FILE dist dist-doc
429429
430+
export GIT_BUILT_FROM_COMMIT=$(gunzip -c git/git-$VERSION.tar.gz | git get-tar-commit-id) ||
431+
die "Could not determine commit for build"
432+
430433
# Extract tarballs
431434
mkdir payload manpages
432435
tar -xvf git/git-$VERSION.tar.gz -C payload
@@ -587,11 +590,79 @@ jobs:
587590
*.deb
588591
# End build and sign Debian package
589592

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

.gitignore

Lines changed: 1 addition & 0 deletions
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

Lines changed: 16 additions & 5 deletions
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.
@@ -2390,6 +2394,15 @@ GIT-USER-AGENT: FORCE
23902394
echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
23912395
fi
23922396

2397+
GIT_BUILT_FROM_COMMIT = $(eval GIT_BUILT_FROM_COMMIT := $$(shell \
2398+
GIT_CEILING_DIRECTORIES="$$(CURDIR)/.." \
2399+
git rev-parse -q --verify HEAD 2>/dev/null))$(GIT_BUILT_FROM_COMMIT)
2400+
GIT-BUILT-FROM-COMMIT: FORCE
2401+
@if test x'$(GIT_BUILT_FROM_COMMIT)' != x"`cat GIT-BUILT-FROM-COMMIT 2>/dev/null`" ; then \
2402+
echo >&2 " * new built-from commit"; \
2403+
echo '$(GIT_BUILT_FROM_COMMIT)' >GIT-BUILT-FROM-COMMIT; \
2404+
fi
2405+
23932406
ifdef DEFAULT_HELP_FORMAT
23942407
BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"'
23952408
endif
@@ -2504,13 +2517,11 @@ PAGER_ENV_CQ_SQ = $(subst ','\'',$(PAGER_ENV_CQ))
25042517
pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \
25052518
-DPAGER_ENV='$(PAGER_ENV_CQ_SQ)'
25062519

2507-
version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
2520+
version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT GIT-BUILT-FROM-COMMIT
25082521
version.sp version.s version.o: EXTRA_CPPFLAGS = \
25092522
'-DGIT_VERSION="$(GIT_VERSION)"' \
25102523
'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)' \
2511-
'-DGIT_BUILT_FROM_COMMIT="$(shell \
2512-
GIT_CEILING_DIRECTORIES="$(CURDIR)/.." \
2513-
git rev-parse -q --verify HEAD 2>/dev/null)"'
2524+
'-DGIT_BUILT_FROM_COMMIT="$(GIT_BUILT_FROM_COMMIT)"'
25142525

25152526
$(BUILT_INS): git$X
25162527
$(QUIET_BUILT_IN)$(RM) $@ && \
@@ -3685,7 +3696,7 @@ dist: git-archive$(X) configure
36853696
@$(MAKE) -C git-gui TARDIR=../.dist-tmp-dir/git-gui dist-version
36863697
./git-archive --format=tar \
36873698
$(GIT_ARCHIVE_EXTRA_FILES) \
3688-
--prefix=$(GIT_TARNAME)/ HEAD^{tree} > $(GIT_TARNAME).tar
3699+
--prefix=$(GIT_TARNAME)/ HEAD > $(GIT_TARNAME).tar
36893700
@$(RM) -r .dist-tmp-dir
36903701
gzip -f -9 $(GIT_TARNAME).tar
36913702

0 commit comments

Comments
 (0)