Class: UnpackStrategy::Dmg Private
- Extended by:
- SystemCommand::Mixin, ClassMethods
- Includes:
- UnpackStrategy
- Defined in:
- unpack_strategy/dmg.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Strategy for unpacking disk images.
Defined Under Namespace
Modules: Bom
Constant Summary
Constants included from UnpackStrategy
Instance Attribute Summary
Attributes included from UnpackStrategy
Class Method Summary collapse
- .can_extract?(path) ⇒ Boolean private
- .extensions ⇒ Array<String> private
Instance Method Summary collapse
Methods included from SystemCommand::Mixin
system_command, system_command!
Methods included from ClassMethods
Methods included from UnpackStrategy
#dependencies, detect, #each_directory, #extract, #extract_nestedly, from_extension, from_magic, from_type, #initialize
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Class Method Details
.can_extract?(path) ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
181 182 183 184 |
# File 'unpack_strategy/dmg.rb', line 181 def self.can_extract?(path) stdout, _, status = system_command("hdiutil", args: ["imageinfo", "-format", path], print_stderr: false).to_a (status.success? && !stdout.empty?) || false end |
.extensions ⇒ Array<String>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
176 177 178 |
# File 'unpack_strategy/dmg.rb', line 176 def self.extensions [".dmg"] end |
Instance Method Details
#mount(verbose: false, &_block) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'unpack_strategy/dmg.rb', line 187 def mount(verbose: false, &_block) Dir.mktmpdir("homebrew-dmg", HOMEBREW_TEMP) do |mount_dir| mount_dir = Pathname(mount_dir) without_eula = system_command( "hdiutil", args: [ "attach", "-plist", "-nobrowse", "-readonly", "-mountrandom", mount_dir, path ], input: "qn\n", print_stderr: false, verbose:, ) # If mounting without agreeing to EULA succeeded, there is none. plist = if without_eula.success? without_eula.plist else without_eula.assert_success! if without_eula.stdout.empty? cdr_path = mount_dir/path.basename.sub_ext(".cdr") quiet_flag = "-quiet" unless verbose system_command!( "hdiutil", args: [ "convert", *quiet_flag, "-format", "UDTO", "-o", cdr_path, path ], verbose:, ) with_eula = system_command!( "hdiutil", args: [ "attach", "-plist", "-nobrowse", "-readonly", "-mountrandom", mount_dir, cdr_path ], verbose:, ) if verbose && !(eula_text = without_eula.stdout).empty? ohai "Software License Agreement for '#{path}':", eula_text end with_eula.plist end mounts = if plist.respond_to?(:fetch) plist.fetch("system-entities", []) .filter_map { |entity| entity["mount-point"] } .map { |path| Mount.new(path) } else [] end begin yield mounts ensure mounts.each do |mount| mount.eject(verbose:) end end end end |