File: //usr/local/libexec/qinst/info
#!/bin/sh
# Display information for quick install
set -e
OPT_ALL=
OPT_EXIST=
OPT_QUIET=
while getopts "aeq" opt; do
case "${opt}" in
a)
OPT_ALL="yes"
;;
e)
OPT_EXIST="yes"
;;
q)
OPT_QUIET="yes"
;;
*)
;;
esac
done
shift $(expr ${OPTIND} - 1)
PKGNAME="$1"
test -z "${PKGNAME}" && OPT_ALL="yes"
set -u
_error() {
local msg="$1"
test -z "${OPT_QUIET}" && echo "${msg}"
exit 1
}
_info_pkg () {
local pkg="$1"
test -r "${pkg}/+COMMENT" || return 2
test -n "${OPT_EXIST}" && return 0
echo -n "${pkg}"
if [ -n "${OPT_QUIET}" ]; then
echo ""
else
echo -n " "
head -1 ${pkg}/+COMMENT
fi
}
test -n "${PKG_DBDIR}" || _error "Error: No such directory"
test -d "${PKG_DBDIR}" || exit 0
cd ${PKG_DBDIR} || _error "Error: Permission denied"
if [ -n "${PKGNAME}" ]; then
_info_pkg "${PKGNAME}" || _error "Error: No package matching ${PKGNAME}"
elif [ -n "${OPT_ALL}" ]; then
ls -1 | while read dir; do
_info_pkg "${dir}" || :
done
fi
: end of script