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

This commit is contained in:
Ned Deily 2018-12-27 16:38:41 -05:00 committed by Miss Islington (bot)
parent a936639b22
commit 0133f9fc9e
1 changed files with 17 additions and 6 deletions

View File

@ -1518,16 +1518,27 @@ def buildDMG():
imagepath = imagepath + '.dmg' imagepath = imagepath + '.dmg'
os.mkdir(outdir) 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()) 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(volname),
shellQuote(os.path.join(WORKDIR, 'installer')), shellQuote(os.path.join(WORKDIR, 'installer')),
shellQuote(imagepath + ".tmp.dmg" ))) shellQuote(imagepath + ".tmp.dmg" )))
for i in range(5):
# Try to mitigate race condition in certain versions of macOS, e.g. 10.9, fd = os.popen(cmd, 'r')
# when hdiutil fails with "Resource busy" data = fd.read()
xit = fd.close()
time.sleep(10) 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")): if not os.path.exists(os.path.join(WORKDIR, "mnt")):
os.mkdir(os.path.join(WORKDIR, "mnt")) os.mkdir(os.path.join(WORKDIR, "mnt"))