3 # edit package metadata
5 #zpm pkg -s packager=foo zpm
7 # zpm pkg -f <pkgfile> zpm path packager=xyz
8 # zpm pkg zpm packager zyz
12 printf '%s:' "$0" 1>&2
19 printf '%s:' "$0" 1>&2
25 pkgfile=${ZPMDB:-/var/lib/zpm/db.zpm}
29 while getopts f:g opt; do
31 f) pkgfile="$OPTARG" ;;
37 if [ $pathglob -eq 1 ]; then
45 if [ ! -f $pkgfile ]; then
46 echo cannot find $pkgfile
52 #printf "pkg: %s\n" $pkg
53 pkgid=$(zpm findpkg -f $pkgfile "$item")
55 if [ -z "$pkgid" ]; then
56 die "can't find pkgid for $item in $pkgfile"
61 path=$(zpm quote "$path")
68 while [ $# -gt 0 ]; do
74 pkgid=$(zpm findpkg -f $pkgfile "${item#:}")
79 path=$(zpm quote "$path")
96 # TODO if field = pkgid, parse and set
97 # TODO if changing pkgid, and it doesn't exist, better error
100 if [ -z "$pkgid" ]; then
101 warn "can't find pkgid for $item in $pkgfile"
105 if [ $field = delete ]; then
106 printf "delete from packagefiles_pkgid where pkgid = '%s' and path $pathop '%s';\n" "$pkgid" "$path"
108 vfield=$(zpm quote "$field")
110 hasfield=$(zpm shell $pkgfile "select name from pragma_table_info('packagefiles') where name = '$vfield';")
111 if [ -z "$hasfield" ]; then
112 warn "$field is not a valid packagefile field"
116 field=$(zpm quote -i "$field")
118 if [ $show -eq 1 ]; then
119 printf "select %s from packagefiles_pkgid where pkgid = '%s' and path $pathop '$path';\n" "$field" "$pkgid"
123 if [ -z "$value" ]; then
126 value=$(zpm quote -q "$value")
129 printf "update packagefiles_pkgid set %s = %s where pkgid = '$pkgid' and path $pathop '$path';\n" $field $value
133 if [ $rv -eq 0 ]; then
139 } | zpm shell $pkgfile