]> granicus.if.org Git - python/commitdiff
macOS installer build: mitigate hdiutil resource busy bug (GH-11333)
authorNed Deily <nad@python.org>
Thu, 27 Dec 2018 21:38:41 +0000 (16:38 -0500)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 27 Dec 2018 21:38:41 +0000 (13:38 -0800)
Mac/BuildScript/build-installer.py

index d550208839280e4bb0be0661bd88eb78155a2ac6..2e3a61ec71d1838182204c3d2e8e62447a588aa7 100755 (executable)
@@ -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"))