Install-prefix when building should not be hardcoded
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.
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 usingrun_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/localis 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
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 usingrun_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/localis 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 installDoes that work for you?
--
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 usingrun_prefix.I'm not sure about this part.
Perhaps it is related to the use of RUNTIME_PREFIX (which I don't use myself)?
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 usingrun_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!
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 usingrun_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.
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
@@ -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