cask install: fix APFS DMG eject to use physical disk
This commit is contained in:
parent
e5bda4e781
commit
cf8d96e0b2
@ -16,13 +16,27 @@ describe Cask::Installer, :cask do
|
||||
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
||||
end
|
||||
|
||||
it "works with dmg-based Casks" do
|
||||
asset = Cask::CaskLoader.load(cask_path("container-dmg"))
|
||||
[
|
||||
["HFS+", "container-dmg"],
|
||||
["APFS", "container-apfs-dmg"],
|
||||
].each do |filesystem, cask|
|
||||
it "works with #{filesystem} dmg-based Casks" do
|
||||
asset = Cask::CaskLoader.load(cask_path(cask))
|
||||
diskutil_list_command = "diskutil list | grep '/dev'"
|
||||
|
||||
sleep(1)
|
||||
original_diskutil_list = `#{diskutil_list_command}`
|
||||
|
||||
described_class.new(asset).install
|
||||
|
||||
expect(Cask::Caskroom.path.join("container-dmg", asset.version)).to be_a_directory
|
||||
expect(Cask::Caskroom.path.join(cask, asset.version)).to be_a_directory
|
||||
expect(asset.config.appdir.join("container")).to be_a_file
|
||||
|
||||
sleep(2)
|
||||
expect { system diskutil_list_command }
|
||||
.to output(original_diskutil_list)
|
||||
.to_stdout_from_any_process
|
||||
end
|
||||
end
|
||||
|
||||
it "works with tar-gz-based Casks" do
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
cask "container-apfs-dmg" do
|
||||
version "1.2.3"
|
||||
sha256 "0630aa1145e8c3fa77aeb6ec414fee35204e90f224d6d06cb23e18a4d6112a5d"
|
||||
|
||||
url "file://#{TEST_FIXTURE_DIR}/cask/container-apfs.dmg"
|
||||
homepage "https://brew.sh/container-apfs-dmg"
|
||||
|
||||
app "container"
|
||||
end
|
||||
BIN
Library/Homebrew/test/support/fixtures/cask/container-apfs.dmg
Normal file
BIN
Library/Homebrew/test/support/fixtures/cask/container-apfs.dmg
Normal file
Binary file not shown.
@ -87,10 +87,31 @@ module UnpackStrategy
|
||||
return unless path.exist?
|
||||
|
||||
if tries > 1
|
||||
disk_info = system_command!(
|
||||
"diskutil",
|
||||
args: ["info", "-plist", path],
|
||||
print_stderr: false,
|
||||
verbose: verbose,
|
||||
)
|
||||
|
||||
# For HFS, just use <mount-path>
|
||||
# For APFS, find the <physical-store> corresponding to <mount-path>
|
||||
eject_paths = if disk_info.success?
|
||||
disk_info.plist
|
||||
.fetch("APFSPhysicalStores", [])
|
||||
.map { |store| store["APFSPhysicalStore"] }
|
||||
.compact
|
||||
.presence || [path]
|
||||
else
|
||||
[path]
|
||||
end
|
||||
|
||||
eject_paths.each do |eject_path|
|
||||
system_command! "diskutil",
|
||||
args: ["eject", path],
|
||||
args: ["eject", eject_path],
|
||||
print_stderr: false,
|
||||
verbose: verbose
|
||||
end
|
||||
else
|
||||
system_command! "diskutil",
|
||||
args: ["unmount", "force", path],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user