From eecfbda7f510ed0b98d146a1aded7c004d3ddb54 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 15 Jun 2015 08:50:55 -0400 Subject: [PATCH] Add uninstall target Fixes #417 --- .travis.yml | 10 +++++++++- Makefile | 14 ++++++++++++++ NEWS.adoc | 1 + tools/uninstall.sh | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 tools/uninstall.sh diff --git a/.travis.yml b/.travis.yml index c4520fc61..56ee50b17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,12 +11,20 @@ install: sudo apt-get install -qq --no-install-recommends asciidoc xmlto docbook script: - # ============ Build from config =============== - cp contrib/config.make . - - make DESTDIR=/tmp/bare-prefix all-debug install install-doc + - make all-debug - make test - make test TEST_OPTS=valgrind + - make DESTDIR=/tmp/bare-destdir install install-doc + - make DESTDIR=/tmp/bare-destdir uninstall + - test ! -d /tmp/bare-destdir + - make prefix=/tmp/bare-prefix install install-doc + - make prefix=/tmp/bare-prefix uninstall + - test ! -d /tmp/bare-prefix - make distclean - # ============ Build using autoconf ============ - make dist - ./configure --prefix=/tmp/conf-prefix - make V=1 TEST_SHELL=bash all test install install-doc + - make uninstall + - test ! -d /tmp/conf-prefix - make clean diff --git a/Makefile b/Makefile index 7d11c8f5f..d7469e85c 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,18 @@ install-release-doc-html: install-doc: install-doc-man install-doc-html install-release-doc: install-release-doc-man install-release-doc-html +uninstall: + $(QUIET_UNINSTALL)tools/uninstall.sh "$(DESTDIR)$(bindir)/$(EXE:src/%=%)" + $(QUIET_UNINSTALL)tools/uninstall.sh "$(DESTDIR)$(sysconfdir)/tigrc" + $(Q)$(foreach doc, $(filter %.1, $(MANDOC:doc/%=%)), \ + $(QUIET_UNINSTALL_EACH)tools/uninstall.sh "$(DESTDIR)$(mandir)/man1/$(doc)";) + $(Q)$(foreach doc, $(filter %.5, $(MANDOC:doc/%=%)), \ + $(QUIET_UNINSTALL_EACH)tools/uninstall.sh "$(DESTDIR)$(mandir)/man5/$(doc)";) + $(Q)$(foreach doc, $(filter %.7, $(MANDOC:doc/%=%)), \ + $(QUIET_UNINSTALL_EACH)tools/uninstall.sh "$(DESTDIR)$(mandir)/man7/$(doc)";) + $(Q)$(foreach doc, $(HTMLDOC:doc/%=%), \ + $(QUIET_UNINSTALL_EACH)tools/uninstall.sh "$(DESTDIR)$(docdir)/tig/$(doc)";) + clean: clean-test clean-coverage $(Q)$(RM) -r $(TARNAME) *.spec tig-*.tar.gz tig-*.tar.gz.md5 .deps $(Q)$(RM) $(EXE) $(TOOLS) $(OBJS) core doc/*.xml src/builtin-config.c @@ -366,6 +378,8 @@ QUIET_DB2PDF = $(Q:@=@echo ' DB2PDF '$@;) # tools/install.sh will print 'file -> $install_dir/file' QUIET_INSTALL = $(Q:@=@printf ' INSTALL ';) QUIET_INSTALL_EACH = $(Q:@=printf ' INSTALL ';) +QUIET_UNINSTALL = $(Q:@=@printf ' UNINSTALL ';) +QUIET_UNINSTALL_EACH = $(Q:@=printf ' UNINSTALL ';) QUIET_TEST = $(Q:@=@echo ' TEST '$@;) QUIET_SUMMARY = $(Q:@=@printf ' SUMMARY ';) QUIET_LCOV = $(Q:@=@echo ' LCOV '$@;) diff --git a/NEWS.adoc b/NEWS.adoc index a94d17ad4..f710b7d63 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -23,6 +23,7 @@ Improvements: - `tig --merge` implies `--boundary` similar to gitk. - Expose repository variables to external commands, e.g. `%(repo:head)` gives the branch name of the current HEAD and `%(repo:cdup)` for the repo root path. + - Add `make uninstall`. (GH #417) Bug fixes: diff --git a/tools/uninstall.sh b/tools/uninstall.sh new file mode 100755 index 000000000..c31124942 --- /dev/null +++ b/tools/uninstall.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# +# Uninstall data or executable file. +# +# Usage: $0 dest +# +# Copyright (c) 2015 Jonas Fonseca +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +set -e + +file="$1" +dir="$(dirname "$file")" + +if [ -d "$file" -a "$dir" = "tig" ]; then + rm -rf "$file" +elif [ -f "$file" ]; then + rm -f "$file" +fi + +if [ -d "$dir" ]; then + set +e + rmdir -p "$dir" 2>/dev/null +fi + +echo "$file"