600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 使用命令行工具 如何创建nicelooking DMG的Mac OS X?

使用命令行工具 如何创建nicelooking DMG的Mac OS X?

时间:2022-03-08 15:13:26

相关推荐

使用命令行工具 如何创建nicelooking DMG的Mac OS X?

使用命令行工具,如何创建nicelooking DMG的Mac OS X?

经过大量的研究,我得到了这个答案,我将它作为我自己问题的答案,供参考:

确保"启用辅助设备访问"在系统首选项>> 通用访问中被选中。 为AppleScript工作需要它。 在这里更改( 它在 Mac OS X 服务器 10.4上不起作用) 之后你可能必须重新启动。

创建一个 R/w DMG 。它必须大于结果。 在本例中,bash变量"大小"包含了Kb的大小,"源"bash变量中的文件夹内容将被复制到 DMG:

hdiutil create -srcfolder"${source}" -volname"${title}" -fs HFS+ -fsargs"-c c=64,a=16,e=16" -format UDRW -size ${size}k pack.temp.dmg

挂载磁盘映像,并存储设备名称( 你可能希望在这里操作之后几秒钟内使用睡眠):

device=$(hdiutil attach -readwrite -noverify -noautoopen"pack.temp.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}')

将背景图片( 以PNG格式格式) 存储在DMG中名为"。背景"的文件夹中,并将它的名称存储在"backgroundpicturename"变量中。

使用AppleScript设置视觉样式(. app的名称必须在bash变量中"applicationname"根据需要对其他属性使用变量):

echo 'tell application"Finder"tell disk"'${title}'"openset current view of container window to icon viewset toolbar visible of container window to falseset statusbar visible of container window to falseset the bounds of container window to {400, 100, 885, 430}set theViewOptions to the icon view options of container windowset arrangement of theViewOptions to not arrangedset icon size of theViewOptions to 72set background picture of theViewOptions to file".background:'${backgroundPictureName}'"make new alias file at container window to POSIX file"/Applications" with properties {name:"Applications"}set position of item"'${applicationName}'" of container window to {100, 100}set position of item"Applications" of container window to {375, 100}update without registering applicationsdelay 5closeend tellend tell' | osascript

通过正确设置权限,压缩并释放该DMG来完成该操作:

chmod -Rf go-w/Volumes/"${title}"syncsynchdiutil detach ${device}hdiutil convert"/pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o"${finalDMGName}"rm -f/pack.temp.dmg

在 Snow Leopard 上,上面的applescript不会正确设置 icon 位置- 它似乎是一个雪花 Leopard Bug 。 一个解决办法是在设置图标后调用 close/打开,i.e.:

..set position of item"'${applicationName}'" of container window to {100, 100}set position of item"Applications" of container window to {375, 100}closeopen

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。