Skip to contentSkip to conversation

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

PATCH In review David Kågedal 2 participants 3 messages Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't fail when an existing directory can't be created.

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.

Documentation/Makefile +4 -4
index 7a2130a..e6271d8 100644
@@ -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 ;\
Makefile +2 -2
index e8712e0..e6bb411 100644
@@ -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
gitk-git/Makefile +1 -1
index e1b6045..117b841 100644
@@ -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::
templates/Makefile +5 -5
index 67be379..58f2bdd 100644
@@ -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 -)
Signature · 5 lines
1.6.0.rc2.7.gbf8a


-- 
David Kågedal
#1 lore raw
Quoted 3 lines · David Kågedal

This makes it possible to install in a writable directory not owned by the current user.
---

Sign-off?

Quoted 5 lines
Documentation/Makefile +0 -0
index 7a2130a..e6271d8 100644

Documentation/Makefile man7: $(DOC_MAN7) · line 92

Quoted 9 lines
Documentation/Makefile +3 -3
@@ -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?

#2 lore raw

[this is a resend, since the first one didn't reach the list]

Quoted 7 lines · Junio C Hamano
Quoted 3 lines · David Kågedal

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.

Signature · 1 line
David Kågedal