I have created package (.pkg) file using packagemaker ver 3.0.4. Is it possible to provide custom icon to the .pkg file. Can some one help me how this can be done ? Thanks in advance.
Asked
Active
Viewed 3,150 times
2 Answers
3
Setting an icon for an mpkg, works fine
# create a file that actually going to set the icon file
touch <package_name>.mpkg/Icon$'\r'
# --- copy the customIcon.icns file to the <package_name>.mpkg before doing the sips, if its needed you
# can take a copy of the file before doing the sips command, doing on a copied file will do good
sips -i <package_name>.mpkg/customIcon.icns
DeRez -only icns <package_name>.mpkg/customIcon.icns > tmpIcon.rsrc
Rez -append tmpIcon.rsrc -o $'<package_name>.mpkg/Icon\r'
SetFile -a C <package_name>.mpkg
# removing the tmp file
rm tmpIcon.rsrc
# remove the .icns from mpkg
rm <package_name>.mpkg/customIcon.icns
# if you want you can hide the Icon$'\r' file inside the .mpkg file, file that presently sets the icon
SetFile -a V <package_name>.mpkg/Icon$'\r'
Hope this helps.

Rekha
- 31
- 1
3

Peter Hosey
- 95,783
- 15
- 211
- 370
-
I am not sure if this is still applicable for snow leopard. Did not work for me. – Unicorn Jun 03 '10 at 09:30
-
2Unicorn: It is. It works just fine all the way through 10.6.3. Make sure the place where you put the pkg, and the pkg itself, are writable. – Peter Hosey Jun 03 '10 at 09:38
-
Oh yea, it worked for me. Was doing at incorrect place. Thanks a ton for the info. But now the problem is when i create the package again this icon will be changed. Is it possible to add this icon file to pmdoc itself so when ever package is created out of it, it will have custom icon ? – Unicorn Jun 03 '10 at 10:03
-
1Not that I know of. You'll have to automate it some other way, such as by AppleScript or by shell-scripting the SetFile(1) command. The latter solution consists of putting the icon in a file in IconFamily (.icns) format inside the .pkg, with the filename “Icon\r” (“Icon” followed by a carriage return, ASCII 0x0d), and using SetFile to give the .pkg the custom-icon bit and take away its inited bit. – Peter Hosey Jun 03 '10 at 10:07
-
Great help, i m gonna try this now. – Unicorn Jun 03 '10 at 10:18