16 tryrun zpm init $pkgid.zpm
18 tryrun zpm newpackage -f $pkgid.zpm $pkgid
21 tryrun zpm add -u $owner -g $group -f $pkgid.zpm $pkgid "$@"
24 skip 1 not adding files init failed
28 skip 2 "unable to init $pkgid.zpm"
40 failsok test $1 $2 fails
47 # set up a new package
50 newpkg $pkgid /bin/true
51 okexit setup package $pkgid
55 #require zpm newpackage -f $PF $pkgid
56 #require zpm add -f $PF $pkgid /bin/true
61 require zpm pkg -f $PF $pkgid status=installing
62 zpm syncfs -d $PF -R. $pkgid 2>&1 | diagstdin
66 okexit bin/true installed
68 require zpm pkg -f $PF $pkgid status=packaged
69 ns=$(zpm pkg -f $PF $pkgid status)
70 okstreq "$ns" "packaged" set package status
78 # TODO should probably have merge set the status to merged by default
80 require zpm init local.db
81 zpm install -R. -d local.db -f $PF $pkgid 2>&1 | diagstdin
82 #zpm list -f local.db -v | diagstdin
84 ns=$(zpm pkg -f local.db $pkgid status)
85 okstreq "$ns" "installed" "install set package status"
88 okexit bin/true installed via zpm-install
94 # update the package version
95 require zpm pkg -f $PF $pkgid version=2.0
96 newver=$(zpm pkg -f $PF itest version)
97 okstreq "$newver" "2.0" "have updated version"
100 tryrun zpm add -f $PF itest /bin/false
101 if [ $? -ne 0 ]; then
103 cat test.out | diagstdin
104 zpm list -f $PF | diagstdin
108 zpm install -R. -d local.db -f $PF itest-2.0-1 2>&1 | diagstdin
110 if [ $? -ne 0 ]; then
111 cat test.out | diagstdin
112 zpm list -f $PF | diagstdin
116 okexit bin/false installed via zpm-install
118 ns=$(zpm pkg -f local.db $pkgid status)
119 okstreq "$ns" "updated" "install set $pkgid status"
120 ns=$(zpm pkg -f local.db itest-2.0-1 status)
121 okstreq "$ns" "installed" "install set itest-2.0-1 status"
124 # upgrade package removing a file
127 newpkg $pkgid /bin/true
128 okexit setup package $pkgid
130 zpm install -R. -d local.db -f $PF $pkgid 2>&1 | diagstdin
131 okexit upgraded to $pkgid
133 ns=$(zpm pkg -f local.db $pkgid status)
134 okstreq "$ns" "installed" "install set $pkgid status"
137 failsok removed bin/false
140 # install second package
142 require ln bin/true bin/sh
145 okexit setup package $pkgid
148 zpm install -R. -d local.db -f $PF $pkgid 2>&1 | diagstdin
149 okexit installed $pkgid
155 ohash=$(zpm hash bin/true)
156 require mv bin/true bin/save
157 require sh -c 'echo false > bin/true'
158 nhash=$(zpm hash bin/true)
160 newpkg $pkgid bin/true
161 okexit setup package $pkgid
162 require mv bin/save bin/true
164 zpm install -R. -d local.db -f $PF $pkgid 2>&1 | diagstdin
165 okexit installed $pkgid
166 rhash=$(zpm hash bin/true)
167 okstreq "$rhash" "$nhash" "updated bin/true"
171 if [ $rv -ne 0 ]; then
179 # package with passing pre-script
183 newpkg $pkgid /bin/echo
184 skiponfail 3 "can't create $pkgid" || {
185 zpm script -s -f $PF -p pre-install $pkgid /bin/true
186 okexit "add true pre-install script to $pkgid"
187 skiponfail 2 "can't set $pkgid pre-install script" || {
188 tryrun zpm install -v -R. -d local.db -f $PF $pkgid
189 okexit installed $pkgid
195 # package with failing pre-script
199 newpkg $pkgid /bin/head
200 skiponfail 3 "can't create $pkgid" || {
201 zpm script -s -f $PF -p pre-install $pkgid /bin/false
202 okexit "add false pre-install script to $pkgid"
203 skiponfail 1 "can't set $pkgid pre-install script" || {
204 zpm install -R. -d local.db -f $PF $pkgid 2>/dev/null
205 failsok failed to install $pkgid
209 tryrun zpm uninstall -R. -d local.db third-1.0-1
211 failsok bin/echo removed
215 newpkg $pkgid /bin/head
216 #zpm list -f $PF 2>&1 | diagstdin
217 skiponfail 1 "can't create $pkgid" || {
218 tryrun zpm install -R. -d local.db -f $PF 2>/dev/null
219 okexit "install with implicit package id"