3 # edit package metadata
5 #zpm pkg -s packager=foo zpm
7 # zpm pkg -f <pkgfile> zpm 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}
27 while getopts f: opt; do
29 f) pkgfile="$OPTARG" ;;
36 if [ ! -f $pkgfile ]; then
37 echo cannot find $pkgfile
43 #printf "pkg: %s\n" $pkg
44 pkgid=$(zpm findpkg -f $pkgfile "$item")
46 if [ -z "$pkgid" ]; then
47 die "can't find pkgid for $item in $pkgfile"
55 while [ $# -gt 0 ]; do
61 pkgid=$(zpm findpkg -f $pkgfile "${item#:}")
78 if [ -z "$pkgid" ]; then
79 warn "can't find pkgid for $item in $pkgfile"
83 vfield=$(zpm quote "$field")
85 hasfield=$(zpm shell $pkgfile "select name from pragma_table_info('packages') where name = '$vfield';")
86 if [ -z "$hasfield" ]; then
87 warn "$field is not a valid package field"
91 field=$(zpm quote -i "$field")
93 if [ $show -eq 1 ]; then
94 printf "select %s from packages_pkgid where pkgid = '%s';\n" "$field" "$pkgid"
98 if [ -z "$value" ]; then
101 value=$(zpm quote -q "$value")
104 printf "update packages_pkgid set %s = %s where pkgid = '$pkgid';\n" $field $value
107 if [ $rv -eq 0 ]; then
113 } | zpm shell $pkgfile