X-Git-Url: https://pd.if.org/git/?p=zpackage;a=blobdiff_plain;f=zpm-uninstall;h=4b3efa1c81175feb7b6dffe3b840dac414bbd921;hp=17ce69bb29749c3801ff2da71f5724d4e047d858;hb=09c80a1f8918d888063f4d1a75921a99fe5f0b5c;hpb=903da5cc8edf74516b98027fb67a25eb407c2f4d diff --git a/zpm-uninstall b/zpm-uninstall index 17ce69b..4b3efa1 100755 --- a/zpm-uninstall +++ b/zpm-uninstall @@ -1,147 +1,5 @@ #!/bin/sh -die() { - echo $* 1>&2 - exit 1 -} +# just a wrapper -dryrun=0 -verbose=0 -runscripts=1 -runconfigure=1 -localdb=/var/lib/zpm/local.db -absorb=0 - -# zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ... -while getopts f:d:R:nSCvA opt; do - case $opt in - A) absorb=1 ;; - f) pkgfile="$OPTARG" ;; - d) localdb="$OPTARG" ;; - R) rootdir="$OPTARG" ;; - S) runscripts=0 ;; - C) runconfigure=0 ;; - n) dryrun=1 ;; - v) verbose=1 ;; - *) die "usage ..." ;; - esac -done -shift $(( OPTIND - 1)) - -pkgid=$1 - -if [ -z "$pkgid" ]; then - die "must specify pkgid" -fi - -eval "$(zpm parse -E $pkgid)" - -if [ -z "$pkgfile" ]; then - pkgfile=$ZPM_PACKAGE_FILE -fi - -# cases C = create ok, R = full package id, F = specified package file - -# immediate error -# C-- 100 error, must specify something -# --- 000 error, must specify something -if [ -z "$release" ] && [ -z "$pkgfile" ]; then - die must specify package file or complete package id -fi - -# TODO look in package file -# --F 001 error, wouldn't know which pkgid to create, could derive from file? -# C-F 101 error, since package wouldn't exist in file to find -if [ -z "$release" ]; then - die must specify complete package id -fi - -# set file from pkgid -# CR- 110 set file from pkgid, create if needed -# -R- 010 set file from pkgid, create in file, error if no file -if [ -z "$pkgfile" ]; then - pkgfile="$pkgid.zpm" -fi - -# will now be one of these -# CRF 111 create package in file given, create file if needed -# -RF 011 create package in file, error if file doesn't exist -if [ ! -f "$pkgfile" ]; then - if [ $create -eq 1 ]; then - zpm init $pkgfile - else - die $pkgfile does not exist - fi -fi - -if [ "$idempotent" = 1 ]; then - idempotent='or ignore' -fi - -package=$(zpm quote "$name") -pkgver=$(zpm quote "$version") -pkgrel=$(zpm quote "$release") - -ZPMDB=$localdb -export ZPMDB - -if [ -z "$ZPMDB" ]; then - die "no local db" -else - #echo "localdb = $ZPMDB" - true -fi - -zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database" - -# check if we're installing something already -var=$(zpm list -f $localdb -s installing | wc -l) -if [ $var -gt 0 ]; then - zpm list -v -f $localdb -s installing - die "already ($localdb) installing $var package(s)" -fi - -if [ -n "$rootdir" ]; then - ZPM_ROOT_DIR="$rootdir" - export ZPM_ROOT_DIR -fi - -for pkgstr in "$@"; do - echo removing $pkgstr from $ZPMDB - pkgid=$(zpm findpkg -s installed -f $ZPMDB $pkgstr) - if [ $? -ne 0 ]; then - die "$pkgid is not installed" - fi - - eval $(zpm parse -E $pkgid) - echo found $name $version $release - - if [ $runscripts -gt 0 ]; then - zpm script -r -f $pkgfile -p pre-uninstall $pkgid $current - if [ $? -ne 0 ]; then - # TODO log - die "pre-uninstall script for $pkgid failed" - fi - fi - - zpm pkg $pkgid status=removing - - #zpm shell $ZPMDB 'select * from install_status' 1>&2 - if [ $dryrun -gt 0 ]; then - zpm syncfs -nv - zpm pkg $pkgid status=dryrun - continue - fi - - zpm syncfs - - if [ $? -ne 0 ]; then - die 'zpm-pkgfiles failed'; - fi - - zpm pkg $pkgid status=removed - - if [ $runscripts -gt 0 ]; then - zpm script -r -p post-uninstall $pkgid - fi -done +zpm update -U "$@"