Module: Hbc::Staged

Included in:
DSL::Postflight, DSL::Preflight, DSL::UninstallPreflight, Installer
Defined in:
Library/Homebrew/cask/lib/hbc/staged.rb

Instance Method Summary collapse

Instance Method Details

#bundle_identifierObject



20
21
22
23
24
# File 'Library/Homebrew/cask/lib/hbc/staged.rb', line 20

def bundle_identifier
  plist_exec("Print CFBundleIdentifier").stdout.chomp
rescue StandardError => e
  raise CaskError, "#{@cask.token}: 'bundle_identifier' failed with: #{e}"
end

#current_userObject



40
41
42
# File 'Library/Homebrew/cask/lib/hbc/staged.rb', line 40

def current_user
  Utils.current_user
end

#info_plist_file(index = 0) ⇒ Object



3
4
5
6
7
8
# File 'Library/Homebrew/cask/lib/hbc/staged.rb', line 3

def info_plist_file(index = 0)
  index =  0 if index == :first
  index =  1 if index == :second
  index = -1 if index == :last
  @cask.artifacts.select { |a| a.is_a?(Artifact::App) }.at(index).target.join("Contents", "Info.plist")
end

#plist_exec(cmd) ⇒ Object



10
11
12
# File 'Library/Homebrew/cask/lib/hbc/staged.rb', line 10

def plist_exec(cmd)
  @command.run!("/usr/libexec/PlistBuddy", args: ["-c", cmd, info_plist_file])
end

#plist_set(key, value) ⇒ Object



14
15
16
17
18
# File 'Library/Homebrew/cask/lib/hbc/staged.rb', line 14

def plist_set(key, value)
  plist_exec("Set #{key} #{value}")
rescue StandardError => e
  raise CaskError, "#{@cask.token}: 'plist_set' failed with: #{e}"
end

#set_ownership(paths, user: current_user, group: "staff") ⇒ Object



33
34
35
36
37
38
# File 'Library/Homebrew/cask/lib/hbc/staged.rb', line 33

def set_ownership(paths, user: current_user, group: "staff")
  full_paths = remove_nonexistent(paths)
  return if full_paths.empty?
  @command.run!("/usr/sbin/chown", args: ["-R", "--", "#{user}:#{group}"] + full_paths,
                                   sudo: true)
end

#set_permissions(paths, permissions_str) ⇒ Object



26
27
28
29
30
31
# File 'Library/Homebrew/cask/lib/hbc/staged.rb', line 26

def set_permissions(paths, permissions_str)
  full_paths = remove_nonexistent(paths)
  return if full_paths.empty?
  @command.run!("/bin/chmod", args: ["-R", "--", permissions_str] + full_paths,
                              sudo: false)
end