]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/testcode/mini_tpkg.sh
network_cmds-596.100.2.tar.gz
[apple/network_cmds.git] / unbound / testcode / mini_tpkg.sh
1 # tpkg that only exes the files.
2 args="../.."
3 if test "$1" = "-a"; then
4 args=$2
5 shift
6 shift
7 fi
8
9 if test "$1" = "clean"; then
10 echo "rm -f result.* .done* .tpkg.var.master .tpkg.var.test"
11 rm -f result.* .done* .tpkg.var.master .tpkg.var.test
12 exit 0
13 fi
14 if test "$1" = "fake"; then
15 echo "minitpkg fake $2"
16 echo "fake" > .done-`basename $2 .tpkg`
17 exit 0
18 fi
19 if test "$1" = "report" || test "$2" = "report"; then
20 echo "Minitpkg Report"
21 for result in *.tpkg; do
22 name=`basename $result .tpkg`
23 if test -f ".done-$name"; then
24 if test "$1" != "-q"; then
25 echo "** PASSED ** : $name"
26 fi
27 else
28 if test -f "result.$name"; then
29 echo "!! FAILED !! : $name"
30 else
31 echo ">> SKIPPED<< : $name"
32 fi
33 fi
34 done
35 exit 0
36 fi
37
38 if test "$1" != 'exe'; then
39 # usage
40 echo "mini tpkg. Reduced functionality for old shells."
41 echo " tpkg exe <file>"
42 echo " tpkg fake <file>"
43 echo " tpkg clean"
44 echo " tpkg [-q] report"
45 exit 1
46 fi
47 shift
48
49 # do not execute if the disk is too full
50 #DISKLIMIT=100000
51 # This check is not portable (to Solaris 10).
52 #avail=`df . | tail -1 | awk '{print $4}'`
53 #if test "$avail" -lt "$DISKLIMIT"; then
54 #echo "minitpkg: The disk is too full! Only $avail."
55 #exit 1
56 #fi
57
58 name=`basename $1 .tpkg`
59 dir=$name.$$
60 result=result.$name
61 done=.done-$name
62 success="no"
63 if test -x "`which bash`"; then
64 shell="bash"
65 else
66 shell="sh"
67 fi
68
69 # check already done
70 if test -f .done-$name; then
71 echo "minitpkg .done-$name exists. skip test."
72 exit 0
73 fi
74
75 # Extract
76 echo "minitpkg extract $1 to $dir"
77 mkdir $dir
78 gzip -cd $name.tpkg | (cd $dir; tar xf -)
79 cd $dir
80 mv $name.dir/* .
81
82 # EXE
83 echo "minitpkg exe $name" > $result
84 grep "Description:" $name.dsc >> $result 2>&1
85 echo "DateRunStart: "`date "+%s" 2>/dev/null` >> $result
86 if test -f $name.pre; then
87 echo "minitpkg exe $name.pre"
88 echo "minitpkg exe $name.pre" >> $result
89 $shell $name.pre $args >> $result
90 if test $? -ne 0; then
91 echo "Warning: $name.pre did not exit successfully"
92 fi
93 fi
94 if test -f $name.test; then
95 echo "minitpkg exe $name.test"
96 echo "minitpkg exe $name.test" >> $result
97 $shell $name.test $args >>$result 2>&1
98 if test $? -ne 0; then
99 echo "$name: FAILED" >> $result
100 echo "$name: FAILED"
101 success="no"
102 else
103 echo "$name: PASSED" >> $result
104 echo "$name: PASSED" > ../.done-$name
105 echo "$name: PASSED"
106 success="yes"
107 fi
108 fi
109 if test -f $name.post; then
110 echo "minitpkg exe $name.post"
111 echo "minitpkg exe $name.post" >> $result
112 $shell $name.post $args >> $result
113 if test $? -ne 0; then
114 echo "Warning: $name.post did not exit successfully"
115 fi
116 fi
117 echo "DateRunEnd: "`date "+%s" 2>/dev/null` >> $result
118
119 mv $result ..
120 cd ..
121 rm -rf $dir
122 # compat for windows where deletion may not succeed initially (files locked
123 # by processes that still have to exit).
124 if test $? -eq 1; then
125 echo "minitpkg waiting for processes to terminate"
126 sleep 2 # some time to exit, and try again
127 rm -rf $dir
128 fi