Skip to content

Instantly share code, notes, and snippets.

@calum-github
Created January 16, 2015 01:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calum-github/97743e99b9bc854f4361 to your computer and use it in GitHub Desktop.
Save calum-github/97743e99b9bc854f4361 to your computer and use it in GitHub Desktop.
Java 2014-001 scripts
/Applications/Utilities/Java Preferences.app
#!/usr/bin/perl
my $wd = `pwd`;
chomp($wd);
system( $wd . "/Tools/deleteomatic",
$ARGV[2],
$wd . "/cleanup-list" );
########################################################
# always exit 0
exit 0;
#!/usr/bin/perl
my $ROOT_DIR = $ARGV[0];
my $DATA_FILE = $ARGV[1];
open (FILE, $DATA_FILE) || die ;
while (defined (my $deleteme = <FILE>)) {
$deleteme =~ /^\s*(.+?)\s*$/;
$deleteme = $1;
if (length($deleteme) > 0)
{
deleteTree($ROOT_DIR . $deleteme);
}
}
sub deleteTree
{
my $path = $_[0];
if (-e $path)
{
if (-d $path
&& !(-l $path))
{
local* THEDIR;
my $file;
opendir THEDIR, $path;
while ($file = readdir THEDIR)
{
if ($file ne '.' && $file ne '..')
{
deleteTree($path . "/" . $file);
}
}
closedir THEDIR;
rmdir $path;
} else {
unlink $path;
}
} else {
if (-l $path)
{
unlink $path;
}
}
}
These are the scripts from the JavaEssentials.pkg
#!/usr/bin/perl
$0 =~ m/.*\/(.*)$/;
my $stage = $1;
my $action = $ARGV[3];
my $wd = `pwd`;
chomp($wd);
my $actionsDir = $wd . "/" . 'postinstall' . "_actions/";
my $upgradeDir = $wd . "/" . 'postupgrade' . "_actions/";
my $upgrade = 0;
my $debug = 1;
my $count;
if ( $0 =~ /postupgrade/ || $0 =~ /preupgrade/ || $action =~ /upgrade/) {
system("logger -p install.info 'Upgrade scripts will be run.'") if ( $debug );
$upgrade = 1;
}
if ( $stage =~ /pre/ )
{
$actionsDir = $wd . "/" . 'preinstall' . "_actions/";
$upgradeDir = $wd . "/" . 'preupgrade' . "_actions/";
}
if ( $upgrade == 1 && -e $upgradeDir ) {
system("logger -p install.info 'Running Upgrade Scripts . . .'") if ( $debug );
$count = 0;
foreach my $action (`/bin/ls \Q$upgradeDir\E`) {
chomp($action);
system("logger -p install.info 'Begin script: $action'") if ( $debug );
system($upgradeDir . $action, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]);
system("logger -p install.info 'End script: $action'") if ( $debug );
$count++;
}
system("logger -p install.info '$count Upgrade Scripts run.'") if ( $debug );
}
if ( -e $actionsDir ) {
system("logger -p install.info 'Running Install Scripts . . .'") if ( $debug );
$count = 0;
foreach my $action (`/bin/ls \Q$actionsDir\E`) {
chomp($action);
system("logger -p install.info 'Begin script: $action'") if ( $debug );
system($actionsDir . $action, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3],$upgrade);
system("logger -p install.info 'End script: $action'") if ( $debug );
$count++;
}
system("logger -p install.info '$count Install Scripts run.'") if ( $debug );
}
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment