X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-update;h=fcfb81668887476ce4aa872a051cb262dd312d92;hb=89a160b4762730e078ed8d2e5c212a51f17ac6f8;hp=3423ff6bdcd03248643ecc8872df09fa90c28aca;hpb=881763b16a50b342676f3d59c2d883e2c39548ff;p=zpackage diff --git a/zpm-update b/zpm-update index 3423ff6..fcfb816 100755 --- a/zpm-update +++ b/zpm-update @@ -31,6 +31,7 @@ die() { zpm log -i -a 'aborted install' -t "$pkgid" "$*" changeall installing changeall removing installed + changeall updating installed exit 1 } @@ -101,10 +102,14 @@ install_for_libs='' backup=0 ignorelibdeps=0 justlist=0 +pullrepos=1 + +# 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:nSCvAObBLUz opt; do case $opt in f) pkgfile="$OPTARG" ;; d) localdb="$OPTARG" ;; @@ -121,6 +126,8 @@ while getopts f:d:R:nSCvAObBL opt; do B) backup=0 ;; L) ignorelibdeps=1 ;; l) justlist=1 ;; + U) uninstall=1 ;; + z) pullrepos=0 ;; *) die "usage ..." ;; esac done @@ -140,8 +147,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 +163,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 @@ -164,6 +182,11 @@ search=$(echo $search) ebail=0 +if [ $pullrepos -eq 1 ]; then + echo pulling repos + zpm repo pull +fi + if [ $ignorelibdeps -eq 1 ]; then merge=$(zpm search -iIO $search) else @@ -222,6 +245,12 @@ if [ -n "$baddl" ]; then die fi +for package in $merge; do + pkgid=${package%:*} + installlist="$installlist $pkgid" +done +installlist=${installlist#' '} + if [ $justlist -eq 1 ]; then for package in $merge; do pkgid=${package%:*} @@ -230,6 +259,7 @@ if [ $justlist -eq 1 ]; then for pkgid in $to_remove; do printf 'remove %s\n' $pkgid done + exit 0 fi if [ -z "$merge" ] && [ -z "$to_remove" ]; then @@ -237,7 +267,8 @@ if [ -z "$merge" ] && [ -z "$to_remove" ]; then exit 0 fi -echo "merge: $merge" +test -n "$merge" && echo "install: $installlist" +test -n "$to_remove" && echo "remove: $to_remove" # finally, merge everything for mergepkg in $merge; do @@ -250,6 +281,9 @@ for mergepkg in $merge; do if [ $pkgfile != $ZPMDB ]; then echo merging $pkgfile $pkgid zpm merge -Fuv -f "$pkgfile" $pkgid + if [ $? -ne 0 ]; then + die "unable to merge $pkgfile" + fi fi to_install="$to_install $pkgid" done @@ -277,6 +311,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 +353,7 @@ if [ -n "$to_remove" ]; then fi changeall removing removed +changeall updating updated echo running ldconfig run_ldconfig $rootdir