Skip to content

Fix launchd service provider to work with OX S 10.7 (Lion) #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet/provider/package/appdmg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def self.installpkgdmg(source, name)
require 'facter/util/plist'
cached_source = source
if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
cached_source = "/tmp/#{name}"
cached_source = "/tmp/#{name}.dmg"
begin
curl "-o", cached_source, "-C", "-", "-k", "-s", "--url", source
Puppet.debug "Success: curl transfered [#{name}]"
Expand Down
12 changes: 9 additions & 3 deletions lib/puppet/provider/package/macports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


def self.parse_installed_query_line(line)
regex = /(\S+)\s+@(\S+)_(\S+)\s+\(active\)/
regex = /(\S+)\s+@(\S+)_(\d+).*\(active\)/
fields = [:name, :ensure, :revision]
hash_from_line(line, regex, fields)
end
Expand Down Expand Up @@ -66,14 +66,20 @@ def install
end

def query
return self.class.parse_installed_query_line(port("-q", :installed, @resource[:name]))
result = self.class.parse_installed_query_line(self.class.stripWarnings port("-q", :installed, @resource[:name]))
return {} if result.nil?
return result
end

def self.stripWarnings(output)
return output.gsub(/^Warning:.*$/, "").strip
end

def latest
# We need both the version and the revision to be confident
# we've got the latest revision of a specific version
# Note we're still not doing anything with variants here.
info_line = port("-q", :info, "--line", "--version", "--revision", @resource[:name])
info_line = self.class.stripWarnings port("-q", :info, "--line", "--version", "--revision", @resource[:name])
return nil if info_line == ""

if newest = self.class.parse_info_query_line(info_line)
Expand Down
7 changes: 6 additions & 1 deletion lib/puppet/provider/package/pkgdmg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ def self.installpkgdmg(source, name)
require 'open-uri'
cached_source = source
if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
cached_source = "/tmp/#{name}"
if source =~ /\.dmg$/i
ext = ".dmg"
else
ext = ".pkg"
end
cached_source = "/tmp/#{name}#{ext}"
begin
curl "-o", cached_source, "-C", "-", "-k", "-s", "--url", source
Puppet.debug "Success: curl transfered [#{name}]"
Expand Down
9 changes: 6 additions & 3 deletions lib/puppet/provider/service/launchd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def self.get_macosx_version_major
end
end

def self.has_launchd_overrides?
return (self.get_macosx_version_major == "10.6" || self.get_macosx_version_major == "10.7")
end

# finds the path for a given label and returns the path and parsed plist
# as an array of [path, plist]. Note plist is really a Hash here.
Expand Down Expand Up @@ -211,7 +214,7 @@ def enabled?
job_path, job_plist = plist_from_label(resource[:name])
job_plist_disabled = job_plist["Disabled"] if job_plist.has_key?("Disabled")

if self.class.get_macosx_version_major == "10.6"
if self.class.has_launchd_overrides?
if FileTest.file?(Launchd_Overrides) and overrides = self.class.read_plist(Launchd_Overrides)
if overrides.has_key?(resource[:name])
overrides_disabled = overrides[resource[:name]]["Disabled"] if overrides[resource[:name]].has_key?("Disabled")
Expand All @@ -236,7 +239,7 @@ def enabled?
# In 10.6 we need to write out a disabled key to the global overrides plist, in earlier
# versions this is stored in the job plist itself.
def enable
if self.class.get_macosx_version_major == "10.6"
if self.class.has_launchd_overrides?
overrides = self.class.read_plist(Launchd_Overrides)
overrides[resource[:name]] = { "Disabled" => false }
Plist::Emit.save_plist(overrides, Launchd_Overrides)
Expand All @@ -251,7 +254,7 @@ def enable


def disable
if self.class.get_macosx_version_major == "10.6"
if self.class.has_launchd_overrides?
overrides = self.class.read_plist(Launchd_Overrides)
overrides[resource[:name]] = { "Disabled" => true }
Plist::Emit.save_plist(overrides, Launchd_Overrides)
Expand Down