Skip to content

feat: add size option to DmgOptions for explicit DMG filesystem size#9543

Merged
mmaietta merged 6 commits into
electron-userland:masterfrom
BarakXYZ:fix/dmg-size-option
Jan 28, 2026
Merged

feat: add size option to DmgOptions for explicit DMG filesystem size#9543
mmaietta merged 6 commits into
electron-userland:masterfrom
BarakXYZ:fix/dmg-size-option

Conversation

@BarakXYZ
Copy link
Copy Markdown
Contributor

@BarakXYZ BarakXYZ commented Jan 27, 2026

Summary

Add size option to DmgOptions to allow specifying the DMG filesystem size explicitly. This fixes "No space left on device" errors when building DMGs for large applications (>2GB) or applications with sparse files.

The size option accepts the same syntax as hdiutil's -size argument (e.g., "150m", "4g"). If not specified, the size is calculated automatically (existing behavior).

Changes

  • Added size property to DmgOptions interface in macOptions.ts
  • Added size to JSON schema validation in scheme.json
  • Added size to DmgBuildConfig interface in dmg.ts
  • Pass size through to dmgbuild settings in dmgUtil.ts
  • Added test for the new option

Usage

dmg: {
  size: "4g", // Explicit 4GB filesystem size
}

Dependency

This PR requires a corresponding change in dmgbuild to read the size option from JSON configuration files:

Once the dmgbuild PR is merged and electron-builder-binaries updates its bundled dmgbuild, this feature will be fully functional.

Fixes #8223

Add `size` option to DmgOptions to allow specifying the DMG filesystem
size explicitly. This fixes "No space left on device" errors when
building DMGs for large applications or applications with sparse files.

The size option accepts the same syntax as hdiutil's `-size` argument
(e.g., "150m", "4g"). If not specified, the size is calculated
automatically (existing behavior).

Fixes #8223
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: bbe61d3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
app-builder-lib Major
dmg-builder Major
electron-builder-squirrel-windows Major
electron-builder Major
electron-forge-maker-appimage Major
electron-forge-maker-nsis-web Major
electron-forge-maker-nsis Major
electron-forge-maker-snap Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread test/src/mac/dmgTest.ts Outdated
@mmaietta
Copy link
Copy Markdown
Collaborator

Thanks for opening a PR! Can you please also run pnpm generate-changeset so this is picked up by the CD pipeline?

- Add `shrink` option (defaults to true) to control filesystem shrinking
- Test uses `shrink: false` to verify filesystem size retention

Depends on: dmgbuild/dmgbuild#280
@BarakXYZ
Copy link
Copy Markdown
Contributor Author

Thanks for the review! I've made the following updates:

1. Added changeset as requested.

2. Added shrink option and enhanced the test

To properly verify that the explicit filesystem size is retained in the final DMG, I needed to add a shrink option. Here's why:

By default, dmgbuild runs hdiutil resize -sectors min after populating the image, which shrinks the filesystem to the minimum size regardless of what size was specified. The size option still works correctly in this case - it ensures enough space during the build phase - but the final filesystem ends up at minimum size.

To test that the filesystem actually retains a specific size (e.g., 500MB), we need to disable this shrinking behavior. So I created a follow-up PR to dmgbuild:

The shrink option (defaults to true) is independent and additive - users can use size alone, shrink alone, or both together depending on their needs.

The test now uses size: "500m" with shrink: false and verifies the mounted filesystem is in the expected range (450-600MB).

Let me know if you'd like any adjustments!

@mmaietta
Copy link
Copy Markdown
Collaborator

Nicely done! I really like this.

Next steps is to open a PR to pull in latest dmgbuild into our portable/closed-loop toolsets is to update the commit hash here to latest
https://github.com/electron-userland/electron-builder-binaries/blob/5fde804b8911fb43e8a9b41fcc668125c25cd6ec/packages/dmg-builder/build.sh#L8
After that PR is merged + deployed, we can simply bump the toolset versions in

"dmgbuild-bundle-arm64-9614277.tar.gz": "28e11550cf990f78180a2d82090f35a24588beda3d9165098837714f90ee47ce",
"dmgbuild-bundle-x86_64-9614277.tar.gz": "4dbf1cc186af62921f8b6f4a5956b28d8622d211797a8b05eb75a260ee9c3fdb",

It's a few-but-simple hoops to jump through ever since I recently got that build pipeline set up. :D

Comment thread packages/app-builder-lib/src/options/macOptions.ts Outdated
@BarakXYZ
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! Updated the size description to clarify it refers to the initial filesystem size.

Also created the PR to update dmgbuild in electron-builder-binaries:

Once that's merged and deployed with new binaries, I'll bump the releaseVersion and checksums in dmgUtil.ts.

@mmaietta
Copy link
Copy Markdown
Collaborator

Boomshakalaka
dmg-builder@1.2.0
digest256 are the hashes you want to use

@BarakXYZ
Copy link
Copy Markdown
Contributor Author

pewpewpew! Bumped to dmg-builder@1.2.0 with the new checksums. Thank you!!

@mmaietta mmaietta merged commit bfee115 into electron-userland:master Jan 28, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No space left on device (sparse files)

2 participants