Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-10-28 11:01:05 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-11-30 15:24:45 +0300
commit8600e1c08e37c984b5c7354df00e47af1ada09f3 (patch)
treeb78e75f3f6435afb8d076a9c6b4a14d18aa0a4c0 /Makefile
parente7cd194b025570a8cb933c89e3895cf07f932561 (diff)
Makefile: Allow building Gitaly with bundled Git binaries
In order to allow the use of feature flags to toggle different Git versions at runtime, Gitaly needs to take much more ownership of binaries such that it knows where to find the Git binaries without having the admin to always set up different paths whenever there are two different versions of Git. As a first step towards taking more ownership, this commit introduces the new `WITH_BUNDLED_GIT` variable to our Makefile: if set, we will build and install required Git binaries. In order to not accidentally overwrite any preexisting binaries, the required binaries all have a "gitaly-" prefix. Note that ideally, we'd want to install only the "git" binary, which nowadays contains almost all of the functionality required by us. One exception though is cURL-based remote helpers, which are still split out into a separate binary "git-remote-http". Given that we do interact with HTTP-based Git servers we thus have to build and install both binaries. This target is currently completely optional, and we want to continue to support running Gitaly with an external Git executable not built by Gitaly. It may eventually replace the current "make git" target though, which sets up a complete Git installation for us.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile35
1 files changed, 33 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 408659d07..1a0869b1c 100644
--- a/Makefile
+++ b/Makefile
@@ -303,6 +303,23 @@ install: build
${Q}mkdir -p ${INSTALL_DEST_DIR}
install $(call find_command_binaries) ${INSTALL_DEST_DIR}
+ifdef WITH_BUNDLED_GIT
+GIT_EXECUTABLES += git
+GIT_EXECUTABLES += git-remote-http
+GIT_EXECUTABLES += git-http-backend
+
+build: $(patsubst %,${BUILD_DIR}/bin/gitaly-%,${GIT_EXECUTABLES})
+
+install: $(patsubst %,${INSTALL_DEST_DIR}/gitaly-%,${GIT_EXECUTABLES})
+
+${BUILD_DIR}/bin/gitaly-%: ${GIT_SOURCE_DIR}/% | ${BUILD_DIR}/bin
+ ${Q}install $< $@
+
+${INSTALL_DEST_DIR}/gitaly-%: ${BUILD_DIR}/bin/gitaly-%
+ ${Q}mkdir -p $(@D)
+ ${Q}install $< $@
+endif
+
.PHONY: prepare-tests
prepare-tests: git libgit2 prepare-test-repos ${SOURCE_DIR}/.ruby-bundle
@@ -521,7 +538,13 @@ ${LIBGIT2_INSTALL_DIR}/lib/libgit2.a: ${DEPENDENCY_DIR}/libgit2.version
${Q}CMAKE_BUILD_PARALLEL_LEVEL=$(shell nproc) cmake --build ${LIBGIT2_BUILD_DIR} --target install
go install -a github.com/libgit2/git2go/${GIT2GO_VERSION}
-${GIT_INSTALL_DIR}/bin/git: ${DEPENDENCY_DIR}/git.version
+# This target is responsible for checking out Git sources. In theory, we'd only
+# need to depend on the source directory. But given that the source directory
+# always changes when anything inside of it changes, like when we for example
+# build binaries inside of it, we cannot depend on it directly or we'd
+# otherwise try to rebuild all targets depending on it whenever we build
+# something else. We thus depend on the Makefile instead.
+${GIT_SOURCE_DIR}/Makefile: ${DEPENDENCY_DIR}/git.version
${Q}${GIT} -c init.defaultBranch=master init ${GIT_QUIET} ${GIT_SOURCE_DIR}
${Q}${GIT} -C "${GIT_SOURCE_DIR}" config remote.origin.url ${GIT_REPO_URL}
${Q}${GIT} -C "${GIT_SOURCE_DIR}" config remote.origin.tagOpt --no-tags
@@ -539,9 +562,17 @@ ifdef GIT_EXTRA_VERSION
else
${Q}rm -f "${GIT_SOURCE_DIR}"/version
endif
+ ${Q}touch $@
+
+${GIT_SOURCE_DIR}/%: ${GIT_SOURCE_DIR}/Makefile
+ ${Q}env -u PROFILE -u MAKEFLAGS -u GIT_VERSION ${MAKE} -C ${GIT_SOURCE_DIR} -j$(shell nproc) prefix=${GIT_PREFIX} ${GIT_BUILD_OPTIONS} $(notdir $@)
+ ${Q}touch $@
+
+${GIT_INSTALL_DIR}/bin/git: ${GIT_SOURCE_DIR}/Makefile
${Q}rm -rf ${GIT_INSTALL_DIR}
${Q}mkdir -p ${GIT_INSTALL_DIR}
- env -u PROFILE -u MAKEFLAGS -u GIT_VERSION ${MAKE} -C ${GIT_SOURCE_DIR} -j$(shell nproc) prefix=${GIT_PREFIX} ${GIT_BUILD_OPTIONS} install
+ ${Q}env -u PROFILE -u MAKEFLAGS -u GIT_VERSION ${MAKE} -C ${GIT_SOURCE_DIR} -j$(shell nproc) prefix=${GIT_PREFIX} ${GIT_BUILD_OPTIONS} install
+ ${Q}touch $@
${TOOLS_DIR}/protoc.zip: TOOL_VERSION = ${PROTOC_VERSION}
${TOOLS_DIR}/protoc.zip: ${TOOLS_DIR}/protoc.version