--- /dev/null
+#!/bin/sh
+
+# show the installed version for each package if no arguments are given, all
+# installed packages are displayed.
+
+chroot=1
+pkgroot=
+
+while getopts :R:CNXf:d:Dt:T:u:g: opt; do
+ case $opt in
+ R) pkgroot="$OPTARG" ;;
+ d) ZPMDB="$OPTARG" ;;
+ esac
+done
+
+shift $((OPTIND - 1))
+
+for cf in /etc/zpmrc ~/.zpmrc ./.zpmrc; do
+ test -r $cf && . $cf
+done
+
+: ${ZPMDB:=/var/lib/zpm/db.zpm}
+
+export ZPMDB
+
+die() {
+ printf 'zpm-installed:' 1>&2
+ printf ' %s' $* 1>&2
+ printf '\n' 1>&2
+ exit 1
+}
+
+db=$pkgroot$ZPMDB
+
+set -e
+zpm test -v $db
+
+{
+
+ printf '.separator "\\t"\n'
+ printf 'select package,version,release from packages\n'
+if [ $# -gt 0 ]; then
+ printf 'where package in\n('
+ printf "'%s'" "$1"
+ shift
+ for pkg in "$@"; do
+ printf ",'%s'" "$pkg"
+ done
+ printf ')\n'
+fi
+printf ';\n'
+} | zpm shell $db
export ZPMPKGFILE
set -e
-for path in $*; do
-
- name=$(basename -- $path)
- dir=$(dirname -- $path)
+for path in "$@"; do
+ name=$(basename -- "$path")
+ dir=$(dirname -- "$path")
dir=${dir#/}
if [ "$pkgroot" != '/' ]; then
: ${owner:=$(pkgfileinfo username $path)}
: ${group:=$(pkgfileinfo groupname $path)}
+ # TODO if the file already exists, and is the correct
+ # hash or directory, do nothing
+
# can't use install because it's not posix.
# probably worth writing a zpm-install, but with
# a different name since that wants to be a package install