3 # edit package metadata
5 #zpm pkg -s packager=foo zpm
7 # zpm pkg -f <pkgfile> zpm packager=xyz
11 printf '%s:' "$0" 1>&2
18 printf '%s:' "$0" 1>&2
24 pkgfile=${ZPMDB:-/var/lib/zpm/local.db}
26 while getopts f: opt; do
28 f) pkgfile="$OPTARG" ;;
35 if [ ! -f $pkgfile ]; then
36 echo cannot find $pkgfile
42 #printf "pkg: %s\n" $pkg
43 pkgid=$(zpm findpkg -f $pkgfile "$item")
45 if [ -z "$pkgid" ]; then
46 die "can't find pkgid for $item in $pkgfile"
54 while [ $# -gt 0 ]; do
60 pkgid=$(zpm findpkg -f $pkgfile "${item#:}")
77 if [ -z "$pkgid" ]; then
78 warn "can't find pkgid for $item in $pkgfile"
82 vfield=$(zpm quote "$field")
84 hasfield=$(zpm shell $pkgfile "select name from pragma_table_info('packages') where name = '$vfield';")
85 if [ -z "$hasfield" ]; then
86 warn "$field is not a valid package field"
90 field=$(zpm quote -i "$field")
92 if [ $show -eq 1 ]; then
93 printf "select %s from packages_pkgid where pkgid = '%s';\n" "$field" "$pkgid"
97 if [ -z "$value" ]; then
100 value=$(zpm quote -q "$value")
103 printf "update packages_pkgid set %s = %s where pkgid = '$pkgid';\n" $field "$value"
106 if [ $rv -eq 0 ]; then
112 } | zpm shell $pkgfile