Skip to content

Commit 042f53c

Browse files
committed
git-gui: Provide 'uninstall' Makefile target to undo an installation
Several users have requested a "make uninstall" target be provided in the stock git-gui Makefile so that they can undo an install if git-gui goes to the wrong place during the initial install, or if they are unhappy with the tool and want to remove it from their system. We currently assume that the complete set of files we need to delete are those defined by our Makefile and current source directory. This could differ from what the user actually has installed if they installed one version then attempt to use another to perform the uninstall. Right now I'm just going to say that is "pilot error". Users should uninstall git-gui using the same version of source that they used to make the installation. Perhaps in the future we could read tclIndex and base our uninstall decisions on its contents. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
1 parent afe2098 commit 042f53c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Makefile

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ ifndef INSTALL
3131
INSTALL = install
3232
endif
3333

34+
RM_F ?= rm -f
35+
RMDIR ?= rmdir
36+
3437
INSTALL_D0 = $(INSTALL) -d -m755 # space is required here
3538
INSTALL_D1 =
3639
INSTALL_R0 = $(INSTALL) -m644 # space is required here
@@ -42,6 +45,12 @@ INSTALL_L1 = && ln # space is required here
4245
INSTALL_L2 =
4346
INSTALL_L3 =
4447

48+
REMOVE_D0 = $(RMDIR) # space is required here
49+
REMOVE_D1 = || true
50+
REMOVE_F0 = $(RM_F) # space is required here
51+
REMOVE_F1 =
52+
CLEAN_DST = true
53+
4554
ifndef V
4655
QUIET = @
4756
QUIET_GEN = $(QUIET)echo ' ' GEN $@ &&
@@ -60,6 +69,12 @@ ifndef V
6069
INSTALL_L1 = && src=
6170
INSTALL_L2 = && dst=
6271
INSTALL_L3 = && echo ' ' 'LINK ' `basename "$$dst"` '->' `basename "$$src"` && rm -f "$$dst" && ln "$$src" "$$dst"
72+
73+
CLEAN_DST = echo ' ' UNINSTALL
74+
REMOVE_D0 = dir=
75+
REMOVE_D1 = && echo ' ' REMOVE $$dir && test -d "$$dir" && $(RMDIR) "$$dir" || true
76+
REMOVE_F0 = dst=
77+
REMOVE_F1 = && echo ' ' REMOVE `basename "$$dst"` && $(RM_F) "$$dst"
6378
endif
6479

6580
TCL_PATH ?= tclsh
@@ -146,6 +161,17 @@ install: all
146161
$(QUIET)$(INSTALL_R0)lib/tclIndex $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)'
147162
$(QUIET)$(foreach p,$(ALL_LIBFILES), $(INSTALL_R0)$p $(INSTALL_R1) '$(DESTDIR_SQ)$(libdir_SQ)' &&) true
148163

164+
uninstall:
165+
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
166+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
167+
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
168+
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(libdir_SQ)'
169+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/tclIndex $(REMOVE_F1)
170+
$(QUIET)$(foreach p,$(ALL_LIBFILES), $(REMOVE_F0)'$(DESTDIR_SQ)$(libdir_SQ)'/$(notdir $p) $(REMOVE_F1) &&) true
171+
$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(REMOVE_D1)
172+
$(QUIET)$(REMOVE_D0)'$(DESTDIR_SQ)$(libdir_SQ)' $(REMOVE_D1)
173+
$(QUIET)$(REMOVE_D0)`dirname '$(DESTDIR_SQ)$(libdir_SQ)'` $(REMOVE_D1)
174+
149175
dist-version:
150176
@mkdir -p $(TARDIR)
151177
@echo $(GITGUI_VERSION) > $(TARDIR)/version
@@ -154,6 +180,6 @@ clean::
154180
rm -f $(ALL_PROGRAMS) lib/tclIndex
155181
rm -f GIT-VERSION-FILE GIT-GUI-VARS
156182

157-
.PHONY: all install dist-version clean
183+
.PHONY: all install uninstall dist-version clean
158184
.PHONY: .FORCE-GIT-VERSION-FILE
159185
.PHONY: .FORCE-GIT-GUI-VARS

0 commit comments

Comments
 (0)