9 while getopts :f:s:a:r:qc opt; do
11 f) pkgfile="$OPTARG" ;;
12 s) setlist="$setlist $OPTARG"; clearlist=1 ;;
13 a) add="$add $OPTARG"; ;;
14 r) remove="$remove $OPTARG" ;;
19 shift $(( OPTIND - 1))
21 : ${pkgfile:=${ZPMDB:-/var/lib/zpm/local.db}}
23 if [ -z "$pkgfile" ]; then
24 echo "must specify package file"
28 pkgid=$(zpm findpkg -f $pkgfile "$1")
29 if [ -z "$pkgid" ]; then
30 echo "cannot find pkgid for $1"
34 eval $(zpm parse -E "$pkgid")
35 package=$(zpm quote -q "$name")
36 version=$(zpm quote -q "$version")
37 pkgselector="package = $package and version = $version and release = $release"
38 listdeps="select requires from packagedeps where %s;\n"
39 adddep='insert or ignore into packagedeps (package,version,release,requires) values (%s,%s,%d,%s);\n'
40 rmdep='delete from packagedeps where %s and requires = %s;\n'
41 cleardeps='delete from packagedeps where %s;\n'
46 if [ $clearlist -eq 1 ]; then
47 printf "$cleardeps" "$pkgselector"
49 if [ -n "$setlist" ]; then
50 for dep in $setlist; do
51 qdep=$(zpm quote -q "$dep")
52 printf "$adddep" "$package" "$version" "$release" "$qdep"
55 if [ -n "$add" ]; then
57 qdep=$(zpm quote -q "$dep")
58 printf "$adddep" "$package" "$version" "$release" "$qdep"
61 if [ -n "$remove" ]; then
62 for dep in $remove; do
63 qdep=$(zpm quote -q "$dep")
64 printf "$rmdep" "$pkgselector" "$qdep"
67 if [ $quiet -eq 0 ]; then
68 printf "$listdeps" "$pkgselector"
71 } | zpm shell $pkgfile