--- /dev/null
+#!/bin/sh
+
+# vim: syn=sh
+
+# test addfile
+
+. tap.sh
+
+plan 32
+
+owner=$(id -un)
+group=$(id -gn)
+
+newpkg() {
+ pkgid=$1
+ tryrun zpm init $pkgid.zpm
+ if [ $? -eq 0 ]; then
+ tryrun zpm newpackage -f $pkgid.zpm $pkgid
+ if [ $? -eq 0 ]; then
+ shift
+ tryrun zpm add -u $owner -g $group -f $pkgid.zpm $pkgid "$@"
+ return $?
+ else
+ skip 1 not adding files init failed
+ return 1
+ fi
+ else
+ skip 2 "unable to init $pkgid.zpm"
+ fi
+ return 0
+}
+
+oktest() {
+ test $1 $2
+ okexit test $1 $2
+}
+
+oknottest() {
+ test $1 $2
+ failsok test $1 $2 fails
+}
+
+require rm -rf tmp
+require mkdir tmp
+cd tmp || bailout
+
+# set up a new package
+
+pkgid=itest-1.0-1
+newpkg $pkgid /bin/true
+okexit setup package $pkgid
+PF=$pkgid.zpm
+require mkdir etc
+echo foo > etc/conf
+zpm add -f $PF -C -c $pkgid etc/conf
+okexit added foo conf
+isconf=$(zpm pkgfile -f $PF $pkgid /etc/conf configuration)
+okstreq $isconf 1 etc/conf 1.0 is config file
+
+pkgid=itest-2.0-1
+newpkg $pkgid /bin/true
+okexit setup package $pkgid
+PF=$pkgid.zpm
+echo bar > etc/conf
+zpm add -f $PF -C -c $pkgid etc/conf
+okexit added bar conf
+isconf=$(zpm pkgfile -f $PF $pkgid /etc/conf configuration)
+okstreq $isconf 1 etc/conf 2.0 is config file
+
+pkgid=itest-3.0-1
+newpkg $pkgid /bin/true
+okexit setup package $pkgid
+PF=$pkgid.zpm
+echo baz > etc/conf
+zpm add -f $PF -C -c $pkgid etc/conf
+okexit added baz conf
+isconf=$(zpm pkgfile -f $PF $pkgid /etc/conf configuration)
+okstreq $isconf 1 etc/conf 3.0 is config file
+
+require rm etc/conf
+
+require mkdir var
+require mkdir var/lib
+require mkdir var/lib/zpm
+
+require zpm install -R. -f itest-1.0-1.zpm itest-1.0-1
+
+test -f etc/conf
+okexit etc/conf installed via zpm-install
+conf=$(cat etc/conf)
+okstreq "$conf" foo conf is foo
+
+# update unchanged config file
+require zpm install -R. -f itest-2.0-1.zpm itest-2.0-1
+conf=$(cat etc/conf)
+okstreq "$conf" bar new conf is bar
+
+echo quux > etc/conf
+
+require zpm install -R. -f itest-3.0-1.zpm itest-3.0-1
+conf=$(cat etc/conf)
+okstreq "$conf" quux kept conf as quux
+
+zpm note -f var/lib/zpm/local.db -l | diagstdin