X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-addtopackage;h=a3b045b04c8f9330751a89a778c301dfe451bff5;hb=09dde8c2b752ea64d012778ad795b7e70cd9fada;hp=05c35963713f4b310f213f2861489cdb61fa039d;hpb=cc86639ed2cb9237b75ddb603b101929a3ee71d6;p=zpackage diff --git a/zpm-addtopackage b/zpm-addtopackage index 05c3596..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,21 +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 - appid=$(sqlite3 $pkgfile 'pragma application_id;' | ( echo obase = 16; cat - ) | bc) - if [ "$appid" != "5A504442" ]; then - echo $pkgfile does not appear to be a zpm package file - exit 1 - fi -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) @@ -69,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