threads / patch / 9408

patchDocumentation/Makefile: remove cmd-list.made before redirecting to it.

Subject: [PATCH] Documentation/Makefile: remove cmd-list.made before redirecting to it.

## tl;dr

3 messages between Aug 6, 2007 and Aug 7, 2007. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

David Kastrup· Aug 6, 2007, 13:05 UTC · lore

If cmd-list.made has been created by a previous run as root, output redirection to it will fail. So remove it before regeneration.

Signed-off-by: David Kastrup <dak@gnu.org>
---
 Documentation/Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to Documentation/Makefile +1 −0
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 97ee067..120e7c0 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -120,6 +120,7 @@ $(cmds_txt): cmd-list.made
 
 cmd-list.made: cmd-list.perl $(MAN1_TXT)
 	perl ./cmd-list.perl
+	$(RM) $@
 	date >$@
 
 git.7 git.html: git.txt core-intro.txt
-- 
1.5.3.rc4.21.ga63eb
Junio C Hamano· Aug 7, 2007, 06:33 UTC · re: David Kastrup · lore

Re: [PATCH] Documentation/Makefile: remove cmd-list.made before redirecting to it.

David Kastrup <dak@gnu.org> writes:
Show 20 quoted lines
> If cmd-list.made has been created by a previous run as root, output
> redirection to it will fail.  So remove it before regeneration.
>
> Signed-off-by: David Kastrup <dak@gnu.org>
> ---
>  Documentation/Makefile |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 97ee067..120e7c0 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -120,6 +120,7 @@ $(cmds_txt): cmd-list.made
>  
>  cmd-list.made: cmd-list.perl $(MAN1_TXT)
>  	perl ./cmd-list.perl
> +	$(RM) $@
>  	date >$@
>  
>  git.7 git.html: git.txt core-intro.txt

Although I understand that it would be a problem if you built as root earlier, which would have left files unmodifyable by you, I think this is getting out of hand. The cmd-list.perl script itself, for example, does "creat in $out+, if the contents have changed from the last round then rename $out+ to $out" sequence in order to avoid unnecessary rebuild of files that depend on the generated command list. If it is interrupted in the middle while running as root, and then you try to do another build, I suspect "creat in $out+" part would fail.

Maybe you can simply recover from such an error with a "make clean"?

Also I'd prefer $(RM) before actually running the command to generate the list, but that is just the matter of taste.

David Kastrup· Aug 7, 2007, 10:29 UTC · re: Junio C Hamano · lore

Re: [PATCH] Documentation/Makefile: remove cmd-list.made before redirecting to it.

Junio C Hamano <gitster@pobox.com> writes:
Show 9 quoted lines
> Although I understand that it would be a problem if you built as
> root earlier, which would have left files unmodifyable by you, I
> think this is getting out of hand.  The cmd-list.perl script itself,
> for example, does "creat in $out+, if the contents have changed from
> the last round then rename $out+ to $out" sequence in order to avoid
> unnecessary rebuild of files that depend on the generated command
> list.  If it is interrupted in the middle while running as root, and
> then you try to do another build, I suspect "creat in $out+" part
> would fail.

No, creat is only interested in the directory permissions. It is open(..., O_TRUNC) that causes the problem. There are not many programs that actually use that for their output files, but shell output redirection is one of them, and some editors tend to do this as well in order to easily preserve permissions.

There are no other shell output redirections to an undeleted file in the Makefile.

-- 
David Kastrup

← back to recent threads