3 # install a file from a package
12 while getopts :f:v:r:d:a:u:g:l:p:b:P:R: opt; do
14 R) pkgroot="$OPTARG" ;;
15 f) pkgfile="$OPTARG" ;;
16 v) pkgver="$OPTARG" ;;
17 r) pkgrel="$OPTARG" ;;
18 P) prefix="$OPTARG" ;;
31 zpm shell $pkgfile<<EOS
32 select $1 from packagefiles
34 and package||'-'||version||'-'||release = '$pkg'
39 # if not from a package file, from local db
40 if [ -z "$pkgfile" ]; then
41 die "installing from non-pkgfile not supported"
53 name=$(basename -- $path)
54 dir=$(dirname -- $path)
57 if [ "$pkgroot" != '/' ]; then
60 # if [ "$dir" = "//" ]; then dir=/ ; fi
63 # TODO generate some unique hash
64 tmppath=$dir/.installing.$name
66 printf '%s installing %s\n' $pkg $dir/$name
68 fhash=$(pkgfileinfo hash $path)
69 mode=$(pkgfileinfo mode $path)
70 ftype=$(pkgfileinfo filetype $path)
71 : ${owner:=$(pkgfileinfo username $path)}
72 : ${group:=$(pkgfileinfo groupname $path)}
74 # can't use install because it's not posix.
75 # probably worth writing a zpm-install, but with
76 # a different name since that wants to be a package install
77 # probably makes the most sense for extract to know how
78 # to do the extract to temp and such, then
79 # you can just add the -S option (secure)
84 r*) zpm extract $pkgfile $fhash $tmppath
85 chown $owner:$group $tmppath
87 # TODO mv -n non-posix, going to need to have extract
89 mv $tmppath $dir/$name
92 mkdir -m 000 $dir/$name
93 chown $owner:$group $dir/$name
97 *) echo unknown filetype ; exit 1 ;;