Module: UnpackStrategy::Dmg::Bom
- Defined in:
- unpack_strategy/dmg.rb
Overview
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
-
.dmg_metadata?(pathname) ⇒ Boolean
Check if path is considered disk image metadata.
-
.system_dir_symlink?(pathname) ⇒ Boolean
Check if path is a symlink to a system directory (commonly to /Applications).
Class Method Details
.bom(pathname) ⇒ String
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'unpack_strategy/dmg.rb', line 49 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) 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
Check if path is considered disk image metadata.
38 39 40 |
# File 'unpack_strategy/dmg.rb', line 38 def self.(pathname) DMG_METADATA.include?(pathname.cleanpath.ascend.to_a.last.to_s) end |
.system_dir_symlink?(pathname) ⇒ Boolean
Check if path is a symlink to a system directory (commonly to /Applications).
44 45 46 |
# File 'unpack_strategy/dmg.rb', line 44 def self.system_dir_symlink?(pathname) pathname.symlink? && MacOS.system_dir?(pathname.dirname.join(pathname.readlink)) end |