11 while getopts :f:s:a:r:qcLR opt; do
13 f) pkgfile="$OPTARG" ;;
14 s) setlist="$setlist $OPTARG"; clearlist=1 ;;
15 a) add="$add $OPTARG"; ;;
16 r) remove="$remove $OPTARG" ;;
23 shift $(( OPTIND - 1))
25 : ${pkgfile:=${ZPMDB:-/var/lib/zpm/local.db}}
27 if [ -z "$pkgfile" ]; then
28 echo "must specify package file"
32 pkgid=$(zpm findpkg -f $pkgfile "$1")
33 if [ -z "$pkgid" ]; then
34 echo "cannot find pkgid for $1"
38 eval $(zpm parse -E "$pkgid")
39 package=$(zpm quote -q "$name")
40 version=$(zpm quote -q "$version")
41 pkgselector="P.package = $package and P.version = $version and P.release = $release"
42 selector="package = $package and version = $version and release = $release"
43 listdeps="select requires from packagedeps P where %s;\n"
44 adddep='insert or ignore into packagedeps (package,version,release,requires) values (%s,%s,%d,%s);\n'
45 rmdep='delete from packagedeps where %s and requires = %s;\n'
46 cleardeps='delete from packagedeps where %s;\n'
47 libdeps="select distinct EN.needed from elfneeded EN join packagefiles P on P.hash = EN.file where %s;\n"
48 resolvelibs="select distinct EN.needed from elfneeded EN join packagefiles PF on PF.hash = EN.file left join where %s;\n"
52 printf ".log stderr\n"
54 if [ $clearlist -eq 1 ]; then
55 printf "$cleardeps" "$selector"
57 if [ -n "$setlist" ]; then
58 for dep in $setlist; do
59 qdep=$(zpm quote -q "$dep")
60 printf "$adddep" "$package" "$version" "$release" "$qdep"
63 if [ -n "$add" ]; then
65 qdep=$(zpm quote -q "$dep")
66 printf "$adddep" "$package" "$version" "$release" "$qdep"
69 if [ -n "$remove" ]; then
70 for dep in $remove; do
71 qdep=$(zpm quote -q "$dep")
72 printf "$rmdep" "$selector" "$qdep"
75 if [ $quiet -eq 0 ]; then
76 printf "$listdeps" "$pkgselector"
77 if [ $includelibs -eq 1 ]; then
78 printf "$libdeps" "$pkgselector"
82 } | zpm shell $pkgfile