begin changes to __package_luarocks and __package_pkg_openbsd
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
3c19e7ab4c
commit
1713a70428
3 changed files with 46 additions and 30 deletions
|
@ -31,7 +31,6 @@ state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
# Correct pre 2.1 naming - FIXME in 2.1
|
# Correct pre 2.1 naming - FIXME in 2.1
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
# FIXME: print warning to stderr!
|
|
||||||
installed)
|
installed)
|
||||||
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
|
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
|
||||||
state_should="present"
|
state_should="present"
|
||||||
|
|
|
@ -29,7 +29,7 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
is_installed="$(grep "(installed)" "$__object/explorer/pkg_status" || true)"
|
is_installed="$(grep "(installed)" "$__object/explorer/pkg_status" || true)"
|
||||||
|
|
||||||
case "$state" in
|
case "$state" in
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Andi Brönnimann (andi-cdist at v-net.ch)
|
# 2011 Andi Brönnimann (andi-cdist at v-net.ch)
|
||||||
|
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -42,44 +43,60 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
# Correct pre 2.1 naming - FIXME in 2.1
|
||||||
|
case "$state_should" in
|
||||||
|
installed)
|
||||||
|
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
removed)
|
||||||
|
echo "WARNING: $state_should is deprecated, please change to present/absent (will be removed in cdist 2.1)" >&2
|
||||||
|
state_should="absent"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
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/$machine/
|
echo export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/
|
||||||
|
|
||||||
case "$state" in
|
if [ "$pkg_version" ]; then
|
||||||
installed)
|
state_is="present"
|
||||||
# Empty? Not installed.
|
else
|
||||||
if [ -z "$pkg_version" ]; then
|
state_is="absent"
|
||||||
# use this because pkg_add doesn't properly handle errors
|
fi
|
||||||
cat << eof
|
|
||||||
status=\$(pkg_add "$pkgopts" "$name--$flavor")
|
|
||||||
|
|
||||||
# no error
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
if [ -n "\$status" ]; then
|
|
||||||
echo "Error: \$status"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
eof
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
removed)
|
|
||||||
if [ "$pkg_version" ]; then
|
|
||||||
# use this because pkg_add doesn't properly handle errors
|
|
||||||
cat << eof
|
|
||||||
status=\$(pkg_delete "$pkgopts" "$name--$flavor")
|
|
||||||
|
|
||||||
# no error
|
case "$state_should" in
|
||||||
if [ -n "\$status" ]; then
|
present)
|
||||||
echo "Error: \$status"
|
# use this because pkg_add doesn't properly handle errors
|
||||||
exit 1
|
cat << eof
|
||||||
fi
|
status=\$(pkg_add "$pkgopts" "$name--$flavor")
|
||||||
|
|
||||||
|
# no error
|
||||||
|
if [ -n "\$status" ]; then
|
||||||
|
echo "Error: \$status"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
eof
|
||||||
|
;;
|
||||||
|
|
||||||
|
absent)
|
||||||
|
# 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
|
||||||
eof
|
eof
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue