threads / patch / 9298

patchMakefile: create an install-symlinks target

Subject: [PATCH] Makefile: create an install-symlinks target

## tl;dr

7 messages between Jul 29, 2007 and Jul 29, 2007. Diffs are folded; open one to read it.

replies: 6people: 4as markdown or json

David Kastrup· Jul 29, 2007, 21:26 UTC · lore
[commit text mostly pinched from INSTALL]

An alternative global installation method making it much easier to uninstall is to use a package-specific prefix like /opt/git, then create symlinks from /usr/local into that hierarchy. Uninstalling can then be achieved by

	# rm -rf /opt/git; find /usr/local -xtype l -delete

You can create a setup like that after having used one of the above install recipes with prefix=/opt/git by writing

	# make prefix=/opt/git symlinkprefix=/usr/local install-symlinks

This works by copying the directory hierarchy of $prefix to $symlinkprefix (not copying or descending to any directories of the name git* matched case-insensitively), then linking all the rest.

Signed-off-by: David Kastrup <dak@gnu.org>
---
 INSTALL  |   12 ++++++++++++
 Makefile |   10 +++++++++-
 2 files changed, 21 insertions(+), 1 deletions(-)
Show changes to 2 files +21 −1

INSTALL, Makefile

diff --git a/INSTALL b/INSTALL
index 79e71b6..22df145 100644
--- a/INSTALL
+++ b/INSTALL
@@ -21,6 +21,18 @@ set up install paths (via config.mak.autogen), so you can write instead
 	$ make all doc ;# as yourself
 	# make install install-doc ;# as root
 
+An alternative global installation method making it much easier to
+uninstall is to use a package-specific prefix like /opt/git, then
+create symlinks from /usr/local into that hierarchy.  Uninstalling can
+then be achieved by
+
+	# rm -rf /opt/git; find /usr/local -xtype l -delete
+
+You can create a setup like that after having used one of the above
+install recipes with prefix=/opt/git by writing
+
+	# make prefix=/opt/git symlinkprefix=/usr/local install-symlinks
+
 
 Issues of note:
 
diff --git a/Makefile b/Makefile
index 73b487f..87b317f 100644
--- a/Makefile
+++ b/Makefile
@@ -142,6 +142,7 @@ ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
 prefix = $(HOME)
+symlinkprefix = /usr/local
 bindir = $(prefix)/bin
 gitexecdir = $(bindir)
 sharedir = $(prefix)/share
@@ -692,6 +693,7 @@ bindir_SQ = $(subst ','\'',$(bindir))
 gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
 template_dir_SQ = $(subst ','\'',$(template_dir))
 prefix_SQ = $(subst ','\'',$(prefix))
+symlinkprefix_SQ = $(subst ','\'',$(symlinkprefix))
 
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
@@ -996,7 +998,13 @@ install-doc:
 quick-install-doc:
 	$(MAKE) -C Documentation quick-install
 
-
+# The somewhat strange looking lines start with an ignored $(MAKE) in
+# order to be executed also in make -n calls.
+install-symlinks:
+	@: $(MAKE) && echo cd '$(prefix_SQ)' && cd '$(prefix_SQ)' && find . -type d ! \( -iname 'git*' -prune \) -exec echo $(INSTALL) -m 755 -d '$(symlinkprefix_SQ)/{}' \;
+	@cd '$(prefix_SQ)' && find . -type d ! \( -iname 'git*' -prune \) -exec $(INSTALL) -m 755 -d '$(symlinkprefix_SQ)/{}' \;
+	@: $(MAKE) && echo cd '$(prefix_SQ)' && cd '$(prefix_SQ)' && find . \( -type d -iname 'git*' -prune -o ! -type d \) -exec echo $(RM) -r '$(symlinkprefix_SQ)/{}' \; -exec echo ln -s '$(prefix_SQ)/{}' '$(symlinkprefix_SQ)/{}' \;
+	@cd '$(prefix_SQ)' && find . \( -type d -iname 'git*' -prune -o ! -type d \) -exec $(RM) -r '$(symlinkprefix_SQ)/{}' \; -exec ln -s '$(prefix_SQ)/{}' '$(symlinkprefix_SQ)/{}' \;
 
 ### Maintainer's dist rules
 
-- 
1.5.3.rc2.84.g6497
David Kastrup· Jul 29, 2007, 21:27 UTC · re: David Kastrup · lore

[PATCH] Makefile: use $(FIND) instead of find

Some people might prefer to be able to specify the find utility to use, in particular for the more complicated usage in the install-symlinks target.

Signed-off-by: David Kastrup <dak@gnu.org>
---
 Makefile |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
Show changes to Makefile +7 −6
diff --git a/Makefile b/Makefile
index 87b317f..29dfdeb 100644
--- a/Makefile
+++ b/Makefile
@@ -178,6 +178,7 @@ AR = ar
 RM = rm -f
 TAR = tar
 INSTALL = install
+FIND = find
 RPMBUILD = rpmbuild
 TCL_PATH = tclsh
 TCLTK_PATH = wish
@@ -905,11 +906,11 @@ doc:
 
 TAGS:
 	$(RM) TAGS
-	find . -name '*.[hcS]' -print | xargs etags -a
+	$(FIND) . -name '*.[hcS]' -print | xargs etags -a
 
 tags:
 	$(RM) tags
-	find . -name '*.[hcS]' -print | xargs ctags -a
+	$(FIND) . -name '*.[hcS]' -print | xargs ctags -a
 
 ### Detect prefix changes
 TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):\
@@ -1001,10 +1002,10 @@ quick-install-doc:
 # The somewhat strange looking lines start with an ignored $(MAKE) in
 # order to be executed also in make -n calls.
 install-symlinks:
-	@: $(MAKE) && echo cd '$(prefix_SQ)' && cd '$(prefix_SQ)' && find . -type d ! \( -iname 'git*' -prune \) -exec echo $(INSTALL) -m 755 -d '$(symlinkprefix_SQ)/{}' \;
-	@cd '$(prefix_SQ)' && find . -type d ! \( -iname 'git*' -prune \) -exec $(INSTALL) -m 755 -d '$(symlinkprefix_SQ)/{}' \;
-	@: $(MAKE) && echo cd '$(prefix_SQ)' && cd '$(prefix_SQ)' && find . \( -type d -iname 'git*' -prune -o ! -type d \) -exec echo $(RM) -r '$(symlinkprefix_SQ)/{}' \; -exec echo ln -s '$(prefix_SQ)/{}' '$(symlinkprefix_SQ)/{}' \;
-	@cd '$(prefix_SQ)' && find . \( -type d -iname 'git*' -prune -o ! -type d \) -exec $(RM) -r '$(symlinkprefix_SQ)/{}' \; -exec ln -s '$(prefix_SQ)/{}' '$(symlinkprefix_SQ)/{}' \;
+	@: $(MAKE) && echo cd '$(prefix_SQ)' && cd '$(prefix_SQ)' && $(FIND) . -type d ! \( -iname 'git*' -prune \) -exec echo $(INSTALL) -m 755 -d '$(symlinkprefix_SQ)/{}' \;
+	@cd '$(prefix_SQ)' && $(FIND) . -type d ! \( -iname 'git*' -prune \) -exec $(INSTALL) -m 755 -d '$(symlinkprefix_SQ)/{}' \;
+	@: $(MAKE) && echo cd '$(prefix_SQ)' && cd '$(prefix_SQ)' && $(FIND) . \( -type d -iname 'git*' -prune -o ! -type d \) -exec echo $(RM) -r '$(symlinkprefix_SQ)/{}' \; -exec echo ln -s '$(prefix_SQ)/{}' '$(symlinkprefix_SQ)/{}' \;
+	@cd '$(prefix_SQ)' && $(FIND) . \( -type d -iname 'git*' -prune -o ! -type d \) -exec $(RM) -r '$(symlinkprefix_SQ)/{}' \; -exec ln -s '$(prefix_SQ)/{}' '$(symlinkprefix_SQ)/{}' \;
 
 ### Maintainer's dist rules
 
-- 
1.5.3.rc2.84.g6497
David Kastrup· Jul 29, 2007, 22:30 UTC · re: Junio C Hamano · lore

Re: [PATCH] Makefile: create an install-symlinks target

Junio C Hamano <gitster@pobox.com> writes:
> I thought we already rejected the "install symlink" in the
> earlier round.  Am I mistaken, or are there any compelling new
> reasons to revisit it?

Uh, perhaps I have a patchy recollection, but what I remember is that Scho argued that one might use something like xstow or a package manager instead, and I replied that

a) this required the installation of additional software for a simple
   task.
b) if the software worked using symbolic links, it would not know at
   what level to make the links (namely create
   /usr/local/share/man/man1 and link every file from
   /opt/git/share/man/man1, but link the directory
   /usr/local/share/git-core directly to /opt/git/share/git-core).

I don't remember a conclusive reply to that. Not seeing the patch appear either, I decided to clean it up, remove the objection of using the GNU-specific -mindepth option, and properly document the usage.

Since the stuff is strictly an additional convenience not impacting any of the existing targets, I would not have thought it terribly controversial.

If I have misinterpreted or misremembered part of the discussion, I apologize. No harm was intended.

In any case, some people might want to make use of the polished patch series even if it is not applied to git.git.

Is there a place other than the git list where one can provide patches that are not likely to end up in git.git?

Thanks,
-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Brian Gernhardt· Jul 29, 2007, 23:44 UTC · re: David Kastrup · lore

Re: [PATCH] Makefile: create an install-symlinks target

On Jul 29, 2007, at 6:30 PM, David Kastrup wrote:
> a) this required the installation of additional software for a simple
>    task.

I would think it's preferable to have a single piece of software to manage these links than attempt to craft a custom solution for every package you install.

Show 5 quoted lines
> b) if the software worked using symbolic links, it would not know at
>    what level to make the links (namely create
>    /usr/local/share/man/man1 and link every file from
>    /opt/git/share/man/man1, but link the directory
>    /usr/local/share/git-core directly to /opt/git/share/git-core).

What stow does is to create a directory for every level where multiple packages have files or non-stow files exists. It would create a link at /usr/local/share/git-core because nobody else uses that directory. If there are other /usr/local/share/man/man1/* files, it would make a link for every file in the git version.

> Since the stuff is strictly an additional convenience not impacting
> any of the existing targets, I would not have thought it terribly
> controversial.

It's additional maintenance, mostly. I don't have an objection to it, although I also don't see a reason to include it.

> Is there a place other than the git list where one can provide patches
> that are not likely to end up in git.git?

You could make a repo at repo.or.cz, I think. Have different branches to maintain features and rebase them on top of master periodically. Or just any random web-page to publish raw patches.

My $0.02, ~~ Brian

Peter Baumann· Jul 29, 2007, 22:26 UTC · re: David Kastrup · lore

Re: [PATCH] Makefile: create an install-symlinks target

On Sun, Jul 29, 2007 at 11:26:08PM +0200, David Kastrup wrote:
Show 19 quoted lines
> [commit text mostly pinched from INSTALL]
> 
> An alternative global installation method making it much easier to
> uninstall is to use a package-specific prefix like /opt/git, then
> create symlinks from /usr/local into that hierarchy.  Uninstalling can
> then be achieved by
> 
> 	# rm -rf /opt/git; find /usr/local -xtype l -delete
> 
> You can create a setup like that after having used one of the above
> install recipes with prefix=/opt/git by writing
> 
> 	# make prefix=/opt/git symlinkprefix=/usr/local install-symlinks
> 
> This works by copying the directory hierarchy of $prefix to
> $symlinkprefix (not copying or descending to any directories of the
> name git* matched case-insensitively), then linking all the rest.
> 
> Signed-off-by: David Kastrup <dak@gnu.org>

AFAIR I suggested this the last time this came up, but in case you missed it:

Use (x)stow for this. It does exactly what you want. No need to hack the Makefile.

-Peter

← back to recent threads