zpm log -i -a 'aborted install' -t "$pkgid" "$*"
changeall installing
changeall removing installed
+ changeall updating installed
exit 1
}
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:nSCvAObBLUzp opt; do
case $opt in
f) pkgfile="$OPTARG" ;;
d) localdb="$OPTARG" ;;
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
-*) 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"
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
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
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%:*}
for pkgid in $to_remove; do
printf 'remove %s\n' $pkgid
done
+ exit 0
fi
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
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
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
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
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"
fi
changeall removing removed
+changeall updating updated
echo running ldconfig
run_ldconfig $rootdir