Search code examples
macosdmg

How can I validate a DMG file?


I have an application that builds into a DMG file (via jpackage). As soon as users download the DMG they tell me it is corrupt and should be deleted.

Now I am unfamiliar with that format and I have no access to any Apple Mac to try myself. Just in case jpackage is really building an invalid package I would like to check that before offering such a download.

Is there any way to validate a DMG on Github's MacOS runner?


Solution

  • I found this web page https://macwrench.miraheze.org/wiki/Hdiutil which mentions that hdiutil supports a number of commands that are useful for validating a DMG file:

    hdiutil verify -verbose <dmg>
    hdiutil imageinfo -verbose <dmg>
    hdiutil hfsanalyze -verbose <dmg>
    hdiutil checksum -type SHA256 -verbose <dmg>
    hdiutil info -verbose
    hdiutil pmap -verbose <dmg>
    

    The first one already gave me output that ended like this:

    hdiutil: verify: checksum of "<dmg>" is VALID
    verified   CRC32 $9D7EB279
    

    So with this I can trust my generated file and should look for issues on the download or user side.