threads / patch / 15157

patchDon't fail when an existing directory can't be created.

Subject: [PATCH] Don't fail when an existing directory can't be created.

## tl;dr

3 messages between Aug 22, 2008 and Aug 23, 2008. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

David Kågedal· Aug 22, 2008, 08:08 UTC · lore
This makes it possible to install in a writable directory not owned by
the current user.
---
 Documentation/Makefile |    8 ++++----
 Makefile               |    4 ++--
 gitk-git/Makefile      |    2 +-
 templates/Makefile     |   10 +++++-----
 4 files changed, 12 insertions(+), 12 deletions(-)

I install git in /usr/local/*, to which I have write permission, but I'm not necessarily the owner of. The permissions may look something like this:

  drwxrwxr-x 2 root adm 4096 2008-08-07 17:54 /usr/local/bin/
To do this I set prefix=/usr/local and run "make install".
Unfortunately, this fails miserably because the install rules insist
on changing the permissions on any directory it installs to to
755. This of course fails because I'm not the owner. And even if it
worked, I wouldn't want it to do that.

This patch is just a simple fix to make the install not abort when it fails to modify the directory permissions, but I have to ask why it tries to do this at all? Most other programs I have built and installed do not try to do this.

Show changes to 4 files +12 −12

Documentation/Makefile, Makefile, gitk-git/Makefile, templates/Makefile

diff --git a/Documentation/Makefile b/Documentation/Makefile
index 7a2130a..e6271d8 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -87,15 +87,15 @@ man7: $(DOC_MAN7)
 info: git.info gitman.info
 
 install: man
-	$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
-	$(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
-	$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
+	-$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
+	-$(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
+	-$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
 	$(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
 	$(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
 	$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
 
 install-info: info
-	$(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
+	-$(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
 	$(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
 	if test -r $(DESTDIR)$(infodir)/dir; then \
 	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
diff --git a/Makefile b/Makefile
index e8712e0..e6bb411 100644
--- a/Makefile
+++ b/Makefile
@@ -1341,8 +1341,8 @@ gitexec_instdir_SQ = $(subst ','\'',$(gitexec_instdir))
 export gitexec_instdir
 
 install: all
-	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
-	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
+	-$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
+	-$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 	$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
 	$(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X '$(DESTDIR_SQ)$(bindir_SQ)'
 	$(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
diff --git a/gitk-git/Makefile b/gitk-git/Makefile
index e1b6045..117b841 100644
--- a/gitk-git/Makefile
+++ b/gitk-git/Makefile
@@ -41,7 +41,7 @@ all:: gitk-wish $(ALL_MSGFILES)
 
 install:: all
 	$(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
-	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)'
+	-$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)'
 	$(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true
 
 uninstall::
diff --git a/templates/Makefile b/templates/Makefile
index 67be379..58f2bdd 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -26,10 +26,10 @@ boilerplates.made : $(bpsrc)
 	$(QUIET)ls *--* 2>/dev/null | \
 	while read boilerplate; \
 	do \
-		case "$$boilerplate" in *~) continue ;; esac && \
-		dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` && \
-		dir=`expr "$$dst" : '\(.*\)/'` && \
-		$(INSTALL) -d -m 755 blt/$$dir && \
+		case "$$boilerplate" in *~) continue ;; esac ; \
+		dst=`echo "$$boilerplate" | sed -e 's|^this|.|;s|--|/|g'` ; \
+		dir=`expr "$$dst" : '\(.*\)/'` ; \
+		$(INSTALL) -d -m 755 blt/$$dir ; \
 		case "$$boilerplate" in \
 		*--) ;; \
 		*) cp -p $$boilerplate blt/$$dst ;; \
@@ -46,6 +46,6 @@ clean:
 	$(RM) -r blt boilerplates.made
 
 install: all
-	$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
+	-$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(template_instdir_SQ)'
 	(cd blt && $(TAR) cf - .) | \
 	(cd '$(DESTDIR_SQ)$(template_instdir_SQ)' && umask 022 && $(TAR) xf -)
-- 
1.6.0.rc2.7.gbf8a


-- 
David Kågedal
Junio C Hamano· Aug 22, 2008, 22:35 UTC · re: David Kågedal · lore

Re: [PATCH] Don't fail when an existing directory can't be created.

David Kågedal <davidk@lysator.liu.se> writes:
> This makes it possible to install in a writable directory not owned by
> the current user.
> ---
Sign-off?
Show 14 quoted lines
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 7a2130a..e6271d8 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -87,15 +87,15 @@ man7: $(DOC_MAN7)
>  info: git.info gitman.info
>  
>  install: man
> -	$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
> -	$(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
> -	$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
> +	-$(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
> +	-$(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
> +	-$(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)

Makes me wonder what happens if you failed to create the target directory. Is it deemed to be Ok because the later step of installing the contents will fail anyway?

David Kågedal· Aug 23, 2008, 14:29 UTC · re: Junio C Hamano · lore

Re: [PATCH] Don't fail when an existing directory can't be created.

[this is a resend, since the first one didn't reach the list]
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
> David Kågedal <davidk@lysator.liu.se> writes:
>
>> This makes it possible to install in a writable directory not owned by
>> the current user.
>> ---
>
> Sign-off?
I can sign it off, but I was more expecting to start a discussions, I suppose.
-- 
David Kågedal

← back to recent threads