git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Makefile: create an install-symlinks target
@ 2007-07-29 21:26 David Kastrup
  2007-07-29 21:27 ` [PATCH] Makefile: use $(FIND) instead of find David Kastrup
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: David Kastrup @ 2007-07-29 21:26 UTC (permalink / raw)
  To: git

[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(-)

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

^ permalink raw reply related	[flat|nested] 13+ messages in thread
* [PATCH] Makefile: create an install-symlinks target
@ 2007-07-18 10:41 David Kastrup
  2007-07-18 12:41 ` David Kastrup
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: David Kastrup @ 2007-07-18 10:41 UTC (permalink / raw)
  To: git


Use this, for example, to do
rm -rf /opt/git
make prefix=/opt/git install
make symlinkprefix=/usr/local prefix=/opt/git install-symlinks
---
 Makefile |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 73b487f..df2fe8d 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
@@ -996,7 +997,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) && cd '$(prefix_SQ)' && find . -mindepth 1 -type d ! \( -iname 'git*' -prune -exec echo rm -rf '$(symlinkprefix)/{}' \; \) -exec echo $(INSTALL) -m 755 -d '$(symlinkprefix)/{}' \;
+	@cd '$(prefix_SQ)' && find . -mindepth 1 -type d ! \( -iname 'git*' -prune -exec rm -rf '$(symlinkprefix)/{}' \; \) -exec $(INSTALL) -m 755 -d '$(symlinkprefix)/{}' \;
+	@: $(MAKE) && cd '$(prefix_SQ)' && find . -mindepth 1 \( -type d -iname 'git*' -prune -o ! -type d \) -exec echo ln -snf '$(prefix_SQ)/{}' '$(symlinkprefix)/{}' \;
+	@cd '$(prefix_SQ)' && find . -mindepth 1 \( -type d -iname 'git*' -prune -o ! -type d \) -exec ln -snf '$(prefix_SQ)/{}' '$(symlinkprefix)/{}' \;
 
 ### Maintainer's dist rules
 
-- 
1.5.3.rc2.41.gb47b1

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

end of thread, other threads:[~2007-07-29 23:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-29 21:26 [PATCH] Makefile: create an install-symlinks target David Kastrup
2007-07-29 21:27 ` [PATCH] Makefile: use $(FIND) instead of find David Kastrup
2007-07-29 22:22   ` Junio C Hamano
2007-07-29 22:15 ` [PATCH] Makefile: create an install-symlinks target Junio C Hamano
2007-07-29 22:30   ` David Kastrup
2007-07-29 23:44     ` Brian Gernhardt
2007-07-29 22:26 ` Peter Baumann
  -- strict thread matches above, loose matches on Subject: below --
2007-07-18 10:41 David Kastrup
2007-07-18 12:41 ` David Kastrup
2007-07-18 12:48 ` Johannes Schindelin
2007-07-18 14:33   ` Peter Baumann
2007-07-18 13:08 ` Alex Riesen
2007-07-18 14:06   ` David Kastrup

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).