]> pd.if.org Git - zpackage/commitdiff
add -g option to pathmod to take paths as globs
authorNathan Wagner <nw@hydaspes.if.org>
Mon, 19 Nov 2018 01:44:13 +0000 (01:44 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Mon, 19 Nov 2018 01:44:13 +0000 (01:44 +0000)
zpm-pathmod

index 0a699fd827428b4d46c6121c4072bc61f1ea89a6..90c29c1d750ef9051e361c87f1d87bb977375c5a 100755 (executable)
@@ -24,13 +24,22 @@ die() {
 
 pkgfile=${ZPMDB:-/var/lib/zpm/db.zpm}
 
-while getopts f: opt; do
+pathglob=0
+
+while getopts f:g opt; do
        case $opt in
                f) pkgfile="$OPTARG" ;;
+               g) pathglob=1 ;;
        esac
 done
 shift $((OPTIND - 1))
 
+if [ $pathglob -eq 1 ]; then
+       pathop='glob'
+else
+       pathop='='
+fi
+
 set -e
 
 if [ ! -f $pkgfile ]; then
@@ -94,7 +103,7 @@ while [ $# -gt 0 ]; do
        fi
 
        if [ $field = delete ]; then
-               printf "delete from packagefiles_pkgid where pkgid = '%s' and path = '%s';\n" "$pkgid" "$path"
+               printf "delete from packagefiles_pkgid where pkgid = '%s' and path $pathop '%s';\n" "$pkgid" "$path"
        else
                vfield=$(zpm quote "$field")
 
@@ -107,7 +116,7 @@ while [ $# -gt 0 ]; do
                field=$(zpm quote -i "$field")
 
                if [ $show -eq 1 ]; then
-                       printf "select %s from packagefiles_pkgid where pkgid = '%s' and path='$path';\n" "$field" "$pkgid"
+                       printf "select %s from packagefiles_pkgid where pkgid = '%s' and path $pathop '$path';\n" "$field" "$pkgid"
                        continue
                fi
 
@@ -117,7 +126,7 @@ while [ $# -gt 0 ]; do
                        value=$(zpm quote -q "$value")
                fi
 
-               printf "update packagefiles_pkgid set %s = %s where pkgid = '$pkgid' and path='$path';\n" $field $value
+               printf "update packagefiles_pkgid set %s = %s where pkgid = '$pkgid' and path $pathop '$path';\n" $field $value
        fi
 done