From 3fffb93150a57786b6db1c1406b93a17bf727e64 Mon Sep 17 00:00:00 2001 From: og Date: Mon, 3 Mar 2014 14:59:50 -0700 Subject: [PATCH 1/3] OpenBSD pkg utils does not return properly, so we have to verify success by looking at the list of installed packages after the present/absent actions --- .../type/__package_pkg_openbsd/gencode-remote | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 9d760655..7583167e 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -69,12 +69,17 @@ case "$state_should" in # use this because pkg_add doesn't properly handle errors cat << eof export PKG_PATH="$pkg_path" -status=\$(pkg_add "$pkgopts" "$name--$flavor") +status=\$(pkg_add "$pkgopts" "$name--$flavor" 2>&1) +pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 -# no error -if [ -n "\$status" ]; then +# We didn't find the package in the list of 'installed packages', so it failed +# This is necessary because pkg_add doesn't return properly +if [ $? -ne 0 ]; then + if [ -z "${status}" ]; then + status="Failed to add package, uncaught exception." + fi echo "Error: \$status" - exit 1 + exit 1 fi eof ;; @@ -83,9 +88,14 @@ eof # use this because pkg_add doesn't properly handle errors cat << eof status=\$(pkg_delete "$pkgopts" "$name--$flavor") +pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 -# no error -if [ -n "\$status" ]; then +# We found the package in the list of 'installed packages' +# This would indicate that pkg_delete failed, send the output of pkg_delete +if [ $? -eq 0 ]; then + if [ -z "${status}" ]; then + status="Failed to remove package, uncaught exception." + fi echo "Error: \$status" exit 1 fi From 074938c697f2671d384f774ecf80d4ee5e2d2c32 Mon Sep 17 00:00:00 2001 From: og Date: Mon, 3 Mar 2014 15:13:57 -0700 Subject: [PATCH 2/3] . --- cdist/conf/type/__package_pkg_openbsd/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 7583167e..e7f40a4d 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -79,7 +79,7 @@ if [ $? -ne 0 ]; then status="Failed to add package, uncaught exception." fi echo "Error: \$status" - exit 1 + exit 1 fi eof ;; From 3d5706d3cc30e556ea6fbf2e6addf8a925362020 Mon Sep 17 00:00:00 2001 From: og Date: Sat, 8 Mar 2014 17:18:19 -0700 Subject: [PATCH 3/3] escaped some variables in the gencode-remote output --- cdist/conf/type/__package_pkg_openbsd/gencode-remote | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index e7f40a4d..08e15e89 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -74,8 +74,8 @@ pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 # We didn't find the package in the list of 'installed packages', so it failed # This is necessary because pkg_add doesn't return properly -if [ $? -ne 0 ]; then - if [ -z "${status}" ]; then +if [ \$? -ne 0 ]; then + if [ -z "\${status}" ]; then status="Failed to add package, uncaught exception." fi echo "Error: \$status" @@ -92,8 +92,8 @@ pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 # We found the package in the list of 'installed packages' # This would indicate that pkg_delete failed, send the output of pkg_delete -if [ $? -eq 0 ]; then - if [ -z "${status}" ]; then +if [ \$? -eq 0 ]; then + if [ -z "\${status}" ]; then status="Failed to remove package, uncaught exception." fi echo "Error: \$status"