Create DMG containing the rootDir.
()
| 1599 | |
| 1600 | |
| 1601 | def buildDMG(): |
| 1602 | """ |
| 1603 | Create DMG containing the rootDir. |
| 1604 | """ |
| 1605 | outdir = os.path.join(WORKDIR, 'diskimage') |
| 1606 | if os.path.exists(outdir): |
| 1607 | shutil.rmtree(outdir) |
| 1608 | |
| 1609 | # We used to use the deployment target as the last characters of the |
| 1610 | # installer file name. With the introduction of weaklinked installer |
| 1611 | # variants, we may have two variants with the same file name, i.e. |
| 1612 | # both ending in '10.9'. To avoid this, we now use the major/minor |
| 1613 | # version numbers of the macOS version we are building on. |
| 1614 | # Also, as of macOS 11, operating system version numbering has |
| 1615 | # changed from three components to two, i.e. |
| 1616 | # 10.14.1, 10.14.2, ... |
| 1617 | # 10.15.1, 10.15.2, ... |
| 1618 | # 11.1, 11.2, ... |
| 1619 | # 12.1, 12.2, ... |
| 1620 | # (A further twist is that, when running on macOS 11, binaries built |
| 1621 | # on older systems may be shown an operating system version of 10.16 |
| 1622 | # instead of 11. We should not run into that situation here.) |
| 1623 | # Also we should use "macos" instead of "macosx" going forward. |
| 1624 | # |
| 1625 | # To maintain compatibility for legacy variants, the file name for |
| 1626 | # builds on macOS 10.15 and earlier remains: |
| 1627 | # python-3.x.y-macosx10.z.{dmg->pkg} |
| 1628 | # e.g. python-3.9.4-macosx10.9.{dmg->pkg} |
| 1629 | # and for builds on macOS 11+: |
| 1630 | # python-3.x.y-macosz.{dmg->pkg} |
| 1631 | # e.g. python-3.9.4-macos11.{dmg->pkg} |
| 1632 | |
| 1633 | build_tuple = getBuildTuple() |
| 1634 | if build_tuple[0] < 11: |
| 1635 | os_name = 'macosx' |
| 1636 | build_system_version = '%s.%s' % build_tuple |
| 1637 | else: |
| 1638 | os_name = 'macos' |
| 1639 | build_system_version = str(build_tuple[0]) |
| 1640 | imagepath = os.path.join(outdir, |
| 1641 | 'python-%s-%s%s'%(getFullVersion(),os_name,build_system_version)) |
| 1642 | if INCLUDE_TIMESTAMP: |
| 1643 | imagepath = imagepath + '-%04d-%02d-%02d'%(time.localtime()[:3]) |
| 1644 | imagepath = imagepath + '.dmg' |
| 1645 | |
| 1646 | os.mkdir(outdir) |
| 1647 | |
| 1648 | # Try to mitigate race condition in certain versions of macOS, e.g. 10.9, |
| 1649 | # when hdiutil create fails with "Resource busy". For now, just retry |
| 1650 | # the create a few times and hope that it eventually works. |
| 1651 | |
| 1652 | volname='Python %s'%(getFullVersion()) |
| 1653 | cmd = ("hdiutil create -format UDRW -volname %s -srcfolder %s -size 100m %s"%( |
| 1654 | shellQuote(volname), |
| 1655 | shellQuote(os.path.join(WORKDIR, 'installer')), |
| 1656 | shellQuote(imagepath + ".tmp.dmg" ))) |
| 1657 | for i in range(5): |
| 1658 | fd = os.popen(cmd, 'r') |
no test coverage detected
searching dependent graphs…