X-Git-Url: https://pd.if.org/git/?p=zpackage;a=blobdiff_plain;f=zpm-update;h=e1accc87393faf4acf73923aa0e8d2b9399c6c6f;hp=c85b0edf9fc7e9944015da2659cd6c160008ae5a;hb=69491d14441cfc893e18e1c60c13c995b93002c9;hpb=1323381f0eeb38466d8afc185a5295e4b5024bd5 diff --git a/zpm-update b/zpm-update index c85b0ed..e1accc8 100755 --- a/zpm-update +++ b/zpm-update @@ -102,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:nSCvAObBLUzpl opt; do case $opt in f) pkgfile="$OPTARG" ;; d) localdb="$OPTARG" ;; @@ -122,13 +126,28 @@ while getopts f:d:R:nSCvAObBL opt; do B) backup=0 ;; L) ignorelibdeps=1 ;; l) justlist=1 ;; + U) uninstall=1 ;; + z) pullrepos=0 ;; + p) syncopts="$syncopts -p" ;; *) die "usage ..." ;; esac done -shift $(( OPTIND - 1)) +shift $(( OPTIND - 1 )) + +if [ -n "$rootdir" ]; then + : rootdir=${rootdir%%/} + ZPM_ROOT_DIR=$rootdir + export ZPM_ROOT_DIR +fi + +if [ -n "$localdb" ]; then + ZPMDB=$localdb +elif [ -z "$ZPMDB" ]; then + ZPMDB="$ZPM_ROOT_DIR/var/lib/zpm/local.db" +fi -ZPMDB=${localdb:-${ZPMDB:-/var/lib/zpm/local.db}} export ZPMDB + # create the localdb if needed zpm init $ZPMDB @@ -141,8 +160,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" @@ -156,7 +176,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 @@ -165,8 +195,15 @@ 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) + # TODO search for libs anyway and put a note for non-installed + # library deps else merge=$(zpm search -iIO -l $search) fi @@ -202,7 +239,6 @@ for mergepkg in $merge; do nlist="$nlist $pkgid:$zpmfile" continue else - echo downloading $zpmfile zpm repo fetch $reponame $pkgid if [ -f "$zpmfile" ]; then nlist="$nlist $pkgid:$zpmfile" @@ -223,6 +259,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%:*} @@ -231,6 +273,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 @@ -238,7 +281,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,14 +294,19 @@ for mergepkg in $merge; do # TODO check for symlinks? if [ $pkgfile != $ZPMDB ]; then echo merging $pkgfile $pkgid - zpm merge -Fuv -f "$pkgfile" $pkgid + zpm merge -Fu -f "$pkgfile" $pkgid + if [ $? -ne 0 ]; then + die "unable to merge $pkgfile" + fi fi to_install="$to_install $pkgid" done to_install=${to_install#' '} -echo "installing: $to_install" +if [ -n "$to_install" ]; then + echo "installing: $to_install" +fi # absorb anything we're updating or removing, if absorb flag set @@ -287,12 +336,6 @@ if [ -n "$to_remove" ]; then done fi -if [ -n "$rootdir" ]; then - ZPM_ROOT_DIR=$rootdir - export ZPM_ROOT_DIR - : rootdir=${rootdir%%/} -fi - if [ $dryrun -gt 0 ]; then runscripts=0 # we don't want to run post scripts on a dry-run syncopts="$syncopts -n" @@ -300,10 +343,11 @@ fi if [ $verbose -gt 0 ]; then syncopts="${syncopts} -v" -else - # force -v during development - syncopts="${syncopts} -v" fi +#else + # force -v during development + #syncopts="${syncopts} -v" +#fi if [ $dryrun -eq 0 ] && [ $backup -eq 1 ]; then true