]> pd.if.org Git - zpackage/blobdiff - zpm-addtopackage
add -f pkgfile option to addtopackage
[zpackage] / zpm-addtopackage
index 1964b77589e29f6cf58778cb3b8e24fdc4a57cc0..a3b045b04c8f9330751a89a778c301dfe451bff5 100755 (executable)
@@ -24,19 +24,26 @@ while getopts :f:v:r:d:a:u:l:p:b:P: opt; do
 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)
@@ -67,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