{"thread":{"id":"58560","subject":"Install-prefix when building should not be hardcoded","startedAt":"2022-10-04T07:38:54Z","lastAt":"2022-10-06T01:32:22Z","messageCount":7,"participants":["darkdragon","Đoàn Trần Công Danh","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"464110","messageId":"CAAOCJVAML0axQXbYZncT945SuG3-GfmDtDQ4_8cnkQmF_SZtHw@mail.gmail.com","threadId":"58560","inReplyTo":null,"subject":"Install-prefix when building should not be hardcoded","fromName":"darkdragon","fromEmail":"darkdragon-001@web.de","sentAt":"2022-10-04T07:38:24Z","receivedAt":"2022-10-04T07:38:54Z","isPatch":false,"sender":{"key":"darkdragon-001@web.de","avatar":null},"body":"Even though in Makefile, it is stated that git will figure out\ngitexecdir at runtime based on the path to the executable, there are\nmany output files where $(prefix) will be hardcoded. Even git\n--exec-path will print out $(compile_prefix)/libexec/git-core instead\nof using run_prefix.\n\nExample: We are building git in Docker at a separate stage to /deploy\n(since /usr/local is populated with our compiler toolchain). The final\nimage is assembled by copying the contents of /deploy to /usr/local.\nCommands like \"git submodule\" will fail because of the wrong git exec\npath. Searching via \"grep -r /deploy\" in /deploy after make install\nyields many results.\n"},{"id":"464111","messageId":"YzvnadnAYce0dIpi@danh.dev","threadId":"58560","inReplyTo":"CAAOCJVAML0axQXbYZncT945SuG3-GfmDtDQ4_8cnkQmF_SZtHw@mail.gmail.com","subject":"Re: Install-prefix when building should not be hardcoded","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-10-04T07:57:29Z","receivedAt":"2022-10-04T07:57:38Z","isPatch":false,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:\n> Even though in Makefile, it is stated that git will figure out\n> gitexecdir at runtime based on the path to the executable, there are\n> many output files where $(prefix) will be hardcoded. Even git\n> --exec-path will print out $(compile_prefix)/libexec/git-core instead\n> of using run_prefix.\n\nI'm not sure about this part.\n\n> Example: We are building git in Docker at a separate stage to /deploy\n> (since /usr/local is populated with our compiler toolchain). The final\n> image is assembled by copying the contents of /deploy to /usr/local.\n> Commands like \"git submodule\" will fail because of the wrong git exec\n> path. Searching via \"grep -r /deploy\" in /deploy after make install\n> yields many results.\n\nBut you may be interested in $(DESTDIR)\n\n\tmake prefix=/usr/local all\n\tmake prefix=/usr/local DESTDIR=/deploy install\n\nDoes that work for you?\n\n-- \nDanh\n"},{"id":"464113","messageId":"CAAOCJVD+NHqhwRQnnz-krLfK=_4_Yaa5MhKhVv5GY9-fi4kEqw@mail.gmail.com","threadId":"58560","inReplyTo":"YzvnadnAYce0dIpi@danh.dev","subject":"Re: Install-prefix when building should not be hardcoded","fromName":"darkdragon","fromEmail":"darkdragon-001@web.de","sentAt":"2022-10-04T08:40:24Z","receivedAt":"2022-10-04T08:41:02Z","isPatch":false,"sender":{"key":"darkdragon-001@web.de","avatar":null},"body":"Thanks for the hint to DESTDIR, it helps!\n\nNevertheless, I would like to point towards the following section in\nthe [MAKEFILE][1]:\n```Makefile\n# Among the variables below, these:\n# gitexecdir\n# ...\n# can be specified as a relative path some/where/else;\n# this is interpreted as relative to $(prefix) and \"git\" at\n# runtime figures out where they are based on the path to the executable.\n# ...\n# This can help installing the suite in a relocatable way.\n# ...\ngitexecdir = libexec/git-core\n```\n\n[1]: https://github.com/git/git/blob/master/Makefile#L525-L547\n\nOn Tue, Oct 4, 2022 at 9:57 AM Đoàn Trần Công Danh <congdanhqx@gmail.com> wrote:\n>\n> On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:\n> > Even though in Makefile, it is stated that git will figure out\n> > gitexecdir at runtime based on the path to the executable, there are\n> > many output files where $(prefix) will be hardcoded. Even git\n> > --exec-path will print out $(compile_prefix)/libexec/git-core instead\n> > of using run_prefix.\n>\n> I'm not sure about this part.\n>\n> > Example: We are building git in Docker at a separate stage to /deploy\n> > (since /usr/local is populated with our compiler toolchain). The final\n> > image is assembled by copying the contents of /deploy to /usr/local.\n> > Commands like \"git submodule\" will fail because of the wrong git exec\n> > path. Searching via \"grep -r /deploy\" in /deploy after make install\n> > yields many results.\n>\n> But you may be interested in $(DESTDIR)\n>\n>         make prefix=/usr/local all\n>         make prefix=/usr/local DESTDIR=/deploy install\n>\n> Does that work for you?\n>\n> --\n> Danh\n"},{"id":"464253","messageId":"xmqqczb6oyie.fsf@gitster.g","threadId":"58560","inReplyTo":"YzvnadnAYce0dIpi@danh.dev","subject":"Re: Install-prefix when building should not be hardcoded","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-10-05T19:34:33Z","receivedAt":"2022-10-05T19:34:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n\n> On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:\n>> Even though in Makefile, it is stated that git will figure out\n>> gitexecdir at runtime based on the path to the executable, there are\n>> many output files where $(prefix) will be hardcoded. Even git\n>> --exec-path will print out $(compile_prefix)/libexec/git-core instead\n>> of using run_prefix.\n>\n> I'm not sure about this part.\n\nPerhaps it is related to the use of RUNTIME_PREFIX (which I don't\nuse myself)?\n"},{"id":"464259","messageId":"CAAOCJVAAwgECsJPfm7eHOMmKPewJzxHTKhjwacxPRYWJkSpX_g@mail.gmail.com","threadId":"58560","inReplyTo":"xmqqczb6oyie.fsf@gitster.g","subject":"Re: Install-prefix when building should not be hardcoded","fromName":"darkdragon","fromEmail":"darkdragon-001@web.de","sentAt":"2022-10-05T20:23:40Z","receivedAt":"2022-10-05T20:24:36Z","isPatch":false,"sender":{"key":"darkdragon-001@web.de","avatar":null},"body":"On Wed, Oct 5, 2022 at 9:34 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n>\n> > On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:\n> >> Even though in Makefile, it is stated that git will figure out\n> >> gitexecdir at runtime based on the path to the executable, there are\n> >> many output files where $(prefix) will be hardcoded. Even git\n> >> --exec-path will print out $(compile_prefix)/libexec/git-core instead\n> >> of using run_prefix.\n> >\n> > I'm not sure about this part.\n>\n> Perhaps it is related to the use of RUNTIME_PREFIX (which I don't\n> use myself)?\n\nThis seems to do the trick! Thanks a lot!\n"},{"id":"464262","messageId":"xmqqpmf6nf09.fsf@gitster.g","threadId":"58560","inReplyTo":"CAAOCJVAAwgECsJPfm7eHOMmKPewJzxHTKhjwacxPRYWJkSpX_g@mail.gmail.com","subject":"Re: Install-prefix when building should not be hardcoded","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-10-05T21:21:10Z","receivedAt":"2022-10-05T21:21:15Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"darkdragon <darkdragon-001@web.de> writes:\n\n> On Wed, Oct 5, 2022 at 9:34 PM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:\n>>\n>> > On 2022-10-04 09:38:24+0200, darkdragon <darkdragon-001@web.de> wrote:\n>> >> Even though in Makefile, it is stated that git will figure out\n>> >> gitexecdir at runtime based on the path to the executable, there are\n>> >> many output files where $(prefix) will be hardcoded. Even git\n>> >> --exec-path will print out $(compile_prefix)/libexec/git-core instead\n>> >> of using run_prefix.\n>> >\n>> > I'm not sure about this part.\n>>\n>> Perhaps it is related to the use of RUNTIME_PREFIX (which I don't\n>> use myself)?\n>\n> This seems to do the trick! Thanks a lot!\n\nI guess somebody needs to send a patch to the Makefile to clarify\nthe comment that led us confused in this thread.  Volunteers?\n\nThanks.\n"},{"id":"464270","messageId":"20221006013205.15015-1-congdanhqx@gmail.com","threadId":"58560","inReplyTo":"xmqqpmf6nf09.fsf@gitster.g","subject":"[PATCH] Makefile: clarify runtime relative gitexecdir","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-10-06T01:32:05Z","receivedAt":"2022-10-06T01:32:22Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"\"git\" built with RUNTIME_PREFIX flag turned on could figure out\ngitexecdir and other paths as relative to \"git\" executable.\n\nHowever, in the section specifies gitexecdir, RUNTIME_PREFIX wasn't\nmentioned, thus users may wrongly assume that \"git\" always locates\ngitexecdir as relative path to the executable.\n\nLet's clarify that only \"git\" built with RUNTIME_PREFIX will locate\ngitexecdir as relative path.\n\nSigned-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>\n---\n Makefile | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex cac3452edb..8a58be440f 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -529,8 +529,9 @@ GIT-VERSION-FILE: FORCE\n #   template_dir\n #   sysconfdir\n # can be specified as a relative path some/where/else;\n-# this is interpreted as relative to $(prefix) and \"git\" at\n-# runtime figures out where they are based on the path to the executable.\n+# this is interpreted as relative to $(prefix) and \"git\" built with\n+# RUNTIME_PREFIX flag will figure out (at runtime) where they are\n+# based on the path to the executable.\n # Additionally, the following will be treated as relative by \"git\" if they\n # begin with \"$(prefix)/\":\n #   mandir\n-- \n2.38.0.1.ge44e9fe867\n\n"}]}