lib/omnibus/compressors/dmg.rb
def compress_dmg
      log.info(log_key) { "Compressing dmg" }

      Dir.chdir(staging_dir) do
        shellout! <<-EOH.gsub(/^ {10}/, "")
          chmod -Rf go-w "/Volumes/#{volume_name}"
          sync
          hdiutil detach "#{@device}"
          hdiutil convert \\
            "#{writable_dmg}" \\
            -format UDZO \\
            -imagekey \\
            zlib-level=9 \\
            -o "#{package_path}"
          rm -rf "#{writable_dmg}"
        EOH
      end
    end
def compress_dmg
      log.info(log_key) { "Compressing dmg" }

      Dir.chdir(staging_dir) do
        shellout! <<-EOH.gsub(/^ {10}/, "")
          chmod -Rf go-w "/Volumes/#{volume_name}"
          sync
          hdiutil detach "#{@device}"
          hdiutil convert \\
            "#{writable_dmg}" \\
            -format UDZO \\
            -imagekey \\
            zlib-level=9 \\
            -o "#{package_path}"
          rm -rf "#{writable_dmg}"
        EOH
      end
    end
Compress the dmg using hdiutil and zlib. zlib offers better compression
 levels than bzip2 (10.4+) or LZFSE (10.11+), but takes longer to compress.
 We're willing to trade slightly longer build times for smaller package sizes.

 @return [void]