X-Git-Url: https://pd.if.org/git/?p=zpackage;a=blobdiff_plain;f=zpm-ipkgfile;h=15107d2bebaee5e1c928bc5e3cee69868a17cfba;hp=0de0397b31f9073139697f0b4ea3c3220e70dc26;hb=09c80a1f8918d888063f4d1a75921a99fe5f0b5c;hpb=95c91056eb1fea49f96dcc2b1c5b91930e0b960a diff --git a/zpm-ipkgfile b/zpm-ipkgfile index 0de0397..15107d2 100755 --- a/zpm-ipkgfile +++ b/zpm-ipkgfile @@ -1,20 +1,23 @@ #!/bin/sh +# install a file from a package +# -f pkgfile +# -R root of pkg +# -P prefix to file +# -S strip prefix +# -p pkgname + pkgroot=/ -while getopts :f:v:r:d:a:u:l:p:b:P:R: opt; do +while getopts :f:v:r:d:a:u:g: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" ;; + u) owner="$OPTARG" ;; + g) group="$OPTARG" ;; esac done shift $((OPTIND - 1)) @@ -41,25 +44,37 @@ fi pkg="$1" shift +ZPMPKGFILE=$pkgfile +export ZPMPKGFILE + set -e -for path in $*; do - fhash=$(pkgfileinfo hash $path) - mode=$(pkgfileinfo mode $path) - owner=$(pkgfileinfo username $path) - group=$(pkgfileinfo groupname $path) - ftype=$(pkgfileinfo filetype $path) - name=$(basename -- $path) +for path in "$@"; do + name=$(basename -- "$path") + dir=$(dirname -- "$path") + dir=${dir#/} if [ "$pkgroot" != '/' ]; then - dir=$pkgroot/$(dirname -- $path) + dir=$pkgroot/$dir dir=${dir%/.} - if [ "$dir" = "//" ]; then dir=/ ; fi +# if [ "$dir" = "//" ]; then dir=/ ; fi else - dir='' + dir="/$dir" fi + # TODO generate some unique hash tmppath=$dir/.installing.$name + printf '%s installing %s\n' $pkg $dir/$name + + fhash=$(pkgfileinfo hash $path) + mode=$(pkgfileinfo mode $path) + ftype=$(pkgfileinfo filetype $path) + : ${owner:=$(pkgfileinfo username $path)} + : ${group:=$(pkgfileinfo groupname $path)} + + # TODO if the file already exists, and is the correct + # hash or directory, do nothing + # 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 @@ -67,14 +82,24 @@ for path in $*; do # 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 + umask 0700 + case $ftype in + r*) zpm extract $pkgfile $fhash $tmppath + chown $owner:$group $tmppath + chmod $mode $tmppath + # TODO mv -n non-posix, going to need to have extract + # do all of this + mv $tmppath $dir/$name + ;; + d*) + mkdir -m 000 $dir/$name + chown $owner:$group $dir/$name + chmod $mode $dir/name + ;; + + *) echo unknown filetype ; exit 1 ;; + esac + #EOC done