]> pd.if.org Git - zpackage/blob - zpm-contents
add where clause argument to findpkg
[zpackage] / zpm-contents
1 #!/bin/sh
2
3 pkgfile=${ZPMDB:-/var/lib/zpm/db.zpm}
4
5 verbose=0
6
7 while getopts f:v opt; do
8         case $opt in
9                 f) pkgfile="$OPTARG" ;;
10                 v) verbose=1
11         esac
12 done
13 shift $((OPTIND - 1))
14
15 set -e
16
17 if [ ! -f $pkgfile ]; then
18         echo cannot find $pkgfile
19         exit 1
20 fi
21
22 cols=
23 if [ $verbose -gt 0 ]; then
24         cols="filetype,printf('%4.4s', mode) as mode,username,groupname,"
25 fi
26
27 for pkg in "$@"; do
28         pkgid=$(zpm findpkg -f $pkgfile $pkg)
29
30         zpm shell $pkgfile <<EOS
31 .separator " "
32 select pkgid, $cols
33 case when filetype = 'd' then
34         rtrim(path,'/') || '/'
35 else
36         path
37 end as path
38 from packagefiles_pkgid
39 where pkgid = '$pkgid'
40 order by path
41 ;
42 EOS
43
44 done