3 # edit package file metadata
5 #zpm pkg -s packager=foo zpm
7 # zpm pkg -f <pkgfile> zpm file/path configuration=1
11 printf '%s:' "$0" 1>&2
18 printf '%s:' "$0" 1>&2
24 pkgfile=${ZPMDB:-/var/lib/zpm/db.zpm}
26 while getopts f: opt; do
28 f) pkgfile="$OPTARG" ;;
33 if [ ! -f $pkgfile ]; then
34 echo cannot find $pkgfile
43 while [ $# -gt 0 ]; do
46 if [ -z "$pkgid" ]; then
48 elif [ -z "$path" ]; then
55 pkgid=$(zpm findpkg -f $pkgfile "${item#:}")
56 if [ -z "$pkgid" ]; then
57 warn "can't find pkgid ${item#:} in $pkgfile"
80 if [ -z "$path" ]; then
81 warn "no package file path specified"
85 vfield=$(zpm quote "$field")
87 hasfield=$(zpm shell $pkgfile "select name from pragma_table_info('packagefiles_pkgid') where name = '$vfield';")
88 if [ -z "$hasfield" ]; then
89 warn "$field is not a valid packagefile field"
93 field=$(zpm quote -i "$field")
94 vpath=$(zpm quote "$path")
95 vpkg=$(zpm quote "$pkgid")
97 haspath=$(zpm shell $pkgfile "select 1 from packagefiles_pkgid where pkgid = '$vpkg' and path = '$vpath';")
98 if [ "$haspath" != 1 ]; then
99 warn "$path not in $pkgid"
103 if [ $show -eq 1 ]; then
104 printf "select %s from packagefiles_pkgid where pkgid = '%s' and path = '%s';\n" "$field" "$pkgid" "$vpath"
108 if [ -z "$value" ]; then
111 value=$(zpm quote -q "$value")
114 printf "update packagefiles_pkgid set %s = %s where pkgid = '$pkgid' and path = '%s';\n" $field $value "$vpath"
117 if [ $rv -eq 0 ]; then
124 } | zpm shell $pkgfile