Add error output to __package_pkg_openbsd

This commit is contained in:
Andreas Brönnimann 2011-04-05 23:23:24 +02:00
parent 23c35acf16
commit 836c2ae7b8
3 changed files with 33 additions and 15 deletions

View file

@ -22,13 +22,10 @@
# #
# #
os="$(cat "$__global/explorer/os")" os="$($__explorer/os)"
case "$os" in case "$os" in
archlinux) archlinux|*bsd)
echo $(uname -m)
;;
openbsd)
echo $(uname -m) echo $(uname -m)
;; ;;
esac esac

View file

@ -18,7 +18,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
# #
# Manage packages with Pacman (mostly archlinux) # Manage packages with pkg on OpenBSD
# #
# Debug # Debug
@ -26,7 +26,7 @@
# set -x # set -x
os_version="$(cat "$__global/explorer/os_version")" os_version="$(cat "$__global/explorer/os_version")"
platform="$(cat "$__global/explorer/platform")" hardware_type="$(cat "$__global/explorer/hardware_type")"
if [ -f "$__object/parameter/flavor" ]; then if [ -f "$__object/parameter/flavor" ]; then
@ -46,19 +46,40 @@ state="$(cat "$__object/parameter/state")"
pkg_version="$(cat "$__object/explorer/pkg_version")" pkg_version="$(cat "$__object/explorer/pkg_version")"
# TODO: Shouldn't be hardcoded # TODO: Shouldn't be hardcoded
echo export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$platform/ echo export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$hardware_type/
case "$state" in case "$state" in
installed) installed)
# Empty? Not installed. # Empty? Not installed.
if [ -z "$pkg_version" ]; then if [ -z "$pkg_version" ]; then
echo pkg_add "$pkgopts" \"$name--$flavor\" # use this because pkg_add doesn't properly handle errors
cat << eof
status=\$(pkg_add "$pkgopts" "$name--$flavor")
# no error
if [ -n "\$status" ]; then
echo "Error: \$status"
exit 1
fi
eof
fi fi
;; ;;
uninstalled) removed)
if [ "$pkg_version" ]; then if [ "$pkg_version" ]; then
echo pkg_delete "$pkgopts" \"$name--$flavor\" # use this because pkg_add doesn't properly handle errors
cat << eof
status=\$(pkg_delete "$pkgopts" "$name--$flavor")
# no error
if [ -n "\$status" ]; then
echo "Error: \$status"
exit 1
fi fi
eof
fi
;;
*)
echo "Unknown state: $state" >&2
exit 1
;; ;;
esac esac

View file

@ -1,6 +1,6 @@
cdist-type__package_pkg(7) cdist-type__package_pkg(7)
============================= =============================
Andreas Brönnimann <andi-cdist--@--v-net.ch> Andi Brönnimann <andi-cdist--@--v-net.ch>
NAME NAME
@ -16,7 +16,7 @@ This type is usually used on OpenBSD to manage packages.
REQUIRED PARAMETERS REQUIRED PARAMETERS
------------------- -------------------
state:: state::
Either "installed" or "uninstalled". Either "installed" or "removed".
OPTIONAL PARAMETERS OPTIONAL PARAMETERS
@ -42,7 +42,7 @@ __package_pkg_openbsd vim --state installed --flavor no_x11
__package_pkg_openbsd python --state installed --name python2 __package_pkg_openbsd python --state installed --name python2
# Remove obsolete package # Remove obsolete package
__package_pkg_openbsd puppet --state uninstalled __package_pkg_openbsd puppet --state removed
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------