Question

I have created a package using PackageMaker and want to change the default icon for .pkg file. After some googling, seticon utility from here http://sveinbjorn.org/osxutils_docs solved my problem for all OSX-es except the latest Lion 10.7 (Kernel 11.0.0). The default icon was replaced by grey square insensitive for double clicks, looks like broken file association.

Additional two days googling gave me some knowledge about resource fork, SetFile(1) and some other useful staff like this old thread Changing icon of package created by package maker but still no luck.

I am trying to do something like:

target=pack.pkg

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

touch "$target/..namedfork/rsrc/$icon_filename"

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

/Developer/Tools/SetFile -a C "$target"

and getting: build-Mac:pack.pkg/..namedfork/ not a directory.

What am I doing wrong? Does anyone can tell me the difference in resource fork in Lion? Any other script-able solution?

Please note, I am a total newbie in MACs and will appreciate a detailed answer for dummies.

Was it helpful?

Solution

I have finally figured out it, in case of someone need it, putting it here. I used apple script:

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top