]> pd.if.org Git - zpackage/commitdiff
add directories to ipkgfile
authorNathan Wagner <nw@hydaspes.if.org>
Tue, 31 Jul 2018 18:57:43 +0000 (18:57 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Tue, 31 Jul 2018 18:57:43 +0000 (18:57 +0000)
zpm-ipkgfile

index 60df2898323c17ccdb78bcfbe2dee70b67a28905..de9771115dc93029fd78cf978de2281a3fad7673 100755 (executable)
@@ -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