|
|
@ -1,5 +1,6 @@
|
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
require 'open3'
|
|
|
|
require 'tempfile'
|
|
|
|
require 'tempfile'
|
|
|
|
|
|
|
|
|
|
|
|
def with_tempfile(name)
|
|
|
|
def with_tempfile(name)
|
|
|
@ -10,14 +11,16 @@ ensure
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
plist = ARGF.read
|
|
|
|
plist = ARGF.read
|
|
|
|
puts plist and exit unless File.exist?("/usr/libexec/PlistBuddy")
|
|
|
|
puts plist or exit unless File.exist?("/usr/libexec/PlistBuddy")
|
|
|
|
|
|
|
|
|
|
|
|
with_tempfile('info.plist') do |f|
|
|
|
|
with_tempfile('info.plist') do |f|
|
|
|
|
f << plist
|
|
|
|
f << plist
|
|
|
|
f.flush
|
|
|
|
f.flush
|
|
|
|
|
|
|
|
|
|
|
|
vars = `/usr/libexec/PlistBuddy -c "Print :variablesdontexport" #{f.path}`
|
|
|
|
stdout, _, status = Open3.capture3("/usr/libexec/PlistBuddy -c 'Print :variablesdontexport' #{f.path}")
|
|
|
|
vars = vars.split("\n")[1..-2].map(&:strip)
|
|
|
|
puts plist or exit unless status.success?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vars = stdout.split("\n")[1..-2].map(&:strip)
|
|
|
|
|
|
|
|
|
|
|
|
vars.each do |var|
|
|
|
|
vars.each do |var|
|
|
|
|
`/usr/libexec/PlistBuddy -c "Set :variables:#{var} ''" #{f.path}`
|
|
|
|
`/usr/libexec/PlistBuddy -c "Set :variables:#{var} ''" #{f.path}`
|
|
|
|