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-12-01 17:23:06 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-12-01 18:16:39 +0300
commita61a48a6b88a1d00bb7a3e003486d27973e1f443 (patch)
tree0150541e8c41dd660ede0eb34284571b97bb40ed /Makefile
parentbbce3f8686e3b6f08a5063f8a6b86e2509fd9285 (diff)
Makefile: Only remove default Git prefix if installing into it
We have two different variables tracking the GIT_PREFIX: first the GIT_PREFIX itself, which can be set by the user to point wherever the user wants to install the compiled Git distribution to. And then we have GIT_DEFAULT_PREFIX, which is the default value of GIT_PREFIX. There is one special thing about GIT_DEFAULT_PREFIX though: upon installing Git, we always remove the GIT_DEFAULT_PREFIX first regardless of whether we're actually using the default prefix or not. While it is clear that we _never_ want to remove GIT_PREFIX before installing into it given that it may point e.g. to `/usr/local`, it's questionable what the intent is in removing the default prefix first. If I am about to guess, then we likely want to ensure that developers never end up with Git installations of mixed versions given that the Git version changes much more frequently on a developer machine, may it be because of normal upgrades of the Git version or because one is in the process of bisecting. As such, it is not too unlikely that the user will end up with such mixed Git installations. And given that distros of Gitaly will hopefully use proper packaging, we should assume that they do not run such mixed installations either. Even so, it does not make sense to delete the default prefix in case the current prefix is different. So let's only delete it in case GIT_PREFIX and GIT_DEFAULT_PREFIX are the same.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 6 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index ec1d231f9..2724e80b0 100644
--- a/Makefile
+++ b/Makefile
@@ -578,11 +578,12 @@ ${GIT_SOURCE_DIR}/%: ${GIT_SOURCE_DIR}/Makefile
${Q}touch $@
${GIT_PREFIX}/bin/git: ${GIT_SOURCE_DIR}/Makefile
- # Note that we're deleting GIT_DEFAULT_PREFIX, not GIT_PREFIX: we only
- # want to remove the default location in our build directory, but never
- # want to delete the actual location the user wants to install to.
- # Otherwise, we may end up wiping e.g. `/usr/local`.
- ${Q}rm -rf ${GIT_DEFAULT_PREFIX}
+ # Remove the Git installation first in case GIT_PREFIX is the default
+ # prefix which always points into our build directory. This is done so
+ # we never end up with mixed Git installations on developer machines.
+ # We cannot ever remove GIT_PREFIX though in case they're different
+ # because it may point to a user-controlled directory.
+ ${Q}if [ "x${GIT_DEFAULT_PREFIX}" = "x${GIT_PREFIX}" ]; then rm -rf "${GIT_DEFAULT_PREFIX}"; fi
${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 $@