From: Nathan Wagner Date: Tue, 31 Jul 2018 18:57:43 +0000 (+0000) Subject: add directories to ipkgfile X-Git-Tag: v0.1.6~85 X-Git-Url: https://pd.if.org/git/?p=zpackage;a=commitdiff_plain;h=d4aaf504afd121d24e67bf56a14ba0039ef266ad add directories to ipkgfile --- diff --git a/zpm-ipkgfile b/zpm-ipkgfile index 60df289..de97711 100755 --- a/zpm-ipkgfile +++ b/zpm-ipkgfile @@ -9,13 +9,15 @@ 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" ;; P) prefix="$OPTARG" ;; + u) owner="$OPTARG" ;; + g) group="$OPTARG" ;; esac done shift $((OPTIND - 1)) @@ -47,24 +49,28 @@ export ZPMPKGFILE set -e for path in $*; do - printf '%s installing %s\n' $pkg $path - fhash=$(zpm pkgfileinfo hash $path) - mode=$(zpm pkgfileinfo mode $path) - ftype=$(zpm pkgfileinfo filetype $path) - owner=$(zpm pkgfileinfo username $path) - group=$(zpm pkgfileinfo groupname $path) name=$(basename -- $path) dir=$(dirname -- $path) + dir=${dir#/} if [ "$pkgroot" != '/' ]; then dir=$pkgroot/$dir dir=${dir%/.} - if [ "$dir" = "//" ]; then dir=/ ; fi +# if [ "$dir" = "//" ]; then dir=/ ; fi 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)} + # 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 @@ -73,11 +79,23 @@ for path in $*; do # you can just add the -S option (secure) #cat <<-EOC 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 + 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