From 6eff4bb898a7ea7d8bcfd9cd23a3193f9fb6b80a Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Wed, 17 Sep 2014 17:43:29 -0400 Subject: [PATCH] Implemented telmich's suggestions Using $($__explorer/os), command -v directly Fix spacing Fix copyright year --- .../conf/type/__package/explorer/pkgng_exists | 10 ++----- cdist/conf/type/__package/manifest | 3 +- .../explorer/pkg_version | 2 +- .../__package_pkgng_freebsd/gencode-remote | 30 +++++++++---------- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/cdist/conf/type/__package/explorer/pkgng_exists b/cdist/conf/type/__package/explorer/pkgng_exists index d0919243..355c5d65 100755 --- a/cdist/conf/type/__package/explorer/pkgng_exists +++ b/cdist/conf/type/__package/explorer/pkgng_exists @@ -21,13 +21,7 @@ # Retrieve the status of a package - parsed dpkg output # -# 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 - printf "pkg-ng not found" - fi +if [ "$($__explorer/os)" = "freebsd" ]; then + command -v pkg fi diff --git a/cdist/conf/type/__package/manifest b/cdist/conf/type/__package/manifest index 2e085158..3e8928c0 100755 --- a/cdist/conf/type/__package/manifest +++ b/cdist/conf/type/__package/manifest @@ -34,8 +34,7 @@ else archlinux) type="pacman" ;; debian|ubuntu) type="apt" ;; freebsd) - exists="$(cat "$__object/explorer/pkgng_exists")" - if [ "$exists" = "pkg-ng installed" ]; then + if [ -n "$(cat "$__object/explorer/pkgng_exists")" ]; then type="pkgng_freebsd" else type="pkg_freebsd" diff --git a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version index fe940724..947857b9 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012 Jake Guffey (jake.guffey at eprotex.com) +# 2014 Jake Guffey (jake.guffey at eprotex.com) # # This file is part of cdist. # diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote index a7ae8b58..39965aca 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012 Jake Guffey (jake.guffey at eprotex.com) +# 2014 Jake Guffey (jake.guffey at eprotex.com) # # This file is part of cdist. # @@ -26,27 +26,27 @@ #set -x if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" + name="$(cat "$__object/parameter/name")" else - name="$__object_id" + name="$__object_id" fi if [ -f "$__object/parameter/flavor" ]; then - flavor="$(cat "$__object/parameter/flavor")" + flavor="$(cat "$__object/parameter/flavor")" fi if [ -f "$__object/parameter/version" ]; then - version="$(cat "$__object/parameter/version")" + version="$(cat "$__object/parameter/version")" fi if [ -f "$__object/parameter/upgrade" ]; then - upgrade="true" + upgrade="true" else upgrade="false" fi if [ -f "$__object/parameter/repo" ]; then - repo="$(cat "$__object/parameter/repo")" + repo="$(cat "$__object/parameter/repo")" fi if [ -f "$__object/parameter/state" ]; then @@ -82,15 +82,15 @@ execcmd(){ ;; esac - echo "$_cmd 2>&- >&-" # Silence the output of the command - echo "status=\$?" - echo "if [ \"\$status\" -ne \"0\" ]; then" - echo " echo \"Error: ${_cmd} exited nonzero with \$status\"'!' >&2" - echo " exit 1" - echo "fi" + echo "$_cmd 2>&- >&-" # Silence the output of the command + echo "status=\$?" + echo "if [ \"\$status\" -ne \"0\" ]; then" + echo " echo \"Error: ${_cmd} exited nonzero with \$status\"'!' >&2" + echo " exit 1" + echo "fi" } -if [ -n "$curr_version" ]; then # PKG *is* installed +if [ -n "$curr_version" ]; then # PKG *is* installed if [ -n "$repo" ]; then cmd="-r ${repo} ${name}" else @@ -114,7 +114,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed else : # Do nothing. fi -else # PKG *isn't* installed +else # PKG *isn't* installed if [ "$state" = "absent" ]; then # Shouldn't be installed exit 0 else # Should be installed