+# cases R = full package id, F = specified package file
+
+# immediate error
+# -- 00 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 01 error, wouldn't know which pkgid to create, could derive from file?
+if [ -z "$release" ]; then
+ # must have package file, or would have died above
+ pkgid=$(zpm findpkg -f $pkgfile $pkgid)
+ if [ -n "$pkgid" ]; then
+ eval "$(zpm parse -E $pkgid)"
+ fi
+fi
+
+if [ -z "$pkgid" ]; then
+ die "$0 can't figure out a package id"
+fi
+
+# set file from pkgid
+# R- 10 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
+# RF 11 create package in file, error if file doesn't exist
+if [ ! -f "$pkgfile" ]; then
+ die $pkgfile does not exist
+fi
+
+if [ "$idempotent" = 1 ]; then
+ idempotent='or ignore'
+fi
+
+package=$(zpm quote "$name")
+pkgver=$(zpm quote "$version")
+pkgrel=$(zpm quote "$release")
+
+if [ -z "$rootdir" ]; then
+ : rootdir=${rootdir%%/}
+fi
+
+if [ -z "$localdb" ]; then
+ localdb=${rootdir}/var/lib/zpm/local.db
+fi