+pkgroot=/
+
+while getopts :f:v:r:d:a:u:l:p:b:P:R: opt; do
+ case $opt in
+ R) pkgroot="$OPTARG" ;;
+ f) pkgfile="$OPTARG" ;;
+ v) pkgver="$OPTARG" ;;
+ r) pkgrel="$OPTARG" ;;
+ d) description="$OPTARG" ;;
+ a) arch="$OPTARG" ;;
+ u) url="$OPTARG" ;;
+ l) licenses="$OPTARG" ;;
+ p) packager="$OPTARG" ;;
+ b) builddate="$OPTARG" ;;
+ P) prefix="$OPTARG" ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+die() {
+ echo $* 1&>2
+ exit 1
+}
+
+pkgfileinfo() {
+ sqlite3 $pkgfile<<EOS
+select $1 from packagefiles
+ where path='$2'
+ and package||'-'||version||'-'||release = '$pkg'
+ ;
+EOS
+}
+
+# if not from a package file, from local db
+if [ -z "$pkgfile" ]; then
+ die "installing from non-pkgfile not supported"
+fi
+
+pkg="$1"