- mkdir -p tmp/$(dirname $path)
- fhash=$(sqlite3 $pkgfile "select hash from packagefiles where path = '$path';")
- ./zpm-extract $pkgfile $fhash ./tmp/$path
+ fhash=$(zpm pkgfileinfo hash $path)
+ mode=$(zpm pkgfileinfo mode $path)
+ owner=$(zpm pkgfileinfo username $path)
+ group=$(zpm pkgfileinfo groupname $path)
+ ftype=$(zpm pkgfileinfo filetype $path)
+ name=$(basename -- $path)
+
+ if [ "$pkgroot" != '/' ]; then
+ dir=$pkgroot/$(dirname -- $path)
+ dir=${dir%/.}
+ if [ "$dir" = "//" ]; then dir=/ ; fi
+ else
+ dir=''
+ fi
+
+ tmppath=$dir/.installing.$name
+
+ # can't use install because it's not posix.
+ # probably worth writing a zpm-install, but with
+ # a different name since that wants to be a package install
+ # probably makes the most sense for extract to know how
+ # to do the extract to temp and such, then
+ # you can just add the -S option (secure)
+ #cat <<-EOC
+ set -x
+ mkdir -p $dir
+ zpm extract $pkgfile $fhash $tmppath 0
+ chown $owner:$group $tmppath
+ chmod $mode $tmppath
+ # TODO mv -n non-posix, going to need to have extract do all
+ # of this
+ mv -n $tmppath $dir/$name
+ set +x
+ #EOC