From 1fef54ecdfd90d3dd02e489119250957259dab65 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Sun, 7 Oct 2012 11:51:15 -0400 Subject: [PATCH] Fix __package* state usage Removed __package*/parameter/required Added state to __package*/parameter/optional Modified man pages for __package* Added optional check for state parameter Defaulted state parameter to "present" --- conf/type/__package/man.text | 8 +++++--- conf/type/__package/parameter/optional | 1 + conf/type/__package/parameter/required | 1 - conf/type/__package_apt/gencode-remote | 6 +++++- conf/type/__package_apt/man.text | 8 +++++--- conf/type/__package_apt/parameter/optional | 1 + conf/type/__package_apt/parameter/required | 1 - conf/type/__package_luarocks/gencode-remote | 6 +++++- conf/type/__package_luarocks/man.text | 8 +++++--- conf/type/__package_luarocks/parameter/optional | 1 + conf/type/__package_luarocks/parameter/required | 1 - conf/type/__package_opkg/gencode-remote | 7 ++++++- conf/type/__package_opkg/man.text | 6 ++++-- conf/type/__package_opkg/parameter/optional | 1 + conf/type/__package_opkg/parameter/required | 1 - conf/type/__package_pacman/gencode-remote | 6 +++++- conf/type/__package_pacman/man.text | 8 +++++--- conf/type/__package_pacman/parameter/optional | 1 + conf/type/__package_pacman/parameter/required | 1 - conf/type/__package_pip/gencode-remote | 6 +++++- conf/type/__package_pip/man.text | 6 ++++-- conf/type/__package_pip/parameter/optional | 1 + conf/type/__package_pip/parameter/required | 1 - conf/type/__package_pkg_freebsd/gencode-remote | 6 +++++- conf/type/__package_pkg_freebsd/man.text | 6 ++++-- conf/type/__package_pkg_freebsd/parameter/optional | 1 + conf/type/__package_pkg_freebsd/parameter/required | 1 - conf/type/__package_pkg_openbsd/gencode-remote | 6 +++++- conf/type/__package_pkg_openbsd/man.text | 8 +++++--- conf/type/__package_pkg_openbsd/parameter/optional | 1 + conf/type/__package_pkg_openbsd/parameter/required | 1 - conf/type/__package_rubygem/gencode-remote | 6 +++++- conf/type/__package_rubygem/man.text | 8 +++++--- conf/type/__package_rubygem/parameter/optional | 1 + conf/type/__package_rubygem/parameter/required | 1 - conf/type/__package_yum/gencode-remote | 6 +++++- conf/type/__package_yum/man.text | 8 +++++--- conf/type/__package_yum/parameter/optional | 1 + conf/type/__package_yum/parameter/required | 1 - conf/type/__package_zypper/gencode-remote | 6 +++++- conf/type/__package_zypper/man.text | 6 ++++-- conf/type/__package_zypper/parameter/optional | 1 + conf/type/__package_zypper/parameter/required | 1 - 43 files changed, 113 insertions(+), 50 deletions(-) delete mode 100644 conf/type/__package/parameter/required delete mode 100644 conf/type/__package_apt/parameter/required delete mode 100644 conf/type/__package_luarocks/parameter/required delete mode 100644 conf/type/__package_opkg/parameter/required delete mode 100644 conf/type/__package_pacman/parameter/required delete mode 100644 conf/type/__package_pip/parameter/required delete mode 100644 conf/type/__package_pkg_freebsd/parameter/required delete mode 100644 conf/type/__package_pkg_openbsd/parameter/required delete mode 100644 conf/type/__package_rubygem/parameter/required delete mode 100644 conf/type/__package_yum/parameter/required delete mode 100644 conf/type/__package_zypper/parameter/required diff --git a/conf/type/__package/man.text b/conf/type/__package/man.text index 071a8bfb..9ad9747a 100644 --- a/conf/type/__package/man.text +++ b/conf/type/__package/man.text @@ -16,9 +16,7 @@ It dispatches the actual work to the package system dependant types. REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" - (the old values "installed" or "removed" will be removed in cdist 2.1). +None OPTIONAL PARAMETERS @@ -35,6 +33,10 @@ type:: e.g. __package_apt for Debian __package_emerge for Gentoo +state:: + The state the package should be in, either "present" or "absent" + (the old values "installed" or "removed" will be removed in cdist 2.1). + EXAMPLES -------- diff --git a/conf/type/__package/parameter/optional b/conf/type/__package/parameter/optional index 6f793411..9982507e 100644 --- a/conf/type/__package/parameter/optional +++ b/conf/type/__package/parameter/optional @@ -2,3 +2,4 @@ name version type pkgsite +state diff --git a/conf/type/__package/parameter/required b/conf/type/__package/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_apt/gencode-remote b/conf/type/__package_apt/gencode-remote index 0bcdb946..14b2f884 100755 --- a/conf/type/__package_apt/gencode-remote +++ b/conf/type/__package_apt/gencode-remote @@ -27,7 +27,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi # Correct pre 2.1 naming - FIXME in 2.1 case "$state_should" in diff --git a/conf/type/__package_apt/man.text b/conf/type/__package_apt/man.text index fd9c1a9c..7e880054 100644 --- a/conf/type/__package_apt/man.text +++ b/conf/type/__package_apt/man.text @@ -16,9 +16,7 @@ manage packages. REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" - (the old values "installed" or "removed" will be removed in cdist 2.1). +None OPTIONAL PARAMETERS @@ -26,6 +24,10 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. +state:: + The state the package should be in, either "present" or "absent" + (the old values "installed" or "removed" will be removed in cdist 2.1). + EXAMPLES -------- diff --git a/conf/type/__package_apt/parameter/optional b/conf/type/__package_apt/parameter/optional index a52167d3..41b8e6cf 100644 --- a/conf/type/__package_apt/parameter/optional +++ b/conf/type/__package_apt/parameter/optional @@ -1,2 +1,3 @@ name version +state diff --git a/conf/type/__package_apt/parameter/required b/conf/type/__package_apt/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_apt/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_luarocks/gencode-remote b/conf/type/__package_luarocks/gencode-remote index 327f812c..e8a7240c 100755 --- a/conf/type/__package_luarocks/gencode-remote +++ b/conf/type/__package_luarocks/gencode-remote @@ -29,7 +29,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi # Correct pre 2.1 naming - FIXME in 2.1 case "$state_should" in installed) diff --git a/conf/type/__package_luarocks/man.text b/conf/type/__package_luarocks/man.text index 8b041b7c..75083821 100644 --- a/conf/type/__package_luarocks/man.text +++ b/conf/type/__package_luarocks/man.text @@ -15,9 +15,7 @@ LuaRocks is a deployment and management system for Lua modules. REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" - (the old values "installed" or "removed" will be removed in cdist 2.1). +None OPTIONAL PARAMETERS @@ -25,6 +23,10 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. +state:: + The state the package should be in, either "present" or "absent" + (the old values "installed" or "removed" will be removed in cdist 2.1). + EXAMPLES -------- diff --git a/conf/type/__package_luarocks/parameter/optional b/conf/type/__package_luarocks/parameter/optional index f121bdbf..1b423dc4 100644 --- a/conf/type/__package_luarocks/parameter/optional +++ b/conf/type/__package_luarocks/parameter/optional @@ -1 +1,2 @@ name +state diff --git a/conf/type/__package_luarocks/parameter/required b/conf/type/__package_luarocks/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_luarocks/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_opkg/gencode-remote b/conf/type/__package_opkg/gencode-remote index bd9a599b..99f86632 100755 --- a/conf/type/__package_opkg/gencode-remote +++ b/conf/type/__package_opkg/gencode-remote @@ -28,7 +28,12 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi + state_is="$(cat "$__object/explorer/pkg_status")" case "$state_is" in absent*) diff --git a/conf/type/__package_opkg/man.text b/conf/type/__package_opkg/man.text index 19d26af6..3d02d1ce 100644 --- a/conf/type/__package_opkg/man.text +++ b/conf/type/__package_opkg/man.text @@ -15,8 +15,7 @@ opkg is usually used on OpenWRT to manage packages. REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" +None OPTIONAL PARAMETERS @@ -24,6 +23,9 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. +state:: + The state the package should be in, either "present" or "absent" + EXAMPLES -------- diff --git a/conf/type/__package_opkg/parameter/optional b/conf/type/__package_opkg/parameter/optional index f121bdbf..1b423dc4 100644 --- a/conf/type/__package_opkg/parameter/optional +++ b/conf/type/__package_opkg/parameter/optional @@ -1 +1,2 @@ name +state diff --git a/conf/type/__package_opkg/parameter/required b/conf/type/__package_opkg/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_opkg/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_pacman/gencode-remote b/conf/type/__package_pacman/gencode-remote index e585ee86..9918d28d 100755 --- a/conf/type/__package_pacman/gencode-remote +++ b/conf/type/__package_pacman/gencode-remote @@ -31,7 +31,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi case "$state_should" in installed) echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2 diff --git a/conf/type/__package_pacman/man.text b/conf/type/__package_pacman/man.text index fe2abac8..b6d07c94 100644 --- a/conf/type/__package_pacman/man.text +++ b/conf/type/__package_pacman/man.text @@ -16,9 +16,7 @@ packages. REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" - (the old values "installed" or "removed" will be removed in cdist 2.1). +None OPTIONAL PARAMETERS @@ -26,6 +24,10 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. +state:: + The state the package should be in, either "present" or "absent" + (the old values "installed" or "removed" will be removed in cdist 2.1). + EXAMPLES -------- diff --git a/conf/type/__package_pacman/parameter/optional b/conf/type/__package_pacman/parameter/optional index f121bdbf..1b423dc4 100644 --- a/conf/type/__package_pacman/parameter/optional +++ b/conf/type/__package_pacman/parameter/optional @@ -1 +1,2 @@ name +state diff --git a/conf/type/__package_pacman/parameter/required b/conf/type/__package_pacman/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_pacman/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_pip/gencode-remote b/conf/type/__package_pip/gencode-remote index 0f15abdc..3456ced2 100644 --- a/conf/type/__package_pip/gencode-remote +++ b/conf/type/__package_pip/gencode-remote @@ -22,7 +22,11 @@ # state_is=$(cat "$__object/explorer/state") -state_should=$(cat "$__object/parameter/state") +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi [ "$state_is" = "$state_should" ] && exit 0 diff --git a/conf/type/__package_pip/man.text b/conf/type/__package_pip/man.text index 2a620658..21d4f9fd 100644 --- a/conf/type/__package_pip/man.text +++ b/conf/type/__package_pip/man.text @@ -16,8 +16,7 @@ It is also included in the python virtualenv environment. REQUIRED PARAMETERS ------------------- -state:: - Either "present" or "absent". +None OPTIONAL PARAMETERS @@ -28,6 +27,9 @@ name:: pip:: Instead of using pip from PATH, use the specific pip path. +state:: + Either "present" or "absent". + EXAMPLES -------- diff --git a/conf/type/__package_pip/parameter/optional b/conf/type/__package_pip/parameter/optional index a1b589e3..f32876f7 100644 --- a/conf/type/__package_pip/parameter/optional +++ b/conf/type/__package_pip/parameter/optional @@ -1 +1,2 @@ pip +state diff --git a/conf/type/__package_pip/parameter/required b/conf/type/__package_pip/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_pip/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_pkg_freebsd/gencode-remote b/conf/type/__package_pkg_freebsd/gencode-remote index ef6632c0..f7dbbd7f 100755 --- a/conf/type/__package_pkg_freebsd/gencode-remote +++ b/conf/type/__package_pkg_freebsd/gencode-remote @@ -63,7 +63,11 @@ if [ -f "$__object/parameter/pkgsite" ]; then pkgsite="$(cat "$__object/parameter/pkgsite")" fi -state="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state="$(cat "$__object/parameter/state")" +else + state="present" +fi curr_version="$(cat "$__object/explorer/pkg_version")" add_cmd="pkg_add" rm_cmd="pkg_delete" diff --git a/conf/type/__package_pkg_freebsd/man.text b/conf/type/__package_pkg_freebsd/man.text index f41ac47a..3087cae1 100644 --- a/conf/type/__package_pkg_freebsd/man.text +++ b/conf/type/__package_pkg_freebsd/man.text @@ -15,8 +15,7 @@ This type is usually used on FreeBSD to manage packages. REQUIRED PARAMETERS ------------------- -state:: - Either "present" or "absent". +None OPTIONAL PARAMETERS @@ -33,6 +32,9 @@ version:: pkgsite:: If supplied, use to install from a specific package repository. +state:: + Either "present" or "absent". + EXAMPLES -------- diff --git a/conf/type/__package_pkg_freebsd/parameter/optional b/conf/type/__package_pkg_freebsd/parameter/optional index 3fb2f29e..8cb68f98 100644 --- a/conf/type/__package_pkg_freebsd/parameter/optional +++ b/conf/type/__package_pkg_freebsd/parameter/optional @@ -2,3 +2,4 @@ name flavor version pkgsite +state diff --git a/conf/type/__package_pkg_freebsd/parameter/required b/conf/type/__package_pkg_freebsd/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_pkg_freebsd/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_pkg_openbsd/gencode-remote b/conf/type/__package_pkg_openbsd/gencode-remote index 26dd4689..7788c210 100755 --- a/conf/type/__package_pkg_openbsd/gencode-remote +++ b/conf/type/__package_pkg_openbsd/gencode-remote @@ -42,7 +42,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi # Correct pre 2.1 naming - FIXME in 2.1 case "$state_should" in installed) diff --git a/conf/type/__package_pkg_openbsd/man.text b/conf/type/__package_pkg_openbsd/man.text index 71cf9d4e..91c8d378 100644 --- a/conf/type/__package_pkg_openbsd/man.text +++ b/conf/type/__package_pkg_openbsd/man.text @@ -15,9 +15,7 @@ This type is usually used on OpenBSD to manage packages. REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" - (the old values "installed" or "removed" will be removed in cdist 2.1). +None OPTIONAL PARAMETERS @@ -28,6 +26,10 @@ name:: flavor:: If supplied, use to avoid ambiguity. +state:: + The state the package should be in, either "present" or "absent" + (the old values "installed" or "removed" will be removed in cdist 2.1). + EXAMPLES -------- diff --git a/conf/type/__package_pkg_openbsd/parameter/optional b/conf/type/__package_pkg_openbsd/parameter/optional index 29b123ef..77fd22b3 100644 --- a/conf/type/__package_pkg_openbsd/parameter/optional +++ b/conf/type/__package_pkg_openbsd/parameter/optional @@ -1,2 +1,3 @@ name flavor +state diff --git a/conf/type/__package_pkg_openbsd/parameter/required b/conf/type/__package_pkg_openbsd/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_pkg_openbsd/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_rubygem/gencode-remote b/conf/type/__package_rubygem/gencode-remote index 638c4252..059e125e 100755 --- a/conf/type/__package_rubygem/gencode-remote +++ b/conf/type/__package_rubygem/gencode-remote @@ -27,7 +27,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi # Correct pre 2.1 naming - FIXME in 2.1 case "$state_should" in installed) diff --git a/conf/type/__package_rubygem/man.text b/conf/type/__package_rubygem/man.text index 79bb8b52..55b202dc 100644 --- a/conf/type/__package_rubygem/man.text +++ b/conf/type/__package_rubygem/man.text @@ -15,9 +15,7 @@ Rubygems is the default package management system for the Ruby programming langu REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" - (the old values "installed" or "removed" will be removed in cdist 2.1). +None OPTIONAL PARAMETERS @@ -25,6 +23,10 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. +state:: + The state the package should be in, either "present" or "absent" + (the old values "installed" or "removed" will be removed in cdist 2.1). + EXAMPLES -------- diff --git a/conf/type/__package_rubygem/parameter/optional b/conf/type/__package_rubygem/parameter/optional index f121bdbf..1b423dc4 100644 --- a/conf/type/__package_rubygem/parameter/optional +++ b/conf/type/__package_rubygem/parameter/optional @@ -1 +1,2 @@ name +state diff --git a/conf/type/__package_rubygem/parameter/required b/conf/type/__package_rubygem/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_rubygem/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_yum/gencode-remote b/conf/type/__package_yum/gencode-remote index df2bf405..71c8034a 100755 --- a/conf/type/__package_yum/gencode-remote +++ b/conf/type/__package_yum/gencode-remote @@ -27,7 +27,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi case "$state_should" in installed) echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2 diff --git a/conf/type/__package_yum/man.text b/conf/type/__package_yum/man.text index 9dfb394e..30c3f308 100644 --- a/conf/type/__package_yum/man.text +++ b/conf/type/__package_yum/man.text @@ -17,9 +17,7 @@ slightly confusing error message "Error: Nothing to do". REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" - (the old values "installed" or "removed" will be removed in cdist 2.1). +None OPTIONAL PARAMETERS @@ -27,6 +25,10 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. +state:: + The state the package should be in, either "present" or "absent" + (the old values "installed" or "removed" will be removed in cdist 2.1). + EXAMPLES -------- diff --git a/conf/type/__package_yum/parameter/optional b/conf/type/__package_yum/parameter/optional index f121bdbf..1b423dc4 100644 --- a/conf/type/__package_yum/parameter/optional +++ b/conf/type/__package_yum/parameter/optional @@ -1 +1,2 @@ name +state diff --git a/conf/type/__package_yum/parameter/required b/conf/type/__package_yum/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_yum/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/conf/type/__package_zypper/gencode-remote b/conf/type/__package_zypper/gencode-remote index 3323d6b1..ca9aec33 100755 --- a/conf/type/__package_zypper/gencode-remote +++ b/conf/type/__package_zypper/gencode-remote @@ -33,7 +33,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi # Exit if nothing is needed to be done [ "$state_is" = "$state_should" ] && exit 0 diff --git a/conf/type/__package_zypper/man.text b/conf/type/__package_zypper/man.text index 9cff9706..702d51e5 100644 --- a/conf/type/__package_zypper/man.text +++ b/conf/type/__package_zypper/man.text @@ -15,8 +15,7 @@ Zypper is usually used on the SuSE distribution to manage packages. REQUIRED PARAMETERS ------------------- -state:: - The state the package should be in, either "present" or "absent" +None OPTIONAL PARAMETERS @@ -24,6 +23,9 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. +state:: + The state the package should be in, either "present" or "absent" + EXAMPLES -------- diff --git a/conf/type/__package_zypper/parameter/optional b/conf/type/__package_zypper/parameter/optional index f121bdbf..1b423dc4 100644 --- a/conf/type/__package_zypper/parameter/optional +++ b/conf/type/__package_zypper/parameter/optional @@ -1 +1,2 @@ name +state diff --git a/conf/type/__package_zypper/parameter/required b/conf/type/__package_zypper/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/conf/type/__package_zypper/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state