Skip to content

Allow manual GIT_BUILT_FROM_COMMIT specification for installer #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

vdye
Copy link
Collaborator

@vdye vdye commented Dec 2, 2021

Related: microsoft/git#472

Changes

  • Allow specification of GIT_BUILT_FROM_COMMIT as make variable when building the MacOS installer package
  • Add commit hash to installer build & test step for printing git version --build-options

Testing

@derrickstolee
Copy link
Owner

Related: microsoft/git#472

Changes

  • Allow specification of GIT_BUILT_FROM_COMMIT as make variable when building the MacOS installer package
  • Add

I feel like maybe you paused writing here, then forgot to resume?

Testing

Excellent!

sudo installer -verbose -pkg $pkgpath -target /

# Show build options
git version --build-options
Copy link
Owner

Choose a reason for hiding this comment

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

We will need to manually verify this output, but that's fine.

Copy link
Collaborator

Choose a reason for hiding this comment

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

couldn't we automate this? Have the build step write an additional artifact with the OID and then test it here.
Might not be worth the trouble (you know my love of all things yml...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes! Should be pretty straightforward to implement, and it makes it clearer when something goes wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed, you can make it an output variable. It is slightly convoluted because you will have to have two output variables (the test-install job can only access the outputs of another job, not of another job's step), see e.g. https://github.com/git/git/blob/v2.34.1/.github/workflows/main.yml#L36, https://github.com/git/git/blob/v2.34.1/.github/workflows/main.yml#L11-L12, and https://github.com/git/git/blob/v2.34.1/.github/workflows/main.yml#L81.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It took a bit of experimentation, but this is now working!

@vdye
Copy link
Collaborator Author

vdye commented Dec 2, 2021

Related: microsoft/git#472

Changes

  • Allow specification of GIT_BUILT_FROM_COMMIT as make variable when building the MacOS installer package
  • Add

I feel like maybe you paused writing here, then forgot to resume?

Sorry about that, description updated!

Makefile Outdated
@@ -63,7 +64,7 @@ XML_CATALOG_FILES=$(shell bin/find-file /usr/local/etc/xml/catalog)
BUILD_CODE := intel-$(ARCH_CODE)-$(OSX_CODE)
BUILD_DIR := build/$(BUILD_CODE)
DESTDIR := $(PWD)/stage/git-$(BUILD_CODE)-$(VERSION)
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)
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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wondering if we should have DQuotes around the new value. (and maybe the $(GIT_PREFIX) too.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll try it and, assuming nothing weird happens (like the quotes showing up in git version --build-options), update this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Didn't see any issues - updated!

Use GIT_BUILT_FROM_COMMIT specified as argument to `make` when building
`git`. By default, the value is empty.

Signed-off-by: Victoria Dye <[email protected]>
@vdye vdye force-pushed the bugfix/macos-build-options branch 3 times, most recently from 347fbab to 58b6593 Compare December 3, 2021 16:30
Set `GIT_BUILT_FROM_COMMIT` in the `osx-installer.yml` workflow from the
git repository cloned for build. Additionally, install the built installer
and verify the built-from commit hash appears properly in
`git version --build-options`.

Signed-off-by: Victoria Dye <[email protected]>
@vdye vdye force-pushed the bugfix/macos-build-options branch from 58b6593 to 09b51b4 Compare December 3, 2021 16:40
if (find ./stage/git-*/usr/local/git/bin/scalar); then
echo "::set-output name=with_scalar::true"
else
echo "::set-output name=with_scalar::false"
fi

# Set build commit hash
echo "::set-output name=commit_hash::$(git -C git rev-parse -q --verify HEAD 2>/dev/null)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure that this is the commit ID we want git config --build-options to show? I had expected something like this appended after line 85:

echo "::set-output name=commit_hash::$GIT_BUILT_FROM_COMMIT"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is mostly an attempt to keep the sources of the "actual" and "expected" commit hash values as separate as possible. By pulling the "expected" commit hash directly from git rev-parse, the validation later will confirm both that 1) the dist archive was built with the correct commit hash, and 2) that commit hash was properly embedded into the resulting installer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair enough!

@@ -55,6 +55,7 @@ LDFLAGS := $(TARGET_FLAGS) $(ARCH_FLAGS_${ARCH_CODE})
BAK_FOLDER := $(shell date +%s)
PREFIX := /usr/local
GIT_PREFIX := $(PREFIX)/git
GIT_BUILT_FROM_COMMIT :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does that really work? I thought that := overrides whatever was specified on the command-line, and we would need ?= here. But then, any uninitialized variable VAR would see $(VAR) interpolated to the empty string, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does! According to the documentation, a command line-defined variable overrides all simply (:=) and recursively (=) expanded assignments. As a result, this initializes GIT_BUILT_FROM_COMMIT as an empty string only if it isn't specified on the command line.

@derrickstolee derrickstolee merged commit 7928044 into derrickstolee:master Dec 6, 2021
@vdye vdye deleted the bugfix/macos-build-options branch December 6, 2021 16:05
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.

4 participants