Skip to content
Newer
Older
100644 50 lines (40 sloc) 1.04 KB
04e7904 @rtomayko basic uninstall command
authored Mar 11, 2010
1 #!/bin/sh
2 set -e
4b1ed8b @rtomayko s/pgem/rpg/g on entire project
authored Mar 13, 2010
3 . rpg-sh-setup
9abeb5c @rtomayko usage and logging cleanup across the board
authored Mar 13, 2010
4
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 19, 2010
5 [ "$*" ] || set -- --help; ARGV="$@"
6 USAGE '${PROGNAME} <package>...
7 Uninstall packages from local system.'
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
8
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
9 # If more than one package was given, re-exec for each package:
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
10 test $# -gt 1 && {
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
11 echo "$@" | xargs -n 1 rpg-uninstall
12 exit $?
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
13 }
14
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
15 package="$1"
16 packagedir="$RPGDB/$package"
17 manifest="$packagedir/active/manifest"
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
18
19 # Bail out if the db doesn't have this package or the package
20 # isn't active.
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
21 test -d "$packagedir" -a -f "$manifest" || {
b4137c6 @rtomayko rpg-uninstall typo
authored Apr 1, 2010
22 warn "$package is not installed"
9abeb5c @rtomayko usage and logging cleanup across the board
authored Mar 13, 2010
23 exit 1
24 }
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
25
26 # Grab the currently installed version from the active symlink.
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
27 version=$(readlink "$packagedir/active")
28 notice "$package $version"
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
29
30 # Remove all files installed by this package
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
31 grep -v '^#' <"$packagedir/active/manifest" |
32 if $RPGVERBOSE
33 then
34 while read file
35 do notice "$file [unlink]"
36 echo "$file"
37 done
38 else
39 cat
40 fi |
75914fa @rtomayko rpg-uninstall doesn't die when unlink fails
authored Apr 2, 2010
41 { xargs -P 4 -n 1 unlink || true; }
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
42
36af74d @josh cleanup empty lib dirs on uninstall
josh authored Mar 23, 2010
43 # Cleanup empty directories
44 find $RPGLIB -depth -type d -empty -exec rmdir {} \;
45
04e7904 @rtomayko basic uninstall command
authored Mar 12, 2010
46 # Unlink the active symlink
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
47 unlink "$packagedir/active"
9abeb5c @rtomayko usage and logging cleanup across the board
authored Mar 13, 2010
48
c51bcb3 @rtomayko uninstall prior package versions before installing new ones
authored Mar 20, 2010
49 true
Something went wrong with that request. Please try again.