]> pd.if.org Git - zpackage/blob - zpm-list
fix eval variable name in zpm-list
[zpackage] / zpm-list
1 #!/bin/sh
2
3 # zpm-list [-s status] [-vn] [ -f pkgfile ] [pkgid ...]
4
5 verbose=0
6 nameonly=0
7
8 while getopts :s:f:vn opt; do
9         case $opt in
10                 f) pkgfile="$OPTARG" ;;
11                 s) status="$OPTARG" ;;
12                 v) verbose=1 ;;
13                 n) nameonly=1 ;;
14         esac
15 done
16 shift $(( OPTIND - 1))
17
18 : ${pkgfile:=$ZPMDB}
19
20 if [ -z "$pkgfile" ]; then
21         echo "must specify package file"
22         exit 1
23 fi
24
25 if [ $nameonly -eq 0 ]; then
26         cols="pkgid"
27 else
28         cols="package"
29 fi
30
31 if [ $verbose -eq 1 ]; then
32         cols="$cols,coalesce(status,'-')"
33 fi
34
35 if [ -n "$status" ]; then
36         status=$(zpm quote "$status")
37         where="where status = '$status'"
38 fi
39
40 pkgid=$1
41
42 if [ -n "$pkgid" ]; then
43         eval $(zpm parse -E "$pkgid")
44         if [ -n "$name" ]; then
45                 package=$(zpm quote "$name")
46                 where="$where and package = '$package'"
47         fi
48         if [ -n "$version" ]; then
49                 version=$(zpm quote "$version")
50                 where="$where and version = '$version'"
51         fi
52         if [ -n "$release" ]; then
53                 release=$(zpm quote "$release")
54                 where="$where and release = '$release'"
55         fi
56 fi
57
58 zpm shell $pkgfile <<EOS
59 .separator "\t"
60 select $cols from packages_pkgid $where
61 ;
62 EOS
63