On Nov 7, 2008, at 1:39 PM, Adam Peck wrote: We just recently implemented something similar here to make sure they wouldn't be able to downgrade. I couldn't figure out a way to do it with meta-packages so we moved to Distribution Scripts. You can programmatically select and de-select items with it. The only downside is you install will not work on anything before Tiger.
So, at Apple, we have a rule of thumb, which is that we always install over the same version. Call it voodoo, but we believe it reduces "Bit Rot" errors.
There's one exception: if I were installing iLife, and I have in my installer QuickTime 7.x, and the user has 7.x already, I would NOT reinstall it, because by doing so, I'd force the user to restart.
(I can handwave an excuse by saying that if QuickTime is busted, chances are the user won't be running the iLife installer.)
So if the user has iLife, and they launch their iLife installer on the DVD, by default, everything will be installed again -- unless a software update has put down a newer version.
Yes, this makes installation take longer -- especially during a "reinstall" type of case, which is to say, not very often. No, we don't get many complaints about it. No it's not
iLife installer does this by using distribution scripts, because it's not supporting 10.3 any more.
Here's code that is almost identical to the shipping code: function canHasiDVD() { var path = my.target.mountpoint + "/Applications/iDVD.app"; var bundle = system.files.bundleAtPath(path); var version = bundle.CFBundleShortVersionString;
if (system.compareVersions(version, "7.0.3") >= 0) { my.choice.tooltip = system.localizedStringWithFormat('TT_NEWERALREADYINSTALLED'); return false; }
return true; }
Down in the choice outline section of the distribution, you'll see: <choice id="iDVD" title="TITLE_IDVD" description="DESCRIPTION_IDVD" enabled='canHasiDVD()' start_selected='NeedsiDVD()'> <pkg-ref auth="root">file:./Contents/Installers/iDVD.mpkg/Contents/Installers/iDVD.pkg</pkg-ref> </choice>
So the canHas function gets the CFBundleShortVersionString out of the iDVD.app "Info.plist" (Apple uses the "string" for reasons decided long ago and far away -- you can use CFBundleVersion, no really, go right ahead) and then compares it. If the version on disk is newer, we set a tooltip that says "A newer version of this software is already installed" and return false.
The choice then sets the starting state of the "selected" state (ie, the checkbox) to the result of the function call, and sets the "enabled" state also. So if you already have iDVD 7.0.4 (and if you do, please send it to me, we can save some work writing it!), the box will be unchecked and the entire line choice "greyed out" (disabled).
Also, in general, with the exception of undocumented fields, if you see some code you like, feel free to re-use it. |