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