home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 August
/
Chip_2003-08_cd1.bin
/
zkuste
/
macos
/
Files
/
Safari.dmg
/
Safari.pkg
/
Contents
/
Resources
/
VolumeCheck
< prev
Wrap
Text File
|
2003-06-13
|
3KB
|
124 lines
#!/usr/bin/perl
########################################################
my $SYSTEM_VERS = $ARGV[0] . "/System/Library/CoreServices/SystemVersion.plist";
my $FOUNDATION_VERS = $ARGV[0] . "/System/Library/Frameworks/Foundation.framework/Resources/Info.plist";
my $EXIT_VALUE = 0;
########################################################
DO_CHECKS:
{
# Must have Mac OS X on target volume.
if (! -e $SYSTEM_VERS) {
$EXIT_VALUE = (( 1 << 6 ) | ( 1 << 5 ) | 16);
last;
}
# 10.2.0 or better on target disk, please.
if (CheckVersion($SYSTEM_VERS, "10.2.0", "ProductVersion", "<")) {
$EXIT_VALUE = (( 1 << 6 ) | ( 1 << 5 ) | 16);
last;
}
# Less than 10.3 on target disk, please.
if (CheckVersion($SYSTEM_VERS, "10.3.0", "ProductVersion", ">=")) {
$EXIT_VALUE = (( 1 << 6 ) | ( 1 << 5 ) | 17);
last;
}
# Foundation framework verison 6.2.0 or 6.2.1 ONLY, please.
unless (CheckVersion($FOUNDATION_VERS, "6.2.0", "CFBundleShortVersionString", "==")) {
unless (CheckVersion($FOUNDATION_VERS, "6.2.1", "CFBundleShortVersionString", "==")) {
$EXIT_VALUE = (( 1 << 6 ) | ( 1 << 5 ) | 18);
last;
}
}
}
exit($EXIT_VALUE);
########################################################
########################################################
sub CheckVersion
{
my $path = $_[0];
my $version = $_[1];
my $keyName = $_[2];
my $operator = $_[3];
my $oldSeperator;
my $plistData;
my @items;
my $item;
my $versiondata;
my $i;
my @theVersionArray;
my %versiondata;
my @versionArray;
# if there's no THERE there, we return FALSE
if (! -e $path) {
return 0;
}
if (!$operator) {
$operator = "==";
}
$oldSeperator = $/;
$/ = \0;
open( PLIST, "$path") || do {
return 0;
};
$plistData = <PLIST>;
$plistData =~ /<dict>(.*?)<\/dict>/gis;
@items = split(/<key>/, $plistData);
shift @items;
foreach $item (@items) {
$item =~ /(.*?)<\/key>.*?<string>(.*?)<\/string>/gis;
$versiondata{ $1 } = $2;
}
close(PLIST);
$/ = $oldSeperator;
@theVersionArray = split(/\./, $versiondata{$keyName});
for ($i = 0; $i < 3; $i++) {
if(!$theVersionArray[$i]) {
$theVersionArray[$i] = '0';
}
}
@versionArray = split(/\./, $version);
my $actualVersion;
for ($i = 0; $i < 3; $i++) {
if (($theVersionArray[$i] != $versionArray[$i]) or ($i == 2)) {
$actualVersion = $theVersionArray[$i];
$version = $versionArray[$i];
last;
}
}
my $expression = '$actualVersion ' . $operator . ' $version';
if( eval ($expression) )
{
return 1;
}
else
{
return 0;
}
}