This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

uninstall prior package versions before installing new ones

  • Loading branch information...
rtomayko committed Mar 20, 2010
1 parent 39c939b commit c51bcb3ec61ec35021258169a4bd09bbfe2ed216
Showing with 30 additions and 28 deletions.
  1. +5 −7 rpg-package-install.sh
  2. +25 −21 rpg-uninstall.sh
View
@@ -78,7 +78,7 @@ test "$version" = '=' && { version="$1"; shift; }
packagedir="$RPGDB/$package"
test -d "$packagedir/$version" || {
- warn "package not registered: $package/$version"
+ warn "package not registered: $package $version"
exit 1
}
@@ -96,23 +96,21 @@ else rm -rf "$RPGPACKS/$package-$version"
rpg-shit-list "$package" "$version" "$RPGPACKS/$package-$version"
fi
-# If the package already has an active/installed version, check if its
+# If the package already has an active/installed version, check if it's
# the same as the one we're installing and bail if so. Otherwise unlink
# the active version and install over it for now.
-#
-# TODO handle uninstalling previous package version or fail or something.
test -e "$packagedir/active" && {
activevers=$(readlink $packagedir/active)
if test "$activevers" = "$version"
then
if $force
- then notice "$package $version is current. reinstalling due to -f"
+ then notice "$package $version is current; reinstalling due to -f"
unlink "$packagedir/active"
- else notice "$package $version is current. not reinstalling."
+ else notice "$package $version is current; skipping package install"
exit 0
fi
else notice "$package $activevers is installed but $version requested"
- unlink "$packagedir/active"
+ rpg-uninstall "$package"
fi
}
View
@@ -2,41 +2,45 @@
set -e
. rpg-sh-setup
-ARGV="$@"
-USAGE '${PROGNAME} <name>
-Uninstall package from rpg environment.'
+[ "$*" ] || set -- --help; ARGV="$@"
+USAGE '${PROGNAME} <package>...
+Uninstall packages from local system.'
+# If more than one package was given, re-exec for each package:
test $# -gt 1 && {
- echo "$@" |
- xargs -n 1 rpg uninstall
- exit
+ echo "$@" | xargs -n 1 rpg-uninstall
+ exit $?
}
-name="$1"
-
-# Get the manifest file going.
-dbdir="$RPGDB/$name"
-manifest="$dbdir/active/manifest"
+package="$1"
+packagedir="$RPGDB/$package"
+manifest="$packagedir/active/manifest"
# Bail out if the db doesn't have this package or the package
# isn't active.
-test -d "$dbdir" -a -f "$manifest" || {
+test -d "$packagedir" -a -f "$manifest" || {
warn "$name is not installed"
exit 1
}
# Grab the currently installed version from the active symlink.
-vers=$(readlink "$dbdir/active")
+version=$(readlink "$packagedir/active")
+notice "$package $version"
# Remove all files installed by this package
-cat "$dbdir/active/manifest" |
-grep -v '^#' |
-xargs -n 1 unlink
+grep -v '^#' <"$packagedir/active/manifest" |
+if $RPGVERBOSE
+then
+ while read file
+ do notice "$file [unlink]"
+ echo "$file"
+ done
+else
+ cat
+fi |
+xargs -P 4 -n 1 unlink
# Unlink the active symlink
-unlink "$dbdir/active"
-
-notice "$name $vers"
+unlink "$packagedir/active"
-# Better safe than sorry.
-:
+true

0 comments on commit c51bcb3

Please sign in to comment.