Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0133f9f

Browse files
ned-deilymiss-islington
authored andcommitted
macOS installer build: mitigate hdiutil resource busy bug (GH-11333)
1 parent a936639 commit 0133f9f

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

Mac/BuildScript/build-installer.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,16 +1518,27 @@ def buildDMG():
15181518
imagepath = imagepath + '.dmg'
15191519

15201520
os.mkdir(outdir)
1521+
1522+
# Try to mitigate race condition in certain versions of macOS, e.g. 10.9,
1523+
# when hdiutil create fails with "Resource busy". For now, just retry
1524+
# the create a few times and hope that it eventually works.
1525+
15211526
volname='Python %s'%(getFullVersion())
1522-
runCommand("hdiutil create -format UDRW -volname %s -srcfolder %s %s"%(
1527+
cmd = ("hdiutil create -format UDRW -volname %s -srcfolder %s -size 100m %s"%(
15231528
shellQuote(volname),
15241529
shellQuote(os.path.join(WORKDIR, 'installer')),
15251530
shellQuote(imagepath + ".tmp.dmg" )))
1526-
1527-
# Try to mitigate race condition in certain versions of macOS, e.g. 10.9,
1528-
# when hdiutil fails with "Resource busy"
1529-
1530-
time.sleep(10)
1531+
for i in range(5):
1532+
fd = os.popen(cmd, 'r')
1533+
data = fd.read()
1534+
xit = fd.close()
1535+
if not xit:
1536+
break
1537+
sys.stdout.write(data)
1538+
print(" -- retrying hdiutil create")
1539+
time.sleep(5)
1540+
else:
1541+
raise RuntimeError("command failed: %s"%(commandline,))
15311542

15321543
if not os.path.exists(os.path.join(WORKDIR, "mnt")):
15331544
os.mkdir(os.path.join(WORKDIR, "mnt"))

0 commit comments

Comments
 (0)