Portfile for a DMG that displays license before mounting

Ryan Schmidt ryandesign at macports.org
Sat Jun 1 12:59:39 UTC 2019

On Jun 1, 2019, at 05:22, Andrew Udvare wrote:

> Anyone dealt with this before?
> If you use hdiutil with all the flags that MacPorts does with use_dmg, prior to mounting  hdiutil prompts you to agree to its license. There doesn't appear to be an official way to skip this.
> A utility known as FastDMG bypasses this by echoing Y repeatedly to get past this. I am considering implementing this in the Portfile as difficult as that may be.
> If there is a better way that isn't so hacky I am interested.

Yes, I've done this before. Echoing Y to hdiutil wasn't working for me so I wrote an expect script to do it.

Here is the expect script:


You may need to modify the strings "Software License" and "Agree Y/N?" depending on the exact wording of your disk image's license.

Here are the Tcl procedures to mount a disk image using that expect script and to unmount it:


(Change "my_system" to "system" though.)

Don't forget to add a dependency on bin:expect:expect for whatever phase you're doing this in (e.g. depends_extract-append).

You want to mount the disk image using these procedures instead of MacPorts base code, so set extract.only to a value that excludes the disk image (i.e. list all the other distfiles; if there are no other distfiles, set extract.only to a blank value), then call the procedures in the post-extract block (or whatever phase you want).

P.S: Please write to our list addresses at lists.macports.org. The older hostname you used redirects mail to the new one, but some users cannot read those redirects due to security concerns implemented by their email providers.

More information about the macports-users mailing list