Skip to content

Commit

Permalink
Add uninstall target
Browse files Browse the repository at this point in the history
Fixes #417
  • Loading branch information
jonas committed Jun 15, 2015
1 parent 9d82649 commit eecfbda
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .travis.yml
Expand Up @@ -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
14 changes: 14 additions & 0 deletions Makefile
Expand Up @@ -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
Expand Down Expand Up @@ -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 '$@;)
Expand Down
1 change: 1 addition & 0 deletions NEWS.adoc
Expand Up @@ -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:

Expand Down
35 changes: 35 additions & 0 deletions tools/uninstall.sh
@@ -0,0 +1,35 @@
#!/bin/sh
#
# Uninstall data or executable file.
#
# Usage: $0 dest
#
# Copyright (c) 2015 Jonas Fonseca <jonas.fonseca@gmail.com>
#
# 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"

0 comments on commit eecfbda

Please sign in to comment.