# Headless disk image layout `Scripts/dmg.sh` builds this small Swift executable with the macOS SDK. It writes Finder layout metadata without launching Finder or sending Apple events. ```sh source Scripts/product.env swift run --package-path Packaging/DMGLayout dmg-layout write /path/to/mounted-volume swift run --package-path Packaging/DMGLayout dmg-layout verify /path/to/mounted-volume swift run --package-path Packaging/DMGLayout dmg-layout verify-open-folder /path/to/mounted-volume swift test --package-path Packaging/DMGLayout Scripts/tests/release.sh ``` `write` requires `${PRODUCT_NAME}.app`, an `/Applications` symlink, and `.background/background.tiff` on the mounted image. `PRODUCT_NAME` must be exported from `Scripts/product.env`; a missing or invalid name is an error. The TIFF must contain 640×440 and 1280×880 representations, both 640×440 points (72 and 144 dpi). These are independently drawn by `dmg-background` and combined by `tiffutil -cathidpicheck` during packaging. The writer refuses to replace an existing `.DS_Store`. `verify` reads the allocator, layout records, and background alias back, and rechecks the TIFF; errors go to stderr with a nonzero exit. `verify-open-folder` independently reads the mounted HFS+ volume's Finder info and checks that the automatic open-folder ID points to the volume root. Packaging runs this check on both the writable and final read-only image. The layout uses a 640×440 window with 96-point icons at (160, 210) and (480, 210). The `icvp` picture settings include all three background-color fields: Finder discards the whole dictionary without them, hiding both the artwork and the icon settings. The `icvl` record selects icon view. Validate visual changes in Finder on the final compressed image as well as running the metadata checks. The writer supports one fixed-size leaf in the documented [store format](https://fastapi.metacpan.org/v1/source/WIML/Mac-Finder-DSStore-1.00/DSStoreFormat.pod), not arbitrary Finder databases. Oversized layouts fail rather than producing an incomplete tree. Finder requires a legacy Alias record for the background, not bookmark data. `BackgroundAlias.swift` resolves the public, deprecated `FSNewAliasFromPath` function at runtime and verifies its native record. Missing symbols and failed resolution are hard errors. No third-party code is used. Create the alias on the mounted HFS+ image, never in staging. Packaging remounts the compressed image read-only at another path and verifies it again, so an alias bound to the temporary mount cannot pass.