]> pd.if.org Git - zpackage/blobdiff - zpm-install
change findpkg to use -f option
[zpackage] / zpm-install
old mode 100644 (file)
new mode 100755 (executable)
index 13a8dcf..47681d3
@@ -6,19 +6,22 @@ die() {
 }
 
 dryrun=0
+verbose=0
 runscripts=1
 runconfigure=1
 localdb=/var/lib/zpm/local.db
 
 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
-while getopts :f:d:R:nSC opt; do
+while getopts f:d:R:nSCv opt; do
        case $opt in
                f) pkgfile="$OPTARG" ;;
                d) localdb="$OPTARG" ;;
                R) rootdir="$OPTARG" ;;
                S) runscripts=0 ;;
                C) runconfigure=0 ;;
-               n) dryrun=1
+               n) dryrun=1 ;;
+               v) verbose=1 ;;
+               *) die "usage ..." ;;
        esac
 done
 shift $(( OPTIND - 1))
@@ -44,6 +47,7 @@ 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
@@ -68,8 +72,6 @@ if [ ! -f "$pkgfile" ]; then
        fi
 fi
 
-set -e
-
 if [ "$idempotent" = 1 ]; then
        idempotent='or ignore'
 fi
@@ -81,13 +83,34 @@ 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 -ge 0 ]; then
-       die 'already installing'
+if [ $var -gt 0 ]; then
+       zpm list -v -f $localdb -s installing 
+       die "already ($localdb) installing $var package(s)"
+fi
+# check if we're installing something already
+var=$(zpm list -f $localdb -s removing | wc -l)
+if [ $var -gt 0 ]; then
+       zpm list -v -f $localdb -s removing 
+       die "already ($localdb) removing $var package(s)"
+fi
+var=$(zpm list -f $localdb -s updating | wc -l)
+if [ $var -gt 0 ]; then
+       zpm list -v -f $localdb -s updating 
+       die "already ($localdb) updating $var package(s)"
 fi
 
-if [ -n "$rootdir" ];
+if [ -n "$rootdir" ]; then
        ZPM_ROOT_DIR="$rootdir"
        export ZPM_ROOT_DIR
 fi
@@ -107,10 +130,11 @@ for pkgstr in "$@"; do
 
        eval $(zpm parse -E $pkgid)
 
+       #zpm list -v
        current=$(zpm list -s installed "$package")
        
        if [ $runscripts -gt 0 ]; then
-               zpm runscript -f $packagefile -p pre-install $pkgid $current
+               zpm runscript -f $pkgfile -p pre-install $pkgid $current
                if [ $? -ne 0 ]; then
                        # TODO log
                        die "pre-install script for $pkgid failed"
@@ -125,14 +149,35 @@ for pkgstr in "$@"; do
                        die "merging $pkgid failed"
                fi
        fi
+       # TODO but need to mark as installing if not merged
+
+       #zpm shell $ZPMDB 'select * from install_status' 1>&2
+       if [ $dryrun -gt 0 ]; then
+               #zpm list -v
+               #zpm shell $ZPMDB 'select * from install_status'
+               zpm syncfs -nv -f $pkgfile
+               zpm pkg $pkgid status=dryrun
+               continue
+       fi
+
+       zpm syncfs -f $pkgfile
+
+       if [ $? -ne 0 ]; then
+               die 'zpm-syncfs failed';
+       fi
 
-       zpm pkgfiles -f $pkgfile $pkgid
        if [ $runscripts -gt 0 ]; then
                zpm runscript -f $pkgfile -p post-install $pkgid $current
        fi
-       # need a way to update multiple statuses all in one
-       # zpm pkgstatus $pkgid installed $pkgid updated
-       zpm pkg $pkgid status installed
+
+       if [ -n "$current" ]; then
+               zpm pkg $pkgid status=installed :$current status=updated
+       else
+               zpm pkg $pkgid status=installed
+       fi
+
+       # TODO skip configure if not on a terminal, regardless of settings
+       # TODO will need force option
        if [ $runconfigure -gt 0 ]; then
                zpm runscript -f $pkgfile -p configure $pkgid $current
        fi