From 37a8b4af2b75ee19c76fe70855ea6941888469f8 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Wed, 10 Sep 2014 15:54:13 -0400 Subject: [PATCH] Minor fixes Fixed pkgng_exists explorer (can't reference $__global) Fixed logic in __package/pkgng_freebsd/gencode-remote Wasn't installing package if it already exists, but after explorer execution --- cdist/conf/type/__package/explorer/pkgng_exists | 4 +++- cdist/conf/type/__package_pkgng_freebsd/gencode-remote | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__package/explorer/pkgng_exists b/cdist/conf/type/__package/explorer/pkgng_exists index 7c4f2256..d0919243 100755 --- a/cdist/conf/type/__package/explorer/pkgng_exists +++ b/cdist/conf/type/__package/explorer/pkgng_exists @@ -21,7 +21,9 @@ # Retrieve the status of a package - parsed dpkg output # -if [ "$(cat "$__global/explorer/os")" = "freebsd" ]; then +# Can't access $__global/explorer/os from here, so recreate the functionality +# because there's no point in executing this explorer on non-FreeBSD targets. +if [ $(uname) = "FreeBSD" ]; then if command -v pkg >&-; then printf "pkg-ng installed" else diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote index 36af987b..a7ae8b58 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote @@ -99,15 +99,20 @@ if [ -n "$curr_version" ]; then # PKG *is* installed if [ -n "$flavor" ]; then cmd="${cmd}-${flavor}" fi + # PKG is supposed to be removed if [ "$state" = "absent" ]; then execcmd "rm" "${cmd}" - elif [ "$version" != "$curr_version" ]; then + # PKG is supposed to be installed to a particular version + elif [ -n "$version" ] && [ "$version" != "$curr_version" ]; then if [ "$upgrade" = "true" ]; then execcmd "upg" "${cmd}" else printf "Version %s is already installed and pkg-ng can't upgrade directly to version %s.\nTo upgrade to the latest version, use the --upgrade flag.\n" "$curr_version" "$version" >&2 exit 1 fi + # PKG is supposed to be installed to the latest version + else + : # Do nothing. fi else # PKG *isn't* installed if [ "$state" = "absent" ]; then # Shouldn't be installed