I hope that the following may save someone else from wasting as much time as I did in trying to figure out why PackageMaker seemed to loose a custom folder icon. I am very much a beginning user of this tool and don't guarantee any of the following to be correct. I am grateful for the help that I have already received from this list and I welcome posts providing correction or further information.
It appears that the PackageMaker that ships with Leopard 10.5 may under at least one condition strip away at least some folder attributes. One effect of this is that custom folder icons are lost.
The condition under which this seems to occur, is when the "Include root in package" option is selected(checked) and the root folder itself has a custom icon. The solution to this problem is quite simple, don't use as the root for a package source, any folder that has a custom icon that you want included in the resultant package.
I did a lot of testing, learned a lot about the "GetFileInfo" and "SetFile" commands. I also did a lot of testing with UFS and FAT volumes as sources. I even learned about and played with the SplitForks command. At first I thought that some of these were parts of successful workarounds. But it now appears that what had actually fixed the problem was the change in the root of the source for the package. I spent many hours before I figured this out. And except for the educational benefit, most of it was a wild goose chase and a waste of time.
Again, with the PackageMaker that ships with Leopard, if the "Include root in package" option of the "Contents pane is checked, then the root folder may loose its attributes.
TEST CASE In a test case, the original folder had the following attributes according to the "GetFileInfo" command included in the developer package:
attributes: avbstClINmedz
After being made into a package and installed, the resultant installed folder attributes were:
attributes: avbstclinmedz
So at least some of the folder attributes are changed (lost?). (Perhaps even all of them, but I didn't test this.) Only the attributes appeared to have been lost. For custom folder Icons, the appropriate Icon^M file was still there and appropriate use of the SetFile command caused it to be properly displayed again.
Best Wishes,
Paul
Begin forwarded message: Date: March 27, 2008 4:22:49 PM CDT Subject: Re: PackageMaker & Custom Folder Icons
Thank you very much. Some of this is new, so it may take me a while to figure it out. But, I do expect that I and others will find it useful.
Best Wishes,
Paul
On Mar 27, 2008, at 12:07 PM, Andrew wrote: Paul, I'd prefer not to spread my contact information, but feel free to share the information part of this email with the list if you find it useful.
Our installers do three things to get custom folder icons to appear properly in a variety of OS versions:
1. Install an Icon^M file (same as Icon\r as Stephen indicates). In bash, you can form this file name using Icon$'\r' or "${SOME_PARENT}"/Icon$'\r'
2. Set the custom icon bit on the enclosing folder. We do this by "find"ing Icon^M files in our installation and then running a custom tool on the parent directory paths. Depending on your scripting ability and environment, it may be simpler to just use a fixed path. You could test this step using the developer tool SetFile, however, I would be surprised if you could ship with that.
3. Refresh the Finder's view of the folder. Historically we have done this via an AppleScript that tells the Finder to iterate all its windows and update the items of each one. More recently we have had success asking the Finder to update all the parent directory paths up to and including the one getting the custom icon. There are other gyrations such as deleting or replacing .DS_Store files and restarting the Finder that can be done, however, the above approaches work pretty reliably and have the benefit of not losing data such as window layouts.
Best of luck, Andrew
On Mar 27, 2008, at 7:21 AM, Paul Cook wrote: Stéphane Sudre,
Thanks very much for the needed refresher course & your help.
In answer to your question, we were observing this issue on Leopard 10.5.2. Leopard 10.5.2 was used to create the packages and it was also the target.
I'll try to see if the "kHasCustomIcon" is being set on the folder. That sounds like a good lead.
Best Wishes,
Paul
On which OS are you observing this issue?
Custom Folder icons has a troubled history with Installer.app and Mac OS X.
o First, a refresher on custom folder icons:
To have a custom folder icon you need to have both an invisible Icon \r file inside the folder and some flags set on the folder itself.
* Icon\r file
It is a Resource fork file. The different icon representations are stored in 'icns' resource -16455. The file type is 'icon', the creator is 'MACS'. The FileInfo finderFlags for this file has the kIsInvisible flag set
* Folder:
The FolderInfo finderFlags for the folder has the kHasCustomIcon flag set.
o This means that in order to have a custom folder icon, a package needs to both retain the resource fork of the Icon\r file and the Finder flags.
This is done through the split forks operation that creates the Apple Double format file. A file A may end up through this process as 2 files:
A which only contains the data fork part of A
._A which contains the finder Info and the resource fork of A
I filed a bug report (Problem ID: 3635123 04/27/2004 which is said to be a duplicate of 3551477). At the time, the issue was that the kHasCustomIcon was not set back on the folder upon installation.
I can't say whether the bug was fixed or not on the OS I was observing it because the report was marked as duplicate.
My $0.02
-- Stephane
On Mar 26, 2008, at 3:38 PM, Paul Cook wrote: Does anyone know how to get Apple's PackageMaker to handle custom folder icons?
I'm not really a developer. But in order to install software via Apple Remote Desktop or as part of OS-X Servers NetInstall, it has to be in an Apple style package. So we are repackaging some software with PackageMaker. And this seems to be the most appropriate list for PackageMaker questions.
Generally, things are working well, except that, when we run the installers, folders have lost their custom icons. Otherwise, if there are other problems, we haven't yet noticed them.
One example is, we were trying to repackage Office 2004 into a package so that it could be installed by Leopard Server's NetInstall feature. Other than being big, there doesn't appear to be anything too complicated here. The created install works fine, except the Office 2004 folder icon is missing. Although, if I do an ls -Gal of the folder created with the installer, there is a .Icon file there.
Since Office is so huge, to make testing quicker, we created a new, folder with just a simple text file in it and using finder's Get Info, we copied the icon from the original Office 2004 folder and pasted it into the test folder. It seems to recreate the problem fine. The package creates a the folder, as it should, except no custom icon displays.
I'm using the Leopard Developer Utilities on a Mac running the current version of Leopard.
Based on some google hits for the problem, I've played with trying to not filter out the .DS_Store files. We've tried playing with what is the root for the package. And we put the source for Package Maker onto a UFS disk image to force any resources into Apple Double format. (One hit suggested that PackageMaker didn't properly handle resource forks. Is true?) We have also looked at what Apple documentation we could find on how to use PackageMaker.
We didn't want to let a little think like an Icon be a blemish on the quality of the effort, but after about 5 hours on this little icon problem, we decided to take a break.
Any ideas?
Best Wishes,
Paul
Begin forwarded message:
Date: March 26, 2008 5:40:12 PM CDT To: Paul Cook Subject: Re: PackageMaker & Custom Folder Icons
On Mar 26, 2008, at 1:38 PM, Paul Cook wrote: Does anyone know how to get Apple's PackageMaker to handle custom folder icons?
The icon is actually contained in a resource fork of a file with a funky name, Icon^M (that's actually a control-M, also known as a carriage-return).
In Tiger's Package Maker, there was a check box somewhere or other that allowed you to suppress resource forks, which would have the effect of breaking these Icon^M files. In Leopard, I can't even find the check box -- apparently, resource forks are always removed, and hence instlling folder icons is impossible! Unless someone can point us to the "strip rsrc" button in Leopard? Or some other tricky technique?
-==-
Project Owner SCPlugin "Subversion for the rest of OS X"
|