Handy Script to detect app installed and version
Handy Script to detect app installed and version
- Subject: Handy Script to detect app installed and version
- From: Hagen Kaye <email@hidden>
- Date: Tue, 20 Mar 2007 11:44:26 -0400
Hi List,
I thought some might find this tidbit of code useful. If you are
creating a package installer that requires an application to be
installed and that application must have a minimum version number
here is a handy perl script to detect this. It will test the
presence of an app and version number and cancel the installation if
the requirements are not met.
This sample script will detect if iPhoto is installed and test to
make sure it's at least version 6.0 or better. Substitute the
parameters appropriately to detect other apps and versions
------------------------------------
#!/usr/bin/perl
use Foundation;
use Mac::Processes;
# find the application from the bundle indentifier
$path = LSFindApplicationForInfo (undef, "com.apple.iPhoto");
print "iPhoto found at $path\n";
# now that we have the path - get the Info.plist file of the application
$file = $path . "/Contents/Info.plist";
$plist = NSDictionary->dictionaryWithContentsOfFile_( $file );
if ( ! $plist or ! $$plist ) {
print "Could not find iPhoto\n";
exit 96;
}
# search the plist for the version number of the app
$version = 0.0;
$value = $plist->objectForKey_("CFBundleShortVersionString");
if ($value && $$value) {
$version = $value->description()->UTF8String();
}
# test version number for minimum requirements
print "Version: $version\n";
if ($version < 6.0) {
print "Need iPhoto 6.0 or better\n";
exit 96;
}
exit 0;
--------------------------
Save this perl script as InstallationCheck and put in the Contents/
Resources folder of the package. More information on using a
InstallationCheck script can be found by Google'ing InstallationCheck
(top hit takes you to the developer page here at apple).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden