]> pd.if.org Git - zpackage/commitdiff
quote shell variables
authorNathan Wagner <nw@hydaspes.if.org>
Tue, 21 Aug 2018 15:05:19 +0000 (15:05 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Tue, 21 Aug 2018 15:05:19 +0000 (15:05 +0000)
zpm-installed [new file with mode: 0755]
zpm-ipkgfile

diff --git a/zpm-installed b/zpm-installed
new file mode 100755 (executable)
index 0000000..fe84874
--- /dev/null
@@ -0,0 +1,52 @@
+#!/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
index 281fccadd1f137d5b4c6ee1d445ab2eb2413e7cd..15107d2bebaee5e1c928bc5e3cee69868a17cfba 100755 (executable)
@@ -48,10 +48,9 @@ ZPMPKGFILE=$pkgfile
 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
@@ -73,6 +72,9 @@ for path in $*; do
        : ${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