Skip to contentSkip to conversation

Install-prefix when building should not be hardcoded

PATCH New darkdragon 3 participants 7 messages Oct 4, 2022 – Oct 6, 2022 Kbuild

lore
Share & tools
lore

darkdragon

author
#0 lore raw

Even though in Makefile, it is stated that git will figure out gitexecdir at runtime based on the path to the executable, there are many output files where $(prefix) will be hardcoded. Even git --exec-path will print out $(compile_prefix)/libexec/git-core instead of using run_prefix.

Example: We are building git in Docker at a separate stage to /deploy (since /usr/local is populated with our compiler toolchain). The final image is assembled by copying the contents of /deploy to /usr/local. Commands like "git submodule" will fail because of the wrong git exec path. Searching via "grep -r /deploy" in /deploy after make install yields many results.

#1 lore raw
Quoted 5 lines · darkdragon

Even though in Makefile, it is stated that git will figure out gitexecdir at runtime based on the path to the executable, there are many output files where $(prefix) will be hardcoded. Even git --exec-path will print out $(compile_prefix)/libexec/git-core instead of using run_prefix.

I'm not sure about this part.

Quoted 6 lines

Example: We are building git in Docker at a separate stage to /deploy (since /usr/local is populated with our compiler toolchain). The final image is assembled by copying the contents of /deploy to /usr/local. Commands like "git submodule" will fail because of the wrong git exec path. Searching via "grep -r /deploy" in /deploy after make install yields many results.

But you may be interested in $(DESTDIR)

make prefix=/usr/local all
make prefix=/usr/local DESTDIR=/deploy install

Does that work for you?

Signature · 1 line
Danh
author
#2 lore raw

Thanks for the hint to DESTDIR, it helps!

Nevertheless, I would like to point towards the following section in the [MAKEFILE][1]:

```Makefile
# Among the variables below, these:
# gitexecdir
# ...
# can be specified as a relative path some/where/else;
# this is interpreted as relative to $(prefix) and "git" at
# runtime figures out where they are based on the path to the executable.
# ...
# This can help installing the suite in a relocatable way.
# ...
gitexecdir = libexec/git-core
```

[1]: https://github.com/git/git/blob/master/Makefile#L525-L547

Quoted 26 lines · Đoàn Trần Công Danh
Quoted 5 lines · darkdragon

Even though in Makefile, it is stated that git will figure out gitexecdir at runtime based on the path to the executable, there are many output files where $(prefix) will be hardcoded. Even git --exec-path will print out $(compile_prefix)/libexec/git-core instead of using run_prefix.

I'm not sure about this part.

Quoted 6 lines

Example: We are building git in Docker at a separate stage to /deploy (since /usr/local is populated with our compiler toolchain). The final image is assembled by copying the contents of /deploy to /usr/local. Commands like "git submodule" will fail because of the wrong git exec path. Searching via "grep -r /deploy" in /deploy after make install yields many results.

But you may be interested in $(DESTDIR)

make prefix=/usr/local all
make prefix=/usr/local DESTDIR=/deploy install

Does that work for you?

--
Danh

#3 lore raw
In reply to Đoàn Trần Công Danh
Quoted 8 lines · Đoàn Trần Công Danh
Quoted 5 lines · darkdragon

Even though in Makefile, it is stated that git will figure out gitexecdir at runtime based on the path to the executable, there are many output files where $(prefix) will be hardcoded. Even git --exec-path will print out $(compile_prefix)/libexec/git-core instead of using run_prefix.

I'm not sure about this part.

Perhaps it is related to the use of RUNTIME_PREFIX (which I don't use myself)?

author
#4 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Đoàn Trần Công Danh
Quoted 5 lines · darkdragon

Even though in Makefile, it is stated that git will figure out gitexecdir at runtime based on the path to the executable, there are many output files where $(prefix) will be hardcoded. Even git --exec-path will print out $(compile_prefix)/libexec/git-core instead of using run_prefix.

Quoted 4 lines
Quoted 1 line

I'm not sure about this part.

Perhaps it is related to the use of RUNTIME_PREFIX (which I don't use myself)?

This seems to do the trick! Thanks a lot!

#5 lore raw
Quoted 11 lines · darkdragon
Quoted 10 lines · Junio C Hamano
Quoted 7 lines · Đoàn Trần Công Danh
Quoted 5 lines · darkdragon

Even though in Makefile, it is stated that git will figure out gitexecdir at runtime based on the path to the executable, there are many output files where $(prefix) will be hardcoded. Even git --exec-path will print out $(compile_prefix)/libexec/git-core instead of using run_prefix.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

I'm not sure about this part.

Perhaps it is related to the use of RUNTIME_PREFIX (which I don't use myself)?

This seems to do the trick! Thanks a lot!

I guess somebody needs to send a patch to the Makefile to clarify the comment that led us confused in this thread. Volunteers?

Thanks.

#6 lore raw

PATCH 1/1 Makefile: clarify runtime relative gitexecdir

"git" built with RUNTIME_PREFIX flag turned on could figure out gitexecdir and other paths as relative to "git" executable.

However, in the section specifies gitexecdir, RUNTIME_PREFIX wasn't mentioned, thus users may wrongly assume that "git" always locates gitexecdir as relative path to the executable.

Let's clarify that only "git" built with RUNTIME_PREFIX will locate gitexecdir as relative path.

---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Makefile +3 -2
index cac3452edb..8a58be440f 100644
@@ -529,8 +529,9 @@ GIT-VERSION-FILE: FORCE
 #   template_dir
 #   sysconfdir
 # can be specified as a relative path some/where/else;
-# this is interpreted as relative to $(prefix) and "git" at
-# runtime figures out where they are based on the path to the executable.
+# this is interpreted as relative to $(prefix) and "git" built with
+# RUNTIME_PREFIX flag will figure out (at runtime) where they are
+# based on the path to the executable.
 # Additionally, the following will be treated as relative by "git" if they
 # begin with "$(prefix)/":
 #   mandir
Signature · 1 line
2.38.0.1.ge44e9fe867