Module: UnpackStrategy::Dmg::Bom Private
- Extended by:
- SystemCommand::Mixin
- Defined in:
- unpack_strategy/dmg.rb
Overview
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Helper module for listing the contents of a volume mounted from a disk image.
Defined Under Namespace
Classes: EmptyError, Error
Class Method Summary collapse
- .bom(pathname) ⇒ String private
-
.dmg_metadata?(pathname) ⇒ Boolean
private
Check if path is considered disk image metadata.
-
.system_dir_symlink?(pathname) ⇒ Boolean
private
Check if path is a symlink to a system directory (commonly to /Applications).
Methods included from SystemCommand::Mixin
system_command, system_command!
Class Method Details
.bom(pathname) ⇒ 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.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'unpack_strategy/dmg.rb', line 54 def self.bom(pathname) tries = 0 result = loop do # We need to use `find` here instead of Ruby in order to properly handle # file names containing special characters, such as “e” + “´” vs. “é”. r = system_command("find", args: [".", "-print0"], chdir: pathname, print_stderr: false, reset_uid: true) tries += 1 # Spurious bug on CI, which in most cases can be worked around by retrying. break r unless r.stderr.match?(/Interrupted system call/i) raise "Command `#{r.command.shelljoin}` was interrupted." if tries >= 3 end odebug "Command `#{result.command.shelljoin}` in '#{pathname}' took #{tries} tries." if tries > 1 bom_paths = result.stdout.split("\0") raise EmptyError, pathname if bom_paths.empty? bom_paths .reject { |path| (Pathname(path)) } .reject { |path| system_dir_symlink?(pathname/path) } .join("\n") end |
.dmg_metadata?(pathname) ⇒ 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.
Check if path is considered disk image metadata.
43 44 45 |
# File 'unpack_strategy/dmg.rb', line 43 def self.(pathname) DMG_METADATA.include?(pathname.cleanpath.ascend.to_a.last.to_s) end |
.system_dir_symlink?(pathname) ⇒ 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.
Check if path is a symlink to a system directory (commonly to /Applications).
49 50 51 |
# File 'unpack_strategy/dmg.rb', line 49 def self.system_dir_symlink?(pathname) pathname.symlink? && MacOS.system_dir?(pathname.dirname.join(pathname.readlink)) end |