X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/a08c8d97d5cd3666799fb3bef14618d4c7c23398..HEAD:/cookbooks/python/resources/package.rb diff --git a/cookbooks/python/resources/package.rb b/cookbooks/python/resources/package.rb index 0a3f49170..c838690af 100644 --- a/cookbooks/python/resources/package.rb +++ b/cookbooks/python/resources/package.rb @@ -40,6 +40,20 @@ action :install do end end +action :upgrade do + if new_resource.version.nil? + execute "pip-upgrade-#{new_resource.package_name}" do + command "#{pip_command} install --upgrade #{new_resource.package_name}" + only_if "#{pip_command} list --outdated | fgrep -q #{new_resource.package_name}" + end + else + execute "pip-upgrade-#{new_resource.package_name}" do + command "#{pip_command} install --upgrade #{new_resource.package_name}==#{new_resource.version}" + not_if "#{pip_command} show #{new_resource.package_name} | fgrep -q #{new_resource.version}" + end + end +end + action :remove do execute "pip-uninstall-#{new_resource.package_name}" do command "#{pip_command} uninstall #{new_resource.package_name}"