From 3c19e7ab4c937bd6452d1f8a777288ab31163a47 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 9 Feb 2012 11:54:13 +0100 Subject: [PATCH] update __package_pacman for absent/present Signed-off-by: Nico Schottelius --- .../__package_pacman/explorer/pkg_version | 4 +-- conf/type/__package_pacman/gencode-remote | 33 +++++++++++++------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/conf/type/__package_pacman/explorer/pkg_version b/conf/type/__package_pacman/explorer/pkg_version index 4f612423..c33820f8 100755 --- a/conf/type/__package_pacman/explorer/pkg_version +++ b/conf/type/__package_pacman/explorer/pkg_version @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -18,7 +18,7 @@ # along with cdist. If not, see . # # -# Retrieve the status of a package - parsed dpkg output +# Retrieve the status of a package - parsed pacman output # if [ -f "$__object/parameter/name" ]; then diff --git a/conf/type/__package_pacman/gencode-remote b/conf/type/__package_pacman/gencode-remote index 3c4fdda7..1516370c 100755 --- a/conf/type/__package_pacman/gencode-remote +++ b/conf/type/__package_pacman/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -33,21 +33,34 @@ else name="$__object_id" fi -state="$(cat "$__object/parameter/state")" +state_should="$(cat "$__object/parameter/state")" +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")" +if [ -z "$pkg_version" ]; then + state_is="absent" +else + state_is="present" +fi -case "$state" in - installed) +# Exit if nothing is needed to be done +[ "$state_is" = "$state_should ] && exit 0 - # Empty? Not installed. - if [ -z "$pkg_version" ]; then +case "$state_should" in + present) echo pacman "$pacopts" -S \"$name\" - fi ;; - removed) - if [ "$pkg_version" ]; then + absent) echo pacman "$pacopts" -R \"$name\" - fi ;; *) echo "Unknown state: $state" >&2