threads / discuss / 58560

Install-prefix when building should not be hardcoded

Subject: Install-prefix when building should not be hardcoded

## tl;dr

7 messages between Oct 4, 2022 and Oct 6, 2022.

replies: 6people: 3as markdown or json

darkdragon· Oct 4, 2022, 07:38 UTC · lore

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.
Đoàn Trần Công Danh· Oct 4, 2022, 07:57 UTC · re: darkdragon · lore

Re: Install-prefix when building should not be hardcoded

On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:
Show 5 quoted lines
> 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.
Show 6 quoted 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
darkdragon· Oct 4, 2022, 08:40 UTC · re: Đoàn Trần Công Danh · lore

Re: Install-prefix when building should not be hardcoded

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
On Tue, Oct 4, 2022 at 9:57 AM Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:
Show 26 quoted lines
>
> On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:
> > 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.
>
> > 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
Junio C Hamano· Oct 5, 2022, 19:34 UTC · re: Đoàn Trần Công Danh · lore

Re: Install-prefix when building should not be hardcoded

Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
Show 8 quoted lines
> On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:
>> 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)?

darkdragon· Oct 5, 2022, 20:23 UTC · re: Junio C Hamano · lore

Re: Install-prefix when building should not be hardcoded

On Wed, Oct 5, 2022 at 9:34 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
>
> Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
>
> > On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:
> >> 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)?
This seems to do the trick! Thanks a lot!
Junio C Hamano· Oct 5, 2022, 21:21 UTC · re: darkdragon · lore

Re: Install-prefix when building should not be hardcoded

darkdragon <darkdragon-001@web.de> writes:
Show 17 quoted lines
> On Wed, Oct 5, 2022 at 9:34 PM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:
>>
>> > On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:
>> >> 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)?
>
> 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.
Đoàn Trần Công Danh· Oct 6, 2022, 01:32 UTC · re: Junio C Hamano · lore

[PATCH] 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.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index cac3452edb..8a58be440f 100644
--- a/Makefile
+++ b/Makefile
@@ -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
-- 
2.38.0.1.ge44e9fe867

← back to recent threads