How to extract content of DMG without mounting it? I want add autoupdate system to my application. It downloads DMG from website, then extract new version of application from it.
-
Your question is directing you into the wrong direction... "autoupdate" is a mechanism inherently supported by MacOS Installer (framework, and service) - and you can rely on this (make your .pkg installer update the existing installed version) rather on manually merging the contents of a volume in a .dmg and your installation on the local drive. I recommend that you consider using official installer package for "autoupdates".– Motti ShneorMay 3 at 12:17
3 Answers
Some .dmg
files can be extracted by using 7-zip.
$ 7z x your.dmg
$ ls
your.dmg
0.MBR
1.Primary GPT Header
2.Primary GPT Table
3.free
4.hfs
5.free
6.Backup GPT Table
7.Backup GPT Header
...and after extracted the 4.hfs
file:
$ 7z x 4.hfs
...you'll get the content of the .dmg
file.
You could also mount the .dmg
in Mac OS X using hdiutil
command (which is also used by Homebrew Cask).
Please refer to this Ask Ubuntu question for more use cases on Linux.
-
-
3@BenLeggiero Not really, install p7zip on Linux/macOS which contains the
7z
command-line application. Sep 17, 2017 at 18:09 -
Extracting dmg files with 7z seem to miss the executable bits, making extracted applications from DMGs dysfunctional. May be related: sourceforge.net/p/p7zip/bugs/113– MotinSep 14, 2018 at 11:43
Dmg is just a format used for MacOS. It's a not compressed file format like zip
or tar.gz
You have several choices to mount it. Here are some options.
- Double click on it to mount it.
- Use
hdiutil attach your.dmg
to mount the dmg file. After mounting on it, operating your command line to extract the files you want out.
-
This is what I needed. Can one get the mounted path from the terminal output?– TailsJun 18, 2021 at 12:34
Doing that is working counter to the design of DMGs, so it's very painful. DMGs are designed to be mounted, that is their whole raison d'être. You would need to rely on experimental code if you wanted to do something like that. You are probably better served by using a non-DMG archive such as a zip file, or by making your automatic updating process download, mount, and unmount the DMG file you provide.
-
Project which you have linked is a portable solution. Mounting DMG images within OSX is easy as others answers proofed.– bluszczJan 24, 2018 at 14:08
-
Not only that - but if your .DMG is encrypted, I don't think even "Experimental code" would work for that. May 3 at 12:18