git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes
@ 2009-02-01 18:24 A Large Angry SCM
  2009-02-05  7:04 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: A Large Angry SCM @ 2009-02-01 18:24 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: git, Junio C Hamano

In 026fa0d5ad9538ca76838070861531c037d7b9ba, "Move computation of 
absolute paths from Makefile to runtime (in preparation for 
RUNTIME_PREFIX)", the following change was made to the Makefile. The 
problem is that $(abspath names...) is a relatively recent addition to 
GNU make and when used in an older GNU make, the test always fails 
resulting incorrect installation dirs for the templates and commands.

The new test is also wrong; (for *nix systems) in that it really wants 
to test if the first character is a '/' but GNU make doesn't have a way 
to do that directly. Instead, it tests if the first character is a / 
_AND_ the path string does not include . or .. components,

The older test has problems itself but at least it allowed you to 
specify absolute paths.

@@ -1407,17 +1417,17 @@ remove-dashes:

  ### Installation rules

-ifeq ($(firstword $(subst /, ,$(template_dir))),..)
-template_instdir = $(bindir)/$(template_dir)
-else
+ifeq ($(abspath $(template_dir)),$(template_dir))
  template_instdir = $(template_dir)
+else
+template_instdir = $(prefix)/$(template_dir)
  endif
  export template_instdir

-ifeq ($(firstword $(subst /, ,$(gitexecdir))),..)
-gitexec_instdir = $(bindir)/$(gitexecdir)
-else
+ifeq ($(abspath $(gitexecdir)),$(gitexecdir))
  gitexec_instdir = $(gitexecdir)
+else
+gitexec_instdir = $(prefix)/$(gitexecdir)
  endif
  gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
  export gitexec_instdir


I see 3 ways to fix the problem:
	1) go back to using the old test.
	2) keep the new test but add a test that will break the build if
		$(abspath names...) does not work.
	3) something like the following (untested)


  ### Installation rules


  temp = $(subst " ",x,$(template_dir))
  temp = $(subst //,/,$(temp))
  temp = $(addsuffix x,$(temp))
  temp = $(subst /, ,$(temp))
  ifeq ($(strip $(temp)),$(temp))
  template_instdir = $(template_dir)
  else
  template_instdir = $(prefix)/$(template_dir)
  endif
  export template_instdir

  temp = $(subst " ",x,$(gitexecdir))
  temp = $(subst //,/,$(temp))
  temp = $(addsuffix x,$(temp))
  temp = $(subst /, ,$(temp))
  ifeq ($(strip $(temp)),$(temp))
  gitexec_instdir = $(gitexecdir)
  else
  gitexec_instdir = $(prefix)/$(gitexecdir)
  endif
  gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
  export gitexec_instdir

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes
  2009-02-01 18:24 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes A Large Angry SCM
@ 2009-02-05  7:04 ` Junio C Hamano
  2009-02-05  7:13   ` Steffen Prohaska
  2009-02-05  7:35 ` Junio C Hamano
  2009-02-05  8:18 ` [PATCH] Makefile: fix misdetection of relative pathnames Junio C Hamano
  2 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2009-02-05  7:04 UTC (permalink / raw)
  To: Steffen Prohaska; +Cc: gitzilla, git

A Large Angry SCM <gitzilla@gmail.com> writes:

> In 026fa0d5ad9538ca76838070861531c037d7b9ba, "Move computation of
> absolute paths from Makefile to runtime (in preparation for
> RUNTIME_PREFIX)", the following change was made to the Makefile. The
> problem is that $(abspath names...) is a relatively recent addition to
> GNU make and when used in an older GNU make, the test always fails
> resulting incorrect installation dirs for the templates and commands.

Is there anything being done on this issue?

I could revert ed096c4 (Merge branch 'sp/runtime-prefix', 2009-01-31), but
I'd rather not if we can avoid it.

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes
  2009-02-05  7:04 ` Junio C Hamano
@ 2009-02-05  7:13   ` Steffen Prohaska
  0 siblings, 0 replies; 13+ messages in thread
From: Steffen Prohaska @ 2009-02-05  7:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: gitzilla, git


On Feb 5, 2009, at 8:04 AM, Junio C Hamano wrote:

> A Large Angry SCM <gitzilla@gmail.com> writes:
>
>> In 026fa0d5ad9538ca76838070861531c037d7b9ba, "Move computation of
>> absolute paths from Makefile to runtime (in preparation for
>> RUNTIME_PREFIX)", the following change was made to the Makefile. The
>> problem is that $(abspath names...) is a relatively recent addition  
>> to
>> GNU make and when used in an older GNU make, the test always fails
>> resulting incorrect installation dirs for the templates and commands.
>
> Is there anything being done on this issue?

Not yet.  I haven't had time.


> I could revert ed096c4 (Merge branch 'sp/runtime-prefix',  
> 2009-01-31), but
> I'd rather not if we can avoid it.

I'll propose a fix on Saturday.

	Steffen

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes
  2009-02-01 18:24 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes A Large Angry SCM
  2009-02-05  7:04 ` Junio C Hamano
@ 2009-02-05  7:35 ` Junio C Hamano
  2009-02-05  7:38   ` Pascal Obry
  2009-02-05  7:44   ` Junio C Hamano
  2009-02-05  8:18 ` [PATCH] Makefile: fix misdetection of relative pathnames Junio C Hamano
  2 siblings, 2 replies; 13+ messages in thread
From: Junio C Hamano @ 2009-02-05  7:35 UTC (permalink / raw)
  To: gitzilla; +Cc: Steffen Prohaska, git

A Large Angry SCM <gitzilla@gmail.com> writes:

> The new test is also wrong; (for *nix systems) in that it really wants
> to test if the first character is a '/' but GNU make doesn't have a
> way to do that directly.

Hmph.  Isn't it just the matter of doing something silly like this?

ifeq ($(filter /%,$(template_dir)),)
	... it does not start with a slash
else
	... it does
endif

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and  $(template_dir) variables using older GNU makes
  2009-02-05  7:35 ` Junio C Hamano
@ 2009-02-05  7:38   ` Pascal Obry
  2009-02-05  7:53     ` Junio C Hamano
  2009-02-05  7:44   ` Junio C Hamano
  1 sibling, 1 reply; 13+ messages in thread
From: Pascal Obry @ 2009-02-05  7:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: gitzilla, Steffen Prohaska, git

I have just proposed a patch to fix this in another thread.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes
  2009-02-05  7:35 ` Junio C Hamano
  2009-02-05  7:38   ` Pascal Obry
@ 2009-02-05  7:44   ` Junio C Hamano
  1 sibling, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2009-02-05  7:44 UTC (permalink / raw)
  To: gitzilla; +Cc: Steffen Prohaska, git

Junio C Hamano <gitster@pobox.com> writes:

> A Large Angry SCM <gitzilla@gmail.com> writes:
>
>> The new test is also wrong; (for *nix systems) in that it really wants
>> to test if the first character is a '/' but GNU make doesn't have a
>> way to do that directly.
>
> Hmph.  Isn't it just the matter of doing something silly like this?
>
> ifeq ($(filter /%,$(template_dir)),)
> 	... it does not start with a slash
> else
> 	... it does
> endif

That is, something like this.

The patch also protects the $(filter) check from sick users that use

	template_dir = My Files /the-leading-dir-ends-with-a-space

by using $(firstword)

No, I didn't test it.

 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git c/Makefile w/Makefile
index a82f173..605b147 100644
--- c/Makefile
+++ w/Makefile
@@ -1434,14 +1434,14 @@ remove-dashes:
 
 ### Installation rules
 
-ifeq ($(abspath $(template_dir)),$(template_dir))
+ifneq ($(filter /%,$(firstword $(template_dir))),)
 template_instdir = $(template_dir)
 else
 template_instdir = $(prefix)/$(template_dir)
 endif
 export template_instdir
 
-ifeq ($(abspath $(gitexecdir)),$(gitexecdir))
+ifneq ($(filter /%,$(firstword $(gitexecdir))),)
 gitexec_instdir = $(gitexecdir)
 else
 gitexec_instdir = $(prefix)/$(gitexecdir)

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and  $(template_dir) variables using older GNU makes
  2009-02-05  7:38   ` Pascal Obry
@ 2009-02-05  7:53     ` Junio C Hamano
  2009-02-05  7:57       ` Pascal Obry
  2009-02-05  8:01       ` Junio C Hamano
  0 siblings, 2 replies; 13+ messages in thread
From: Junio C Hamano @ 2009-02-05  7:53 UTC (permalink / raw)
  To: Pascal Obry; +Cc: gitzilla, Steffen Prohaska, git

Pascal Obry <pascal@obry.net> writes:

> I have just proposed a patch to fix this in another thread.

Does your patch address the lack of $(abspath) in older GNU make?

I do not know if mine that used firstword did for that matter, either,
though.

Regardless, I think your patch to config.mak is independently good,
because the way Makefile defines these directories is without the trailing
slash, and it would be better to be consistent.

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and  $(template_dir) variables using older GNU makes
  2009-02-05  7:53     ` Junio C Hamano
@ 2009-02-05  7:57       ` Pascal Obry
  2009-02-05  8:01       ` Junio C Hamano
  1 sibling, 0 replies; 13+ messages in thread
From: Pascal Obry @ 2009-02-05  7:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: gitzilla, Steffen Prohaska, git

Junio,

> Does your patch address the lack of $(abspath) in older GNU make?

Don't think so.

> Regardless, I think your patch to config.mak is independently good,
> because the way Makefile defines these directories is without the trailing
> slash, and it would be better to be consistent.

Right, better to have no slash ending directories to avoid double
slashes in $(dir)/file.c.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595

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

* Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) and  $(template_dir) variables using older GNU makes
  2009-02-05  7:53     ` Junio C Hamano
  2009-02-05  7:57       ` Pascal Obry
@ 2009-02-05  8:01       ` Junio C Hamano
  1 sibling, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2009-02-05  8:01 UTC (permalink / raw)
  To: Pascal Obry; +Cc: gitzilla, Steffen Prohaska, git

Junio C Hamano <gitster@pobox.com> writes:

> Regardless, I think your patch to config.mak is independently good,
> because the way Makefile defines these directories is without the trailing
> slash, and it would be better to be consistent.

In other words, I am thinking about applying your patch after amending the 
log message like this.

    [PATCH] config.mak.in: define paths without trailing slash

    The main Makefile defines gitexecdir and template_dir without trailing
    slash.  config.mak.in should do the same to be consistent.

    Signed-off-by: Pascal Obry <pascal@obry.net>

I think the misuse of abspath is a separate issue.

The main Makefile should be made robust not to misdetect the relative vs
absolute, especially because not everybody uses config.mak.autogen, and
because people should be able to override these variables from the command
line of make invocation and the name of the directory with or without
trailing slash ought to mean the same thing.

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

* [PATCH] Makefile: fix misdetection of relative pathnames
  2009-02-01 18:24 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes A Large Angry SCM
  2009-02-05  7:04 ` Junio C Hamano
  2009-02-05  7:35 ` Junio C Hamano
@ 2009-02-05  8:18 ` Junio C Hamano
  2009-02-05 12:27   ` Johannes Sixt
  2009-02-05 22:16   ` A Large Angry SCM
  2 siblings, 2 replies; 13+ messages in thread
From: Junio C Hamano @ 2009-02-05  8:18 UTC (permalink / raw)
  To: gitzilla; +Cc: Steffen Prohaska, Pascal Obry, git


A Large Angry SCM <gitzilla@gmail.com> writes:

> In 026fa0d5ad9538ca76838070861531c037d7b9ba, "Move computation of
> absolute paths from Makefile to runtime (in preparation for
> RUNTIME_PREFIX)", the following change was made to the Makefile. The
> problem is that $(abspath names...) is a relatively recent addition to
> GNU make and when used in an older GNU make, the test always fails
> resulting incorrect installation dirs for the templates and commands.
>
> The new test is also wrong; (for *nix systems) in that it really wants
> to test if the first character is a '/'

Ok, here is the final one from me that I am considering to commit, but it
would be nice to hear success/failure feedback from people who had trouble
with Steffen's changes.  I'd also like to hear from people who have been
happy with Steffen's changes that this does not break things for them.

-- >8 --

The installation rules wanted to differentiate between a template_dir that
is given as an absolute path (e.g. /usr/share/git-core/templates) and a
relative one (e.g. share/git-core/templates) but it was done by checking
if $(abspath $(template_dir)) and $(template_dir) yield the same string.

This was wrong in number of ways.

 * The user can give template_dir with a trailing slash from the command
   line to invoke make, or in the included config.mak.  A directory path
   ought to mean the same thing with or without such a trailing slash but
   use of $(abspath) means with an absolute path with a trailing slash
   fails the test.

 * The compilation could be done inside /usr directory with a relative
   pathname share/git-core/templates and it will be mistaken as an
   absolute path.

 * Versions of GNU make older than 3.81 do not have $(abspath) to begin
   with.

This changes the detection logic to see if the given path begins with a
slash.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index a82f173..605b147 100644
--- a/Makefile
+++ b/Makefile
@@ -1434,14 +1434,14 @@ remove-dashes:
 
 ### Installation rules
 
-ifeq ($(abspath $(template_dir)),$(template_dir))
+ifneq ($(filter /%,$(firstword $(template_dir))),)
 template_instdir = $(template_dir)
 else
 template_instdir = $(prefix)/$(template_dir)
 endif
 export template_instdir
 
-ifeq ($(abspath $(gitexecdir)),$(gitexecdir))
+ifneq ($(filter /%,$(firstword $(gitexecdir))),)
 gitexec_instdir = $(gitexecdir)
 else
 gitexec_instdir = $(prefix)/$(gitexecdir)
-- 
1.6.1.2.382.gda69a

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

* Re: [PATCH] Makefile: fix misdetection of relative pathnames
  2009-02-05  8:18 ` [PATCH] Makefile: fix misdetection of relative pathnames Junio C Hamano
@ 2009-02-05 12:27   ` Johannes Sixt
  2009-02-05 17:19     ` Junio C Hamano
  2009-02-05 22:16   ` A Large Angry SCM
  1 sibling, 1 reply; 13+ messages in thread
From: Johannes Sixt @ 2009-02-05 12:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: gitzilla, Steffen Prohaska, Pascal Obry, git

Junio C Hamano schrieb:
> -ifeq ($(abspath $(template_dir)),$(template_dir))
> +ifneq ($(filter /%,$(firstword $(template_dir))),)

> -ifeq ($(abspath $(gitexecdir)),$(gitexecdir))
> +ifneq ($(filter /%,$(firstword $(gitexecdir))),)

No, this does not work on Windows for the use-case that this check is
intended for, namely when the user specifies an *absolute* path for
gitexecdir and/or template_dir in config.mak [*].

Neither does the version that uses $(abspath ...)! Because $(abspath ...)
does not work in our msysgit environment (that has GNU make 3.79.1).

That said, I don't think it's worth to cater for this use-case, precisely
because we want to *avoid* absolute paths on Windows anyway, and apply the
change that you proposed here.

[*] The reason it does not work is that we cannot use MSYS-style absolute
paths /c/Foo/Bar because the paths will be interpreted by git, which does
not understand them; the user must specify drive-letter absolute paths
c:/Foo/Bar, but the check does not catch them.

-- Hannes

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

* Re: [PATCH] Makefile: fix misdetection of relative pathnames
  2009-02-05 12:27   ` Johannes Sixt
@ 2009-02-05 17:19     ` Junio C Hamano
  0 siblings, 0 replies; 13+ messages in thread
From: Junio C Hamano @ 2009-02-05 17:19 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: gitzilla, Steffen Prohaska, Pascal Obry, git

Johannes Sixt <j.sixt@viscovery.net> writes:

> That said, I don't think it's worth to cater for this use-case, precisely
> because we want to *avoid* absolute paths on Windows anyway, and apply the
> change that you proposed here.
>
> [*] The reason it does not work is that we cannot use MSYS-style absolute
> paths /c/Foo/Bar because the paths will be interpreted by git, which does
> not understand them; the user must specify drive-letter absolute paths
> c:/Foo/Bar, but the check does not catch them.

Hmm, not c:\Program Files\Git?

In any case, thanks for an Ack.  It clears one remaining issue for -rc0
(and there are certainly others I have forgot).

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

* Re: [PATCH] Makefile: fix misdetection of relative pathnames
  2009-02-05  8:18 ` [PATCH] Makefile: fix misdetection of relative pathnames Junio C Hamano
  2009-02-05 12:27   ` Johannes Sixt
@ 2009-02-05 22:16   ` A Large Angry SCM
  1 sibling, 0 replies; 13+ messages in thread
From: A Large Angry SCM @ 2009-02-05 22:16 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Steffen Prohaska, Pascal Obry, git

Junio C Hamano wrote:
> A Large Angry SCM <gitzilla@gmail.com> writes:
> 
>> In 026fa0d5ad9538ca76838070861531c037d7b9ba, "Move computation of
>> absolute paths from Makefile to runtime (in preparation for
>> RUNTIME_PREFIX)", the following change was made to the Makefile. The
>> problem is that $(abspath names...) is a relatively recent addition to
>> GNU make and when used in an older GNU make, the test always fails
>> resulting incorrect installation dirs for the templates and commands.
>>
>> The new test is also wrong; (for *nix systems) in that it really wants
>> to test if the first character is a '/'
> 
> Ok, here is the final one from me that I am considering to commit, but it
> would be nice to hear success/failure feedback from people who had trouble
> with Steffen's changes.  I'd also like to hear from people who have been
> happy with Steffen's changes that this does not break things for them.
> 
> -- >8 --
> 
> The installation rules wanted to differentiate between a template_dir that
> is given as an absolute path (e.g. /usr/share/git-core/templates) and a
> relative one (e.g. share/git-core/templates) but it was done by checking
> if $(abspath $(template_dir)) and $(template_dir) yield the same string.
> 
> This was wrong in number of ways.
> 
>  * The user can give template_dir with a trailing slash from the command
>    line to invoke make, or in the included config.mak.  A directory path
>    ought to mean the same thing with or without such a trailing slash but
>    use of $(abspath) means with an absolute path with a trailing slash
>    fails the test.
> 
>  * The compilation could be done inside /usr directory with a relative
>    pathname share/git-core/templates and it will be mistaken as an
>    absolute path.
> 
>  * Versions of GNU make older than 3.81 do not have $(abspath) to begin
>    with.
> 
> This changes the detection logic to see if the given path begins with a
> slash.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tested-by: A Large Angry SCM <gitzilla@gmail.com>

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

end of thread, other threads:[~2009-02-05 22:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-01 18:24 026fa0d5ad Breaks installs with absolue $(gitexecdir) and $(template_dir) variables using older GNU makes A Large Angry SCM
2009-02-05  7:04 ` Junio C Hamano
2009-02-05  7:13   ` Steffen Prohaska
2009-02-05  7:35 ` Junio C Hamano
2009-02-05  7:38   ` Pascal Obry
2009-02-05  7:53     ` Junio C Hamano
2009-02-05  7:57       ` Pascal Obry
2009-02-05  8:01       ` Junio C Hamano
2009-02-05  7:44   ` Junio C Hamano
2009-02-05  8:18 ` [PATCH] Makefile: fix misdetection of relative pathnames Junio C Hamano
2009-02-05 12:27   ` Johannes Sixt
2009-02-05 17:19     ` Junio C Hamano
2009-02-05 22:16   ` A Large Angry SCM

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).