def buildDMG(self):
# Remove DMG if it already exists
if os.path.exists(self.dmgName):
os.unlink(self.dmgName)
createargs = [
'hdiutil', 'create', '-fs', 'HFSX', '-format', 'UDZO',
self.dmgName, '-imagekey', 'zlib-level=9', '-srcfolder',
self.bundleDir, '-volname', self.volume_label
]
if self.applications_shortcut:
scriptargs = [
'osascript', '-e', 'tell application "Finder" to make alias \
file to POSIX file "/Applications" at POSIX file "%s"' %
os.path.realpath(self.buildDir)
]
if os.spawnvp(os.P_WAIT, 'osascript', scriptargs) != 0:
raise OSError('creation of Applications shortcut failed')
createargs.append('-srcfolder')
createargs.append(self.buildDir + '/Applications')
# Create the dmg
if os.spawnvp(os.P_WAIT, 'hdiutil', createargs) != 0:
raise OSError('creation of the dmg failed')
评论列表
文章目录