[Python-checkins] macOS installer build: mitigate hdiutil resource busy bug (GH-11333)

Miss Islington (bot) webhook-mailer at python.org
Thu Dec 27 16:38:46 EST 2018


https://github.com/python/cpython/commit/0133f9fc9e8a35b223341d7b5641ac2f16ff2a19
commit: 0133f9fc9e8a35b223341d7b5641ac2f16ff2a19
branch: master
author: Ned Deily <nad at python.org>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2018-12-27T13:38:41-08:00
summary:

macOS installer build: mitigate hdiutil resource busy bug (GH-11333)

files:
M Mac/BuildScript/build-installer.py

diff --git a/Mac/BuildScript/build-installer.py b/Mac/BuildScript/build-installer.py
index d55020883928..2e3a61ec71d1 100755
--- a/Mac/BuildScript/build-installer.py
+++ b/Mac/BuildScript/build-installer.py
@@ -1518,16 +1518,27 @@ def buildDMG():
     imagepath = imagepath + '.dmg'
 
     os.mkdir(outdir)
+
+    # Try to mitigate race condition in certain versions of macOS, e.g. 10.9,
+    # when hdiutil create fails with  "Resource busy".  For now, just retry
+    # the create a few times and hope that it eventually works.
+
     volname='Python %s'%(getFullVersion())
-    runCommand("hdiutil create -format UDRW -volname %s -srcfolder %s %s"%(
+    cmd = ("hdiutil create -format UDRW -volname %s -srcfolder %s -size 100m %s"%(
             shellQuote(volname),
             shellQuote(os.path.join(WORKDIR, 'installer')),
             shellQuote(imagepath + ".tmp.dmg" )))
-
-    # Try to mitigate race condition in certain versions of macOS, e.g. 10.9,
-    # when hdiutil fails with  "Resource busy"
-
-    time.sleep(10)
+    for i in range(5):
+        fd = os.popen(cmd, 'r')
+        data = fd.read()
+        xit = fd.close()
+        if not xit:
+            break
+        sys.stdout.write(data)
+        print(" -- retrying hdiutil create")
+        time.sleep(5)
+    else:
+        raise RuntimeError("command failed: %s"%(commandline,))
 
     if not os.path.exists(os.path.join(WORKDIR, "mnt")):
         os.mkdir(os.path.join(WORKDIR, "mnt"))



More information about the Python-checkins mailing list