Skip to content

Commit befe3f7

Browse files
committed
macOS installer build: mitigate hdiutil resource busy bug
1 parent c540c4e commit befe3f7

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

Mac/BuildScript/build-installer.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -1533,16 +1533,27 @@ def buildDMG():
15331533
imagepath = imagepath + '.dmg'
15341534

15351535
os.mkdir(outdir)
1536+
1537+
# Try to mitigate race condition in certain versions of macOS, e.g. 10.9,
1538+
# when hdiutil create fails with "Resource busy". For now, just retry
1539+
# the create a few times and hope that it eventually works.
1540+
15361541
volname='Python %s'%(getFullVersion())
1537-
runCommand("hdiutil create -format UDRW -volname %s -srcfolder %s %s"%(
1542+
cmd = ("hdiutil create -format UDRW -volname %s -srcfolder %s -size 100m %s"%(
15381543
shellQuote(volname),
15391544
shellQuote(os.path.join(WORKDIR, 'installer')),
15401545
shellQuote(imagepath + ".tmp.dmg" )))
1541-
1542-
# Try to mitigate race condition in certain versions of macOS, e.g. 10.9,
1543-
# when hdiutil fails with "Resource busy"
1544-
1545-
time.sleep(10)
1546+
for i in range(5):
1547+
fd = os.popen(cmd, 'r')
1548+
data = fd.read()
1549+
xit = fd.close()
1550+
if not xit:
1551+
break
1552+
sys.stdout.write(data)
1553+
print(" -- retrying hdiutil create")
1554+
time.sleep(5)
1555+
else:
1556+
raise RuntimeError("command failed: %s"%(commandline,))
15461557

15471558
if not os.path.exists(os.path.join(WORKDIR, "mnt")):
15481559
os.mkdir(os.path.join(WORKDIR, "mnt"))

0 commit comments

Comments
 (0)