]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
macOS installer build: mitigate hdiutil resource busy bug
authorNed Deily <nad@python.org>
Tue, 11 Dec 2018 03:05:14 +0000 (22:05 -0500)
committerNed Deily <nad@python.org>
Tue, 11 Dec 2018 20:56:50 +0000 (15:56 -0500)
Mac/BuildScript/build-installer.py

index b1dede492058b630fee849fad54e37197d81c367..6fc07ad3d3d1b160aa5225c165f37250a1fe0101 100755 (executable)
@@ -1533,16 +1533,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"))