home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2003 August
/
Chip_2003-08_cd1.bin
/
zkuste
/
macos
/
Files
/
Safari.dmg
/
Safari.pkg
/
Contents
/
Resources
/
postflight
< prev
next >
Wrap
Text File
|
2003-06-16
|
3KB
|
99 lines
#!/usr/bin/perl
use File::Path;
use File::Spec;
use Cwd;
my $TARGET_VOLUME = $ARGV[2];
my $PACKAGE_PATH = $ENV{PACKAGE_PATH};
my $SCRIPT_NAME = $ENV{SCRIPT_NAME};
my $POSTFLIGHT_SCRIPT_PATH = $ENV{RECEIPT_PATH};
my @PFPATHARRAY = File::Spec->splitdir($POSTFLIGHT_SCRIPT_PATH);
pop @PFPATHARRAY;
pop @PFPATHARRAY;
my $RECEIPT_PATH = $TARGET_VOLUME . File::Spec->catdir(@PFPATHARRAY);
####################################################################################################
my $TOKEN = "Safari";
my $TOKENSPLIST = quotemeta($RECEIPT_PATH . "/Contents/tokens.plist");
my $olddir = getcwd();
chdir($PACKAGE_PATH . "/Contents/Resources/");
my $command = "./PlistBuddy -c \"Print :" . $TOKEN . "\" " . $TOKENSPLIST . " |";
open(PSOUT, $command);
chomp(my $FOUNDAPP = <PSOUT>);
close(PSOUT);
chdir($olddir);
my $APPPATHWITHINVOL = File::Spec->canonpath($FOUNDAPP);
my $APPPATH = $TARGET_VOLUME . "/" . $APPPATHWITHINVOL;
my @PATHARRAY = File::Spec->splitdir($APPPATH);
pop @PATHARRAY;
my $PARENTDIR = File::Spec->catdir(@PATHARRAY);
####################################################################################################
my $BOMLocation = quotemeta($RECEIPT_PATH . "/Contents/Archive.bom");
my %inBOM;
my $item;
$olddir = getcwd();
chdir($APPPATH);
my @AppContents = split(/\n/, `/usr/bin/find -d .`);
chdir($olddir);
open(BOM, "/usr/bin/lsbom -s " . $BOMLocation . " |");
while (<BOM>) {
if (m-^\.\/\Q${APPPATHWITHINVOL}\E(.*)$-) {
$inBOM{$1} = 1;
}
};
close(BOM);
foreach $item (@AppContents) {
$item =~ s/^\.//;
unless ($inBOM{$item}) {
my $obsolete = $APPPATH . $item;
rmdir($obsolete);
unlink($obsolete);
}
}
#####################################################################################################
$olddir = getcwd();
chdir($APPPATH);
system "/usr/bin/touch ./";
chdir($PARENTDIR);
system "/usr/bin/touch ./";
chdir($olddir);
####################################################################################################
my $permissions_info_file = "/tmp/com.apple.installation.savedperm";
my @stat_info;
my $MODE = 2;
my $UID = 4;
my $GID = 5;
if(-e $permissions_info_file) {
if(open(PERMS_FILE_HDL, "$permissions_info_file")) {
while(<PERMS_FILE_HDL>) {
my $item = $_;
chomp($item);
push(@stat_info, $item);
}
close(PERMS_FILE_HDL);
unlink($permissions_info_file);
chown($stat_info[$UID], $stat_info[$GID], $TARGET_VOLUME);
chmod($stat_info[$MODE] & 07777, $TARGET_VOLUME);
}
}
####################################################################################################
exit 0;