X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-install;h=994ed195d14bc5c24ed7a68d4b0e24eaaa9bba1a;hb=f12e588273d9a3ffc97c20a7075845dff68905e4;hp=13a8dcf5bc4e8bde3e7d3803cc02d4639adbadd8;hpb=51f45dbb730de79b22875305cf83eeb32e7b096d;p=zpackage diff --git a/zpm-install b/zpm-install old mode 100644 new mode 100755 index 13a8dcf..994ed19 --- a/zpm-install +++ b/zpm-install @@ -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,20 +83,30 @@ 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 -if [ -n "$rootdir" ]; +if [ -n "$rootdir" ]; then ZPM_ROOT_DIR="$rootdir" export ZPM_ROOT_DIR fi # TODO mark already installed packages as updating? for pkgstr in "$@"; do - pkgid=$(zpm findpkg -f $pkgfile $pkgstr) + pkgid=$(zpm findpkg $pkgfile $pkgstr) if [ $? -ne 0 ]; then # TODO log die "can't find package $pkgstr in $pkgfile" @@ -110,7 +122,7 @@ for pkgstr in "$@"; do 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" @@ -126,13 +138,30 @@ for pkgstr in "$@"; do fi fi + if [ $dryrun -gt 0 ]; then + #zpm list -v + #zpm shell $ZPMDB 'select * from install_status' + zpm pkgfiles -nv -f $pkgfile $pkgid + zpm pkg $pkgid status=dryrun + continue + fi + zpm pkgfiles -f $pkgfile $pkgid + + if [ $? -ne 0 ]; then + die 'zpm-pkgfiles failed'; + fi + 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 + if [ $runconfigure -gt 0 ]; then zpm runscript -f $pkgfile -p configure $pkgid $current fi