5

I'm trying to build dmg of .app file using following hdutil command:

hdiutil create  -srcfolder /Users/me/My.app My.dmg

It works as expected as it creates My.dmg correctly. Problem started happening when I add two more files in to .app bundle before calling that hdutil command. The hdutil ends up with error:

diskimages-helper: resize request is above maximum size allowed.
hdiutil: create failed - Invalid argument

Thanks for any help you can provide.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Nilay Anand
  • 330
  • 4
  • 17

3 Answers3

10

I had the same problem. The solution I found at Apple Support Communities worked for me. I ended up adding an empty .Trash file into the folder before calling hdiutil:

touch root_folder/.Trash

or with Ant in my case:

<touch file="root_folder/.Trash"/>
Michal
  • 1,262
  • 1
  • 12
  • 22
  • What do you mean by `root_folder`? Is it system root? – Nilay Anand Sep 26 '13 at 12:51
  • 1
    By `root_folder` I mean a directory, which is the root of your image (would be the `-srcfolder` you pass to `hdiutil`). Please note, that in your example you pass the `/Users/me/My.app` which IMO would lead to image which contains contents of `My.app`, not the `My.app` itself. You should probably pass `/Users/me` instead (of course, assuming there is nothing else than `My.app` there). – Michal Sep 26 '13 at 15:08
  • 2
    We recently moved one of our build systems from Snow Leopard to Mavericks and now we randomly see this problem with scripted builds. We never saw this on our previous build systems with thousands of builds. So far the work around of creating the .Trash file in the source seems to work. But I hate voodoo work arounds like this, so I reported it as a bug to Apple. I suggest that anyone else who runs into this also report it. – acronce Feb 23 '14 at 16:57
  • Is there a public link to the bug on Apple's site? – thisjustin Jun 16 '14 at 18:22
  • @ezrock No, you can report bugs to https://bugreport.apple.com/ but you can't see what others reported. – Michal Jun 16 '14 at 22:44
  • 1
    Odd. Tried it. It worked. My image is not large, but I was getting the "hdiutil: create failed - error -5341" error. – Rob Winchester Apr 21 '15 at 12:17
  • @RobWinchester I think there is some bug in the hdiutil, that it calculates required size first and then adds the .Trash. Depending on exact size of your data, you might be lucky and it fits into the rounded allocated size or not. – Michal Apr 21 '15 at 16:53
2

You can optionally specify a '-size' parameter when you invoke hdiutil. If you specify a size large enough that the disk image doesn't need to be resized during .dmg creation, it seems you can avoid this error.

E.g.:

hdiutil create -size 240m -fs HFS+ -srcfolder test -volname Test test.dmg
pagej97
  • 21
  • 3
-1

I make images of folders like this:

hdiutil makehybrid -hfs -o output/path.dmg -hfs-openfolder input/path input/path
JWWalker
  • 22,385
  • 6
  • 55
  • 76