Skip to content

unpack_strategy/dmg: use diskutil image on macOS 14+ - #23414

Merged
p-linnane merged 2 commits into
mainfrom
dmg-diskutil-image
Aug 4, 2026
Merged

unpack_strategy/dmg: use diskutil image on macOS 14+#23414
p-linnane merged 2 commits into
mainfrom
dmg-diskutil-image

Conversation

@p-linnane

@p-linnane p-linnane commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

hdiutil is deprecated on macOS 27 and prints a deprecation warning on every attach, imageinfo, and convert call, each one pointing at diskutil image as the replacement (also reported in #23401). diskutil image attach was added in macOS 13, while image creation was added in macOS 14. Because SLA conversion requires diskutil image create from, this moves the DMG unpack strategy to diskutil image on macOS 14 and newer and retains the existing hdiutil path for older releases.

On macOS 14 and newer we detect images with diskutil image info --plist, attach read-only with nobrowse into an isolated temporary mount point, fall back to a plain attach when an image has multiple mountable volumes (--mountPoint only supports a single mountable entity), and convert SLA-bearing images with diskutil image create from. Both tools emit the same system-entities/mount-point plist structure, so mount handling and ejection are unchanged.

One detection difference is worth calling out. diskutil image info exits nonzero after printing the license agreement for an SLA-bearing image. When that occurs, detection confirms the file has a valid koly UDIF trailer directly. This avoids treating arbitrary failure output as a disk image without falling back to deprecated hdiutil on the new path.

Validated end-to-end on macOS 27 beta build 26A5388g, including SLA-bearing, multi-volume, and combined SLA/multi-volume images. The macOS 14 floor is based on the capability history documented by diskutil(8); macOS 14 through 26 have not been exercised directly. diskutil image create from --format UDRO preserves embedded SLAs, while RAW strips them like the legacy UDTO conversion. This is observed prerelease behavior and should be rechecked before macOS 27 GA.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Claude Code (Opus 5) drafted the implementation and tests; I reviewed the diff, verified the new tests fail without the fix and pass with it, exercised real SLA-bearing and multi-volume disk images end-to-end on macOS 27, and ran brew lgtm + targeted specs.


Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Homebrew鈥檚 DMG unpack strategy to avoid hdiutil deprecation warnings on macOS 27+ by switching to diskutil image for image detection, attachment, and SLA-handling conversion while retaining the existing hdiutil behavior on older macOS versions.

Changes:

  • Add an OS-gated diskutil image code path for .can_extract? and DMG mounting/attachment on macOS 27+.
  • Introduce helpers to attach images with an isolated mount point and to convert SLA-bearing images for mounting.
  • Add macOS 27-specific unit tests and OS extension hooks to enable the new behavior only on macOS.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Library/Homebrew/unpack_strategy/dmg.rb Switch DMG detection/attach/convert to diskutil image on macOS 27+ and factor out helpers.
Library/Homebrew/test/unpack_strategy/dmg_spec.rb Add specs covering diskutil vs hdiutil selection, isolated mount point, fallback attach, and SLA conversion.
Library/Homebrew/extend/os/unpack_strategy/dmg.rb Add OS-specific loader for DMG unpack strategy extensions on macOS.
Library/Homebrew/extend/os/mac/unpack_strategy/dmg.rb Define the macOS 27+ predicate (diskutil_image?) used to switch implementations.

馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/unpack_strategy/dmg.rb
@p-linnane
p-linnane force-pushed the dmg-diskutil-image branch from fad6773 to 73b395b Compare August 3, 2026 18:39

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! If possible let's see what other macOS versions this works on?

Comment thread Library/Homebrew/extend/os/mac/unpack_strategy/dmg.rb Outdated
@p-linnane
p-linnane force-pushed the dmg-diskutil-image branch from 73b395b to 820dc84 Compare August 3, 2026 18:50
@p-linnane p-linnane changed the title unpack_strategy/dmg: use diskutil image on macOS 27 unpack_strategy/dmg: use diskutil image on macOS 14+ Aug 3, 2026
@p-linnane
p-linnane force-pushed the dmg-diskutil-image branch from 820dc84 to 8ef1bf7 Compare August 3, 2026 19:17
Signed-off-by: Patrick Linnane <patrick@linnane.io>
@p-linnane
p-linnane force-pushed the dmg-diskutil-image branch from 8ef1bf7 to 7aaf445 Compare August 3, 2026 20:02
@p-linnane
p-linnane requested a review from MikeMcQuaid August 3, 2026 20:03

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, sorry, few more nits.

Comment thread Library/Homebrew/unpack_strategy/dmg.rb Outdated
Comment thread Library/Homebrew/unpack_strategy/dmg.rb Outdated
Signed-off-by: Patrick Linnane <patrick@linnane.io>

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@p-linnane
p-linnane enabled auto-merge August 4, 2026 15:40
@p-linnane
p-linnane added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit 83ae06d Aug 4, 2026
64 of 65 checks passed
@p-linnane
p-linnane deleted the dmg-diskutil-image branch August 4, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants