Merge pull request #10958 from cho-m/cask-eject-apfs-dmg
cask install: fix APFS DMG eject to use physical disk
This commit is contained in:
commit
051d4378b1
@ -16,7 +16,7 @@ describe Cask::Installer, :cask do
|
||||
expect(caffeine.config.appdir.join("Caffeine.app")).to be_a_directory
|
||||
end
|
||||
|
||||
it "works with dmg-based Casks" do
|
||||
it "works with HFS+ dmg-based Casks" do
|
||||
asset = Cask::CaskLoader.load(cask_path("container-dmg"))
|
||||
|
||||
described_class.new(asset).install
|
||||
@ -25,6 +25,24 @@ describe Cask::Installer, :cask do
|
||||
expect(asset.config.appdir.join("container")).to be_a_file
|
||||
end
|
||||
|
||||
it "works with APFS dmg-based Casks" do
|
||||
asset = Cask::CaskLoader.load(cask_path("container-apfs-dmg"))
|
||||
diskutil_list_command = "diskutil list | grep '/dev'"
|
||||
|
||||
sleep 5
|
||||
original_diskutil_list = `#{diskutil_list_command}`
|
||||
|
||||
described_class.new(asset).install
|
||||
|
||||
expect(Cask::Caskroom.path.join("container-apfs-dmg", asset.version)).to be_a_directory
|
||||
expect(asset.config.appdir.join("container")).to be_a_file
|
||||
|
||||
sleep 5
|
||||
expect { system diskutil_list_command }
|
||||
.to output(original_diskutil_list)
|
||||
.to_stdout_from_any_process
|
||||
end
|
||||
|
||||
it "works with tar-gz-based Casks" do
|
||||
asset = Cask::CaskLoader.load(cask_path("container-tar-gz"))
|
||||
|
||||
|
||||
@ -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,27 @@ module UnpackStrategy
|
||||
return unless path.exist?
|
||||
|
||||
if tries > 1
|
||||
system_command! "diskutil",
|
||||
args: ["eject", path],
|
||||
print_stderr: false,
|
||||
verbose: verbose
|
||||
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 = disk_info.plist
|
||||
.fetch("APFSPhysicalStores", [])
|
||||
.map { |store| store["APFSPhysicalStore"] }
|
||||
.compact
|
||||
.presence || [path]
|
||||
|
||||
eject_paths.each do |eject_path|
|
||||
system_command! "diskutil",
|
||||
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