3

我已经使用 PackageMaker 创建了一个包,并且想要更改 .pkg 文件的默认图标。经过一番谷歌搜索后,这里http://sveinbjorn.org/osxutils_docs的 seticon 实用程序解决了我对所有 OSX-es 的问题,除了最新的 Lion 10.7(内核 11.0.0)。默认图标被替换为对双击不敏感的灰色方形,看起来像文件关联损坏。

另外两天的谷歌搜索让我了解了资源分叉、SetFile(1) 和其他一些有用的工作人员,比如这个旧线程更改包制造商创建的包的图标,但仍然没有运气。

我正在尝试做类似的事情:

目标=pack.pkg

icon_filename="$(perl -e 'print "Icon\r"')"

触摸“$target/..namedfork/rsrc/$icon_filename”

cp "Icon.icns" "$target/..namedfork/rsrc/$icon_filename"

/开发者/工具/SetFile -a C "$target"

并得到: build-Mac:pack.pkg/..namedfork/ 不是目录。

我究竟做错了什么?有人能告诉我 Lion 中资源分叉的区别吗?还有其他可编写脚本的解决方案吗?

请注意,我是 MAC 的新手,我会感谢傻瓜的详细答案。

4

1 回答 1

2

终于想通了,万一有人需要,放在这里。我使用了苹果脚本:

set newIcon to (POSIX file "IconMac.icns") as alias
set theItem to (POSIX file "Installer.pkg") as alias

tell application "Preview"
activate
open newIcon
end tell
tell application "System Events"
tell process "Preview"
    keystroke "c" using command down
end tell
end tell
tell application "Preview" to quit

tell application "Finder"
set infoWindow to open information window of theItem
set infoWindowName to name of infoWindow
end tell

tell application "System Events"
tell application process "Finder"
    tell window infoWindowName
        keystroke tab
        delay 1
        keystroke "v" using command down
    end tell
end tell
end tell

tell application "Finder"
close infoWindow
end tell
于 2012-01-24T09:34:01.583 回答