Reputation: 6116
I need to update a .dmg
(a.k.a. Apple disk image) file by adding a folder to it (it's an OSGI application and I want to add a few more bundles) but I would prefer a platform independent solution. My main code is written in Python but I am also comfortable with Java. Is it possible to to edit a .dmg
file like so?
Note that I don't necessarily need to created a /dmg
file cause I have one but if the best way is to unpack and then re-pack that works too.
Upvotes: 2
Views: 353
Reputation: 2025
Creating .dmg images elsewhere than on a Mac is not as easy task at least not an easy task to do using free software. And with non-free, it is mostly for-Mac software. I have been there and decided this was a waste of time.
If you are on a mac, using hdiutil
is the way to manipulate .dmg
There is a Python wrapper for instance here https://bitbucket.org/al45tair/dmgbuild to give you some ideas.
In most cases you cannot "edit" a .dmg directly, as these are fixed size images AFAICR. You can however resize one:
hdiutil resize -size 70m
Then you can mount it and copy you files to it.
If this is a one time operation, you are better off doing it by hand than automating IMHO.
Now there are a few tools that can possibly build on Linux, but I did not evaluate them AND the key issues when not using hdiutils is to create a .dmg that will always be readable on a Mac...
You could try:
-hfsplus-tools
: https://apps.fedoraproject.org/packages/hfsplus-tools
-libdmg-hfsplus
: https://github.com/planetbeing/libdmg-hfsplus and in Debian too.
-hfsutils
: available in Linux distros
See also http://www.nathancoulson.com/proj_cross_tools.php for a list of these and this SO question too: How to build a dmg Mac OS X file (on a non-Mac platform)?
Again, YMMV but I was never able to get 100% reliable .dmg created outside of a Mac.
Upvotes: 1