]> pd.if.org Git - zpackage/commitdiff
change package list terminator
authorNathan Wagner <nw@hydaspes.if.org>
Sun, 9 Dec 2018 01:33:48 +0000 (01:33 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sun, 9 Dec 2018 10:22:39 +0000 (10:22 +0000)
A '--' is interpreted as the end of options, which made it difficult
to specify a zpm-contents glob list without a package list.  Changed
the separator to a ':', which is also an illegal package name.

doc/zpm-contents.8
t/pathmod.t [new file with mode: 0755]
zpm-contents

index 4ac9c15e57314f88aa857833fc24e0aadc711e88..30a320208ef07ef241e4f703861e50dbe0a4a4d3 100644 (file)
@@ -10,12 +10,12 @@ zpm-contents \- list files in a zpm package
 .B -ln
 ]
 .RI [ package ...]
-.RB [ --
+.RB [ :
 .IR glob ...\fR]
 .SH DESCRIPTION
 \fBzpm-contents\fR lists files belonging to any of the given packages,
 or all packages.  Additionally, the list of packages can be
-terminated with '--' and any additional arguments are glob patterns.
+terminated with ':' and any additional arguments are glob patterns.
 .SH OPTIONS
 .TP
 \-f
diff --git a/t/pathmod.t b/t/pathmod.t
new file mode 100755 (executable)
index 0000000..47575e6
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# vim: syn=sh
+
+# test addfile
+
+. tap.sh
+
+plan 13
+
+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=pathmod-1.0-1
+newpkg $pkgid /bin/true
+okexit setup package $pkgid
+PF=$pkgid.zpm
+
+username=$(zpm pathmod -f $PF $pkgid /bin/true username)
+okstreq "$username" "$owner" 'default owned by current user'
+zpm pathmod -f $PF $pkgid /bin/true username=root
+username=$(zpm pathmod -f $PF $pkgid /bin/true username)
+okstreq "$username" root 'set username to root'
+has=$(zpm contents -q -f $PF $pkgid : /bin/true)
+okstreq "$has" /bin/true 'package has /bin/true'
+
+zpm packagehash -qs -f $PF $pkgid
+hash=$(zpm packagehash -f $PF $pkgid)
+if [ -n "$hash" ]; then
+       pass 'packagehash set'
+       diag $hash
+else
+       fail 'packagehash set'
+fi
+
+zpm pathmod -f $PF $pkgid /bin/true delete
+zpm contents -q -f $PF $pkgid : /bin/true
+has=$(zpm contents -q -f $PF $pkgid : /bin/true)
+okstreq "$has" '' '/bin/true deleted'
+
+hash=$(zpm packagehash -e -f $PF $pkgid)
+if [ -z "$hash" ]; then
+       pass 'packagehash cleared'
+else
+       fail 'packagehash cleared'
+       diag $hash
+fi
+
+cd .. || bailout
+require rm -rf tmp
index 60ec1f534807e05d6ad2817f434f256e890a3d9a..d466478dd11d2581aee9c86967f4dd4c8e5657b3 100755 (executable)
@@ -46,7 +46,7 @@ while [ $# -gt 0 ]; do
        pkg=$1
        shift
 
-       if [ "$pkg" = '--' ]; then
+       if [ "$pkg" = ':' ]; then
                break
        fi