]> pd.if.org Git - zpackage/blob - zpm-test
check for non-regular file in zpm test
[zpackage] / zpm-test
1 #!/bin/sh
2
3 # tests a package file
4
5 # just checks that all args are valid pkg files
6 verbose=0
7
8 while getopts v opt; do
9         case $opt in
10                 v) verbose=1 ;;
11         esac
12 done
13 shift $((OPTIND - 1))
14
15 for pkgfile in "$@"; do
16         if [ ! -f "$pkgfile" ]; then
17                 if [ "$verbose" -eq 1 ]; then
18                         echo $pkgfile does not appear to be a zpm package file 1>&2
19                 fi
20                 exit 1
21         fi
22
23 appid=$(sqlite3 $pkgfile 'pragma application_id;' | ( echo obase = 16; cat - ) | bc)
24 if [ "$appid" != "5A504442" ]; then
25         if [ "$verbose" -eq 1 ]; then
26                 echo $pkgfile does not appear to be a zpm package file 1>&2
27         fi
28         exit 1
29 fi
30 done
31
32 exit 0