X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-addtopackage;h=a3b045b04c8f9330751a89a778c301dfe451bff5;hb=09dde8c2b752ea64d012778ad795b7e70cd9fada;hp=cccd12de666d3ce2c0574207583f2120401448db;hpb=cb319777926fbee07c96a5f28aacb243f3e6353d;p=zpackage diff --git a/zpm-addtopackage b/zpm-addtopackage index cccd12d..a3b045b 100755 --- a/zpm-addtopackage +++ b/zpm-addtopackage @@ -1,7 +1,5 @@ #!/bin/sh -package=${1:-$ZPMPACKAGE} -shift pkgver=${ZPMPKGVER:-1.0} pkgrel=${ZPMPKGREL:-1} @@ -24,17 +22,28 @@ while getopts :f:v:r:d:a:u:l:p:b:P: opt; do c) tags="$tags +configuration" ;; esac done +shift $((OPTIND - 1)) + +die() { + echo $* 1&>2 + exit 1 +} + +package="$1" +shift +if [ -z "$package" ]; then + die "must specify package" +fi set -e if [ -z "$pkgfile" ]; then pkgfile="$package-$pkgver-$pkgrel.zpm" fi -if [ ! -f $pkgfile ]; then - zpm newpackage $package || exit 1 -else - zpm-test -v $pkgfile -fi +# make sure package exists +zpm newpackage -I -f $pkgfile -v $pkgver -r $pkgrel $package || exit 1 + +zpm test -v $pkgfile for path in $*; do mtime=$(zpm stat -f '%y' $path) @@ -65,10 +74,12 @@ for path in $*; do target='NULL' case "$filetype" in regular) - filetype=d + filetype=r hash=$(zpm addfile $pkgfile "$path") + if [ $? -ne 0 ]; then + die "zpm addfile failed ($?): $pkgfile $path" + fi hash="'$hash'" - filetype=r ;; directory) filetype=d