All of lore.kernel.org
 help / color / mirror / Atom feed
* Install-prefix when building should not be hardcoded
@ 2022-10-04  7:38 darkdragon
  2022-10-04  7:57 ` Đoàn Trần Công Danh
  0 siblings, 1 reply; 7+ messages in thread
From: darkdragon @ 2022-10-04  7:38 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Install-prefix when building should not be hardcoded
  2022-10-04  7:38 Install-prefix when building should not be hardcoded darkdragon
@ 2022-10-04  7:57 ` Đoàn Trần Công Danh
  2022-10-04  8:40   ` darkdragon
  2022-10-05 19:34   ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Đoàn Trần Công Danh @ 2022-10-04  7:57 UTC (permalink / raw)
  To: darkdragon; +Cc: git

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Install-prefix when building should not be hardcoded
  2022-10-04  7:57 ` Đoàn Trần Công Danh
@ 2022-10-04  8:40   ` darkdragon
  2022-10-05 19:34   ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: darkdragon @ 2022-10-04  8:40 UTC (permalink / raw)
  To: Đoàn Trần Công Danh; +Cc: git

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:
>
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Install-prefix when building should not be hardcoded
  2022-10-04  7:57 ` Đoàn Trần Công Danh
  2022-10-04  8:40   ` darkdragon
@ 2022-10-05 19:34   ` Junio C Hamano
  2022-10-05 20:23     ` darkdragon
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2022-10-05 19:34 UTC (permalink / raw)
  To: Đoàn Trần Công Danh; +Cc: darkdragon, git

Đ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)?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Install-prefix when building should not be hardcoded
  2022-10-05 19:34   ` Junio C Hamano
@ 2022-10-05 20:23     ` darkdragon
  2022-10-05 21:21       ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: darkdragon @ 2022-10-05 20:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Đoàn Trần Công Danh, git

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!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Install-prefix when building should not be hardcoded
  2022-10-05 20:23     ` darkdragon
@ 2022-10-05 21:21       ` Junio C Hamano
  2022-10-06  1:32         ` [PATCH] Makefile: clarify runtime relative gitexecdir Đoàn Trần Công Danh
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2022-10-05 21:21 UTC (permalink / raw)
  To: darkdragon; +Cc: Đoàn Trần Công Danh, git

darkdragon <darkdragon-001@web.de> writes:

> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Makefile: clarify runtime relative gitexecdir
  2022-10-05 21:21       ` Junio C Hamano
@ 2022-10-06  1:32         ` Đoàn Trần Công Danh
  0 siblings, 0 replies; 7+ messages in thread
From: Đoàn Trần Công Danh @ 2022-10-06  1:32 UTC (permalink / raw)
  To: git
  Cc: Đoàn Trần Công Danh, darkdragon-001,
	Junio C Hamano

"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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-06  1:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-04  7:38 Install-prefix when building should not be hardcoded darkdragon
2022-10-04  7:57 ` Đoàn Trần Công Danh
2022-10-04  8:40   ` darkdragon
2022-10-05 19:34   ` Junio C Hamano
2022-10-05 20:23     ` darkdragon
2022-10-05 21:21       ` Junio C Hamano
2022-10-06  1:32         ` [PATCH] Makefile: clarify runtime relative gitexecdir Đoàn Trần Công Danh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.