Permalink
Browse files

Extracted method package_name

  • Loading branch information...
1 parent 99bf966 commit cc44e3bace865747016c7f33f2df204219646142 Matthew Landauer committed Feb 26, 2009
Showing with 12 additions and 6 deletions.
  1. +12 −6 chef/lib/chef/provider/package/freebsd.rb
@@ -78,6 +78,7 @@ def load_current_resource
@current_resource
end
+ # The name of the leaf directory in /usr/ports
def port_name
# if passed ports:package, build DIST_SUBDIR from ports
# if passed a sole word in source that isn't ports, consider it DIST_SUBDIR, install package
@@ -91,6 +92,11 @@ def port_name
@new_resource.package_name
end
end
+
+ # The name of the package as understood by pkg_add and pkg_info
+ def package_name
+ @new_resource.package_name
+ end
def install_package(name, version)
unless @current_resource.version
@@ -102,10 +108,10 @@ def install_package(name, version)
)
when /^http/, /^ftp/
run_command(
- :command => "pkg_add -r #{@new_resource.name}",
+ :command => "pkg_add -r #{package_name}",
:environment => { "PACKAGESITE" => @new_resource.source }
)
- Chef::Log.info("Installed package #{@new_resource.name} from: #{@new_resource.source}")
+ Chef::Log.info("Installed package #{package_name} from: #{@new_resource.source}")
when /^\//
run_command(
:command => "pkg_add #{@new_resource.name}",
@@ -114,19 +120,19 @@ def install_package(name, version)
Chef::Log.info("Installed package #{@new_resource.name} from: #{@new_resource.source}")
else
run_command(
- :command => "pkg_add -r #{@new_resource.name}"
+ :command => "pkg_add -r #{package_name}"
)
- Chef::Log.info("Installed package #{@new_resource.name}")
+ Chef::Log.info("Installed package #{package_name}")
end
end
end
def remove_package(name, version)
if @current_resource.version
run_command(
- :command => "pkg_delete #{@current_resource.name}-#{@current_resource.version}"
+ :command => "pkg_delete #{package_name}-#{@current_resource.version}"
)
- Chef::Log.info("Removed package #{@current_resource.name}-#{@current_resource.version}")
+ Chef::Log.info("Removed package #{package_name}-#{@current_resource.version}")
end
end
end

0 comments on commit cc44e3b

Please sign in to comment.