Skip to content

Commit

Permalink
feat(salt@3006): Try using salt patch from lib
Browse files Browse the repository at this point in the history
  • Loading branch information
cdalvaro committed Nov 23, 2024
1 parent 5adc1b1 commit 2211574
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions Casks/[email protected]
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
module Utils
extend SystemCommand::Mixin

def self.patch_plist(daemon)
plist_file = "/Library/LaunchDaemons/com.saltstack.salt.#{daemon}.plist"
xml, _, status = system_command "plutil",
args: ["-convert", "xml1", "-o", "-", "--", plist_file],
sudo: true

return unless status.success?

xml = Plist.parse_xml(xml)

xml["EnvironmentVariables"] = {} unless xml.key?("EnvironmentVariables")
xml["EnvironmentVariables"]["HOMEBREW_PREFIX"] = HOMEBREW_PREFIX.to_s
xml["EnvironmentVariables"]["HOME"] ||= "/var/root"

path = xml["EnvironmentVariables"]["PATH"] || "/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
path = "#{HOMEBREW_PREFIX}/bin:#{path}" unless path.split(":").include?("#{HOMEBREW_PREFIX}/bin")
xml["EnvironmentVariables"]["PATH"] = path

random_str = (0...8).map { rand(65..90).chr }.join
new_plist_file = "/tmp/#{random_str}.#{File.basename(plist_file)}"
File.write(new_plist_file, xml.to_plist)
system_command "plutil",
args: ["-lint", new_plist_file]

system_command "mv",
args: [new_plist_file, plist_file],
sudo: true
system_command "chown",
args: ["root:wheel", plist_file],
sudo: true
end
end

cask "salt@3006" do
arch arm: "arm64", intel: "x86_64"

Expand All @@ -57,8 +21,8 @@ def self.patch_plist(daemon)
pkg "salt-#{version}-py3-#{arch}.pkg"

postflight do
require_relative "#{`brew --repository cdalvaro/tap`.lines.first.chomp}/lib/patches/salt"
%w[api master minion syndic].each { |daemon| Utils.patch_plist(daemon) }
require_relative "../lib/patches/salt"
%w[api master minion syndic].each { |daemon| Patches::Salt.patch_plist(daemon) }
end

uninstall launchctl: [
Expand Down

0 comments on commit 2211574

Please sign in to comment.