]> pd.if.org Git - zpackage/blobdiff - zpm-update
add option to simplify uninstalls
[zpackage] / zpm-update
index 3423ff6bdcd03248643ecc8872df09fa90c28aca..44529783408c1c195c4524ae071d53e574c3622a 100755 (executable)
@@ -31,6 +31,7 @@ die() {
        zpm log -i -a 'aborted install' -t "$pkgid" "$*"
        changeall installing
        changeall removing installed
+       changeall updating installed
        exit 1
 }
 
@@ -102,9 +103,12 @@ backup=0
 ignorelibdeps=0
 justlist=0
 
+# treat un-adorned packages as uninstalls
+uninstall=0
+
 # TODO option to attempt to resume an ongoing install
 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
-while getopts f:d:R:nSCvAObBL opt; do
+while getopts f:d:R:nSCvAObBLU opt; do
        case $opt in
                f) pkgfile="$OPTARG" ;;
                d) localdb="$OPTARG" ;;
@@ -121,6 +125,7 @@ while getopts f:d:R:nSCvAObBL opt; do
                B) backup=0 ;;
                L) ignorelibdeps=1 ;;
                l) justlist=1 ;;
+               U) uninstall=1 ;;
                *) die "usage ..." ;;
        esac
 done
@@ -140,8 +145,9 @@ for op in "$@"; do
                -*) pkgid=$(zpm findpkg -I "${op#-}")
                        if [ -n "$pkgid" ]; then
                                to_remove="$to_remove $pkgid"
+                       else
+                               die "$op not installed"
                        fi
-                       # else warn not installed
                        ;;
                +*) pkg=${op#+}
                        search="$search $pkg"
@@ -155,7 +161,17 @@ for op in "$@"; do
                                die "can't find $pkg in $file"
                        fi
                        ;;
-               *) search="$search $op"
+               *)
+                       if [ $uninstall -eq 0 ]; then
+                               search="$search $op"
+                       else
+                               pkgid=$(zpm findpkg -I "${op}")
+                               if [ -n "$pkgid" ]; then
+                                       to_remove="$to_remove $pkgid"
+                               else
+                                       die "$op not installed"
+                               fi
+                       fi
                        ;;
        esac
 done
@@ -277,6 +293,7 @@ if [ -n "$to_install" ]; then
        for pkgid in $to_install; do
                zpm pkg $pkgid status=installing
        done
+       zpm shell "$ZPMDB" "update packages set status='updating' where status='installed' and package in (select package from packages where status = 'installing')"
 fi
 
 if [ -n "$to_remove" ]; then
@@ -318,6 +335,7 @@ if [ -n "$to_remove" ]; then
 fi
 
 changeall removing removed
+changeall updating updated
 
 echo running ldconfig
 run_ldconfig $rootdir