From db32d0de3a62044ce23c036cca0d79ffe34a90a5 Mon Sep 17 00:00:00 2001 From: Andres Erbsen Date: Fri, 2 Sep 2016 11:13:37 -0400 Subject: [PATCH] __package_pkg_openbsd: support --version --- .../type/__package_pkg_openbsd/gencode-remote | 22 +++++++++++++++---- cdist/conf/type/__package_pkg_openbsd/man.rst | 3 +++ .../__package_pkg_openbsd/parameter/optional | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index dea7f711..5ba5f7ef 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -29,6 +29,10 @@ os_version="$(cat "$__global/explorer/os_version")" machine="$(cat "$__global/explorer/machine")" +if [ -f "$__object/parameter/version" ]; then + version="$(cat "$__object/parameter/version")" +fi + if [ -f "$__object/parameter/flavor" ]; then flavor="$(cat "$__object/parameter/flavor")" fi @@ -42,6 +46,16 @@ else name="$__object_id" fi +if [ -n "$version" -a -n "$flavor" ]; then + pkgid="$name-$version-$flavor" +elif [ -n "$version" ]; then + pkgid="$name-$version" +elif [ -n "$flavor" ]; then + pkgid="$name--$flavor" +else + pkgid="$name" +fi + state_should="$(cat "$__object/parameter/state")" pkg_version="$(cat "$__object/explorer/pkg_version")" @@ -65,8 +79,8 @@ 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" 2>&1) -pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 +status=\$(pkg_add "$pkgopts" "$pkgid" 2>&1) +pkg_info | grep "^${name}.*${version}.*${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 @@ -83,8 +97,8 @@ eof absent) # 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 +status=\$(pkg_delete "$pkgopts" "$pkgid") +pkg_info | grep "^${name}.*${version}.*${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 diff --git a/cdist/conf/type/__package_pkg_openbsd/man.rst b/cdist/conf/type/__package_pkg_openbsd/man.rst index 0814029f..dcfd0719 100644 --- a/cdist/conf/type/__package_pkg_openbsd/man.rst +++ b/cdist/conf/type/__package_pkg_openbsd/man.rst @@ -24,6 +24,9 @@ name flavor If supplied, use to avoid ambiguity. +version + If supplied, use to avoid ambiguity. + state Either "present" or "absent", defaults to "present" diff --git a/cdist/conf/type/__package_pkg_openbsd/parameter/optional b/cdist/conf/type/__package_pkg_openbsd/parameter/optional index 43278d16..6a5f9277 100644 --- a/cdist/conf/type/__package_pkg_openbsd/parameter/optional +++ b/cdist/conf/type/__package_pkg_openbsd/parameter/optional @@ -1,4 +1,5 @@ name +version flavor state pkg_path