]> pd.if.org Git - zpackage/blobdiff - zpm-contents
add where clause argument to findpkg
[zpackage] / zpm-contents
index 0d1a027bae73110f937b3dec01151331bd63eaf2..23c07ae29a1d327050f8c5a06e953c5b141083c0 100755 (executable)
@@ -2,9 +2,12 @@
 
 pkgfile=${ZPMDB:-/var/lib/zpm/db.zpm}
 
-while getopts f: opt; do
+verbose=0
+
+while getopts f:v opt; do
        case $opt in
                f) pkgfile="$OPTARG" ;;
+               v) verbose=1
        esac
 done
 shift $((OPTIND - 1))
@@ -16,16 +19,25 @@ if [ ! -f $pkgfile ]; then
        exit 1
 fi
 
+cols=
+if [ $verbose -gt 0 ]; then
+       cols="filetype,printf('%4.4s', mode) as mode,username,groupname,"
+fi
 
 for pkg in "$@"; do
-       pkgid=$(zpm findpkg $pkgfile $pkg)
+       pkgid=$(zpm findpkg -f $pkgfile $pkg)
 
        zpm shell $pkgfile <<EOS
-.separator "\t"
-select package, version, release,
-path || case when hash is null then '/' else '' end
-from packagefiles
-where printf('%s-%s-%s', package,version,release) = '$pkgid'
+.separator " "
+select pkgid, $cols
+case when filetype = 'd' then
+       rtrim(path,'/') || '/'
+else
+       path
+end as path
+from packagefiles_pkgid
+where pkgid = '$pkgid'
+order by path
 ;
 EOS