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-09-03 13:26:21 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-03 16:04:54 +0300
commit184deb2a6af21ca3923a67b1fae5f2de8e38430c (patch)
tree88e1f4c8fea48fe0d1feafb155a600f55d7878d1 /Makefile
parent378d379adcb545e10ee2db333bdddc054647b019 (diff)
Makefile: Build Git with extra GitLab patch level version
With Gitaly now being the single source of truth for the Git version deployed in production, we have started to make a lot more use of applying patches on top of our self-built Git version. The policy is and will remain to only ever apply patches which have been accepted upstream, but it is sensible to allow for backporting patches such that we can make use of them faster and test whether they have the expected benefits. This has uncovered a problem though: it's impossible for us to detect which patches have been applied on top. This makes it hard for admins to see whether they are running a custom version of Git or the mainline version, and it is a problem for Gitaly because we cannot detect what the current version supports in case we backport important fixes which require changes both in Git and Gitaly. Introduce a new Git extra version into our build process. This extra version is a simple counter "gl${PATCHLEVEL}", where each newly added set of Git patches must from now on increment the extra version. With this version in place, we can fix both of above usecases. When setting the Git version, we need to be careful to not break our Git version parsing. But luckily, the current code is very lenient with regards to parsing the fourth tuple: we only recognize the "rc" prefix, but ignore everything else. Adding the GitLab patch level as this fourth tuple is thus backwards compatible with older Gitaly versions, which will simply ignore it. The end result is thus: $ git --version git version 2.33.0.gl1 It still needs an admin to correlate the set of patches with the patch level, but this should be an easy enough task and is easier to maintain on our side compared to somehow encoded "real" capabilities into the version string. Changelog: added
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile18
1 files changed, 17 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 54154c18b..dd0eebdc8 100644
--- a/Makefile
+++ b/Makefile
@@ -120,6 +120,14 @@ ifndef GIT_PATCHES
GIT_PATCHES += 0004-revision-stop-retrieving-reference-twice.patch
GIT_PATCHES += 0005-commit-graph-split-out-function-to-search-commit-pos.patch
GIT_PATCHES += 0006-revision-avoid-hitting-packfiles-when-commits-are-in.patch
+
+ # This extra version has two intentions: first, it allows us to detect
+ # capabilities of the command at runtime. Second, it helps admins to
+ # discover which version is currently in use. As such, this version must be
+ # incremented whenever a new patch is added above. When no patches exist,
+ # then this should be undefined. Otherwise, it must be set to at least
+ # `gl1` given that `0` is the "default" GitLab patch level.
+ GIT_EXTRA_VERSION = gl1
endif
ifndef GIT_BUILD_OPTIONS
@@ -465,7 +473,7 @@ ${DEPENDENCY_DIR}: | ${BUILD_DIR}
${DEPENDENCY_DIR}/libgit2.version: dependency-version | ${DEPENDENCY_DIR}
${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${LIBGIT2_VERSION} ${LIBGIT2_BUILD_OPTIONS}" ] || >$@ echo -n "${LIBGIT2_VERSION} ${LIBGIT2_BUILD_OPTIONS}"
${DEPENDENCY_DIR}/git.version: dependency-version | ${DEPENDENCY_DIR}
- ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${GIT_VERSION} ${GIT_BUILD_OPTIONS} ${GIT_PATCHES}" ] || >$@ echo -n "${GIT_VERSION} ${GIT_BUILD_OPTIONS} ${GIT_PATCHES}"
+ ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${GIT_VERSION}.${GIT_EXTRA_VERSION} ${GIT_BUILD_OPTIONS} ${GIT_PATCHES}" ] || >$@ echo -n "${GIT_VERSION}.${GIT_EXTRA_VERSION} ${GIT_BUILD_OPTIONS} ${GIT_PATCHES}"
${TOOLS_DIR}/%.version: dependency-version | ${TOOLS_DIR}
${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${TOOL_VERSION}" ] || >$@ echo -n "${TOOL_VERSION}"
@@ -491,6 +499,14 @@ ${GIT_INSTALL_DIR}/bin/git: ${DEPENDENCY_DIR}/git.version
ifneq (${GIT_PATCHES},)
${Q}${GIT} -C "${GIT_SOURCE_DIR}" apply $(addprefix "${SOURCE_DIR}"/_support/git-patches/,${GIT_PATCHES})
endif
+ # We're writing the version into the "version" file in Git's own source
+ # directory. If it exists, Git's Makefile will pick it up and use it as
+ # the version instead of auto-detecting via git-describe(1).
+ifneq (${GIT_EXTRA_VERSION},0)
+ ${Q}echo ${GIT_VERSION}.${GIT_EXTRA_VERSION} >"${GIT_SOURCE_DIR}"/version
+else
+ ${Q}rm -f "${GIT_SOURCE_DIR}"/version
+endif
${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