[eqemu_update.pl] Linux compatibility adjustments [skip ci]

This commit is contained in:
Akkadius 2015-03-12 00:08:10 -05:00
parent 9344cfb4e3
commit b3a0370e71
2 changed files with 42 additions and 21 deletions

View File

@ -494,7 +494,7 @@ bool Database::CheckDatabaseConversions() {
/* Check for a new version of this script, the arg passed /* Check for a new version of this script, the arg passed
would have to be higher than the copy they have downloaded would have to be higher than the copy they have downloaded
locally and they will re fetch */ locally and they will re fetch */
system("perl eqemu_update.pl V 5"); system("perl eqemu_update.pl V 6");
/* Run Automatic Database Upgrade Script */ /* Run Automatic Database Upgrade Script */
system("perl eqemu_update.pl ran_from_world"); system("perl eqemu_update.pl ran_from_world");

View File

@ -15,8 +15,6 @@ use File::Path;
use File::Find; use File::Find;
use URI::Escape; use URI::Escape;
use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
$time_stamp = strftime('%m-%d-%Y', gmtime()); $time_stamp = strftime('%m-%d-%Y', gmtime());
$console_output .= " Operating System is: $Config{osname}\n"; $console_output .= " Operating System is: $Config{osname}\n";
@ -24,7 +22,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; }
if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; }
#::: If current version is less than what world is reporting, then download a new one... #::: If current version is less than what world is reporting, then download a new one...
$current_version = 5; $current_version = 6;
if($ARGV[0] eq "V"){ if($ARGV[0] eq "V"){
if($ARGV[1] > $current_version){ if($ARGV[1] > $current_version){
@ -465,17 +463,13 @@ sub QuestFiles_Fetch{
GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1); GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1);
print "\nFetched latest quests...\n"; print "\nFetched latest quests...\n";
my $zip = Archive::Zip->new(); mkdir('updates_staged');
unless ( $zip->read( 'updates_staged\Quests-Plugins-master.zip' ) == AZ_OK ) { UnZip('updates_staged/Quests-Plugins-master.zip', 'updates_staged/');
die 'read error';
}
print "Extracting...\n";
$zip->extractTree('', 'updates_staged/');
$fc = 0; $fc = 0;
use File::Find; use File::Find;
use File::Compare; use File::Compare;
use Text::Diff;
my @files; my @files;
my $start_dir = "updates_staged/Quests-Plugins-master/quests/"; my $start_dir = "updates_staged/Quests-Plugins-master/quests/";
find( find(
@ -493,7 +487,7 @@ sub QuestFiles_Fetch{
print "Installing :: '" . $dest_file . "'\n"; print "Installing :: '" . $dest_file . "'\n";
} }
else{ else{
$diff = diff($dest_file, $staged_file, { STYLE => "Unified" }); $diff = Diff($dest_file, $staged_file);
if($diff ne ""){ if($diff ne ""){
$backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file;
@ -529,17 +523,13 @@ sub Plugins_Fetch{
GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1); GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1);
print "\nFetched latest plugins...\n"; print "\nFetched latest plugins...\n";
my $zip = Archive::Zip->new();
unless ( $zip->read( 'updates_staged\Quests-Plugins-master.zip' ) == AZ_OK ) { UnZip('updates_staged/Quests-Plugins-master.zip', 'updates_staged/');
die 'read error';
}
print "Extracting...\n";
$zip->extractTree('', 'updates_staged/');
$fc = 0; $fc = 0;
use File::Find; use File::Find;
use File::Compare; use File::Compare;
use Text::Diff;
my @files; my @files;
my $start_dir = "updates_staged/Quests-Plugins-master/plugins/"; my $start_dir = "updates_staged/Quests-Plugins-master/plugins/";
find( find(
@ -557,10 +547,9 @@ sub Plugins_Fetch{
print "Installing :: '" . $dest_file . "'\n"; print "Installing :: '" . $dest_file . "'\n";
} }
else{ else{
$diff = diff($dest_file, $staged_file, { STYLE => "Unified" }); $diff = Diff($dest_file, $staged_file);
if($diff ne ""){ if($diff ne ""){
$backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file;
print $diff . "\n"; print $diff . "\n";
print "\nFile Different :: '" . $dest_file . "'\n"; print "\nFile Different :: '" . $dest_file . "'\n";
print "\nDo you wish to update this Plugin? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; print "\nDo you wish to update this Plugin? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n";
@ -587,6 +576,38 @@ sub Plugins_Fetch{
} }
} }
sub Diff{
$file_1 = $_[0];
$file_2 = $_[1];
if($OS eq "Windows"){
eval "use Text::Diff";
$diff = diff($file_1, $file_2, { STYLE => "Unified" });
return $diff;
}
if($OS eq "Linux"){
# print 'diff -u "$file_1" "$file_2"' . "\n";
return `diff -u "$file_1" "$file_2"`;
}
}
sub UnZip{
$archive_to_unzip = $_[0];
$dest_folder = $_[1];
if($OS eq "Windows"){
eval "use Archive::Zip qw( :ERROR_CODES :CONSTANTS )";
my $zip = Archive::Zip->new();
unless ( $zip->read($archive_to_unzip) == AZ_OK ) {
die 'read error';
}
print "Extracting...\n";
$zip->extractTree('', $dest_folder);
}
if($OS eq "Linux"){
print `unzip -o "$archive_to_unzip" -d "$dest_folder"`;
}
}
sub AreFileSizesDifferent{ sub AreFileSizesDifferent{
$file_1 = $_[0]; $file_1 = $_[0];
$file_2 = $_[1]; $file_2 = $_[1];