Skip to content

Commit

Permalink
Merge pull request #237 from puppetlabs/fix_package_task_on_yum
Browse files Browse the repository at this point in the history
Fix package task for yum when passing version
  • Loading branch information
carabasdaniel committed Feb 19, 2021
2 parents a82253d + 6dc51fc commit fe685d9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tasks/linux.sh
Expand Up @@ -72,7 +72,7 @@ case "$available_manager" in
provided_package="$(rpm -q --whatprovides "$name")" || provided_package=

# <package>-<version> is the syntax for installing a specific version in yum
[[ $version ]] && name="${name}-${version}"
[[ $version ]] && full_name="${name}-${version}" || full_name="${name}"

# For Ruby compatibility, 'status' and 'install' will check if the package is upgradable
case "$action" in
Expand All @@ -81,14 +81,14 @@ case "$available_manager" in
;;

"install")
yum install "$name" "${options[@]}" >/dev/null || fail
yum install "$full_name" "${options[@]}" >/dev/null || fail
# Check for this again after installing
provided_package="$(rpm -q --whatprovides "$name")" || provided_package=
yum_check_latest
;;

"uninstall")
yum remove "$name" "${options[@]}" >/dev/null || fail
yum remove "$full_name" "${options[@]}" >/dev/null || fail
cmd_status="$(yum_status '\{ "status": "installed", "version": "%{VERSION}-%{RELEASE}" \}')" || {
cmd_status='{ "status": "uninstalled" }'
}
Expand All @@ -104,8 +104,8 @@ case "$available_manager" in

# Why does yum upgrade not return non-zero on a nonexistent package...
# Because of this, check the output
yum_out=$(yum upgrade "$name" "${options[@]}") || fail
[[ $yum_out =~ "No package $name available" ]] && fail
yum_out=$(yum upgrade "$full_name" "${options[@]}") || fail
[[ $yum_out =~ "No package $full_name available" ]] && fail

# For Ruby compatibility, this command uses a different output format
# Check for this again after installing
Expand Down

0 comments on commit fe685d9

Please sign in to comment.