12 localdb=/var/lib/zpm/local.db
15 # zpm-install [-SCn] [ -d localdb ] [ -f pkgfile ] [ -R installroot ] pkgstr ...
16 while getopts f:d:R:nSCvA opt; do
19 f) pkgfile="$OPTARG" ;;
20 d) localdb="$OPTARG" ;;
21 R) rootdir="$OPTARG" ;;
29 shift $(( OPTIND - 1))
33 if [ -z "$pkgid" ]; then
34 die "must specify pkgid"
37 eval "$(zpm parse -E $pkgid)"
39 if [ -z "$pkgfile" ]; then
40 pkgfile=$ZPM_PACKAGE_FILE
43 # cases C = create ok, R = full package id, F = specified package file
46 # C-- 100 error, must specify something
47 # --- 000 error, must specify something
48 if [ -z "$release" ] && [ -z "$pkgfile" ]; then
49 die must specify package file or complete package id
52 # TODO look in package file
53 # --F 001 error, wouldn't know which pkgid to create, could derive from file?
54 # C-F 101 error, since package wouldn't exist in file to find
55 if [ -z "$release" ]; then
56 die must specify complete package id
60 # CR- 110 set file from pkgid, create if needed
61 # -R- 010 set file from pkgid, create in file, error if no file
62 if [ -z "$pkgfile" ]; then
66 # will now be one of these
67 # CRF 111 create package in file given, create file if needed
68 # -RF 011 create package in file, error if file doesn't exist
69 if [ ! -f "$pkgfile" ]; then
70 if [ $create -eq 1 ]; then
73 die $pkgfile does not exist
77 if [ "$idempotent" = 1 ]; then
78 idempotent='or ignore'
81 package=$(zpm quote "$name")
82 pkgver=$(zpm quote "$version")
83 pkgrel=$(zpm quote "$release")
88 if [ -z "$ZPMDB" ]; then
91 #echo "localdb = $ZPMDB"
95 zpm test -v "$ZPMDB" || die "$ZPMDB is not a zpm database"
97 # check if we're installing something already
98 var=$(zpm list -f $localdb -s installing | wc -l)
99 if [ $var -gt 0 ]; then
100 zpm list -v -f $localdb -s installing
101 die "already ($localdb) installing $var package(s)"
104 if [ -n "$rootdir" ]; then
105 ZPM_ROOT_DIR="$rootdir"
109 for pkgstr in "$@"; do
110 echo removing $pkgstr from $ZPMDB
111 pkgid=$(zpm findpkg -s installed -f $ZPMDB $pkgstr)
112 if [ $? -ne 0 ]; then
113 die "$pkgid is not installed"
116 eval $(zpm parse -E $pkgid)
117 echo found $name $version $release
119 if [ $runscripts -gt 0 ]; then
120 zpm script -r -f $pkgfile -p pre-uninstall $pkgid $current
121 if [ $? -ne 0 ]; then
123 die "pre-uninstall script for $pkgid failed"
127 zpm pkg $pkgid status=removing
129 #zpm shell $ZPMDB 'select * from install_status' 1>&2
130 if [ $dryrun -gt 0 ]; then
132 zpm pkg $pkgid status=dryrun
138 if [ $? -ne 0 ]; then
139 die 'zpm-pkgfiles failed';
142 zpm pkg $pkgid status=removed
144 if [ $runscripts -gt 0 ]; then
145 zpm script -r -p post-uninstall $pkgid