2008-09-06 14:19:33 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use Cwd;
|
|
|
|
use File::Basename;
|
2015-09-01 20:30:45 +02:00
|
|
|
use File::stat;
|
2015-10-26 19:10:27 +01:00
|
|
|
use File::Temp qw/ tempfile :seekable/;
|
2008-09-06 14:19:33 +02:00
|
|
|
use Net::FTP;
|
2015-09-18 14:27:28 +02:00
|
|
|
use IO::Uncompress::Gunzip qw(gunzip $GunzipError) ;
|
2015-09-01 20:30:45 +02:00
|
|
|
use Time::localtime;
|
2008-09-06 14:19:33 +02:00
|
|
|
|
2011-05-01 07:17:11 +02:00
|
|
|
my ($ftp_file, $ftp_host, $ftp_user, $ftp_pass, $ftp_path, $tag);
|
2008-09-06 14:19:33 +02:00
|
|
|
|
2008-09-06 15:04:54 +02:00
|
|
|
$ftp_file = shift;
|
2011-05-01 07:17:11 +02:00
|
|
|
$tag = shift;
|
2008-09-06 15:04:54 +02:00
|
|
|
|
|
|
|
open(FTP, $ftp_file) or die "Unable to read FTP config file $ftp_file: $!\n";
|
|
|
|
$ftp_host = <FTP>;
|
|
|
|
$ftp_user = <FTP>;
|
|
|
|
$ftp_pass = <FTP>;
|
|
|
|
$ftp_path = <FTP>;
|
|
|
|
close(FTP);
|
|
|
|
|
|
|
|
chomp $ftp_host;
|
|
|
|
chomp $ftp_user;
|
|
|
|
chomp $ftp_pass;
|
|
|
|
chomp $ftp_path;
|
2008-09-06 14:19:33 +02:00
|
|
|
|
|
|
|
my ($myself, $path) = fileparse($0);
|
|
|
|
chdir($path);
|
|
|
|
|
|
|
|
require 'helpers.pm';
|
|
|
|
|
|
|
|
#Switch to the output folder.
|
2009-08-30 09:21:42 +02:00
|
|
|
chdir(Build::PathFormat('../../../OUTPUT/package'));
|
2008-09-06 14:19:33 +02:00
|
|
|
|
2015-09-01 20:30:45 +02:00
|
|
|
print "Downloading languages.cfg...\n";
|
2015-09-12 20:16:38 +02:00
|
|
|
# Don't check certificate. It will fail on the slaves and we're resolving to internal addressing anyway
|
|
|
|
system('wget --no-check-certificate -q -O addons/sourcemod/configs/languages.cfg "https://sm.alliedmods.net/translator/index.php?go=translate&op=export_langs"');
|
2015-09-01 20:30:45 +02:00
|
|
|
open(my $fh, '<', 'addons/sourcemod/configs/languages.cfg')
|
|
|
|
or die "Could not open languages.cfg' $!";
|
|
|
|
|
|
|
|
while (my $ln = <$fh>) {
|
|
|
|
if ($ln =~ /"([^"]+)"\s*"[^"]+.*\((\d+)\) /)
|
|
|
|
{
|
|
|
|
my $abbr = $1;
|
|
|
|
my $id = $2;
|
|
|
|
|
|
|
|
print "Downloading language pack $abbr.zip...\n";
|
2015-09-12 20:16:38 +02:00
|
|
|
# Don't check certificate. It will fail on the slaves and we're resolving to internal addressing anyway
|
|
|
|
system("wget --no-check-certificate -q -O $abbr.zip \"https://sm.alliedmods.net/translator/index.php?go=translate&op=export&lang_id=$id\"");
|
2015-09-01 20:30:45 +02:00
|
|
|
system("unzip -qo $abbr.zip -d addons/sourcemod/translations/");
|
2015-09-12 21:12:45 +02:00
|
|
|
unlink("$abbr.zip");
|
2015-09-01 20:30:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close($fh);
|
|
|
|
|
|
|
|
my $needNewGeoIP = 1;
|
|
|
|
if (-e '../GeoIP.dat.gz')
|
|
|
|
{
|
2016-07-24 14:26:00 +02:00
|
|
|
my $stats = stat('../GeoIP.dat.gz');
|
|
|
|
if ($stats->size != 0)
|
|
|
|
{
|
|
|
|
my $fileModifiedTime = $stats->mtime;
|
|
|
|
my $fileModifiedMonth = localtime($fileModifiedTime)->mon;
|
|
|
|
my $currentMonth = localtime->mon;
|
|
|
|
my $thirtyOneDays = 60 * 60 * 24 * 31;
|
2015-09-01 20:30:45 +02:00
|
|
|
|
2016-07-24 14:26:00 +02:00
|
|
|
# GeoIP file only updates once per month
|
|
|
|
if ($currentMonth == $fileModifiedMonth || (time() - $fileModifiedTime) < $thirtyOneDays)
|
|
|
|
{
|
|
|
|
$needNewGeoIP = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-09-01 20:30:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($needNewGeoIP)
|
|
|
|
{
|
|
|
|
print "Downloading GeoIP.dat...\n";
|
|
|
|
system('wget -q -O ../GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "Reusing existing GeoIP.dat\n";
|
|
|
|
}
|
|
|
|
|
2015-09-18 14:27:28 +02:00
|
|
|
my $geoIPfile = 'addons/sourcemod/configs/geoip/GeoIP.dat';
|
|
|
|
if (-e $geoIPfile) {
|
|
|
|
unlink($geoIPfile);
|
|
|
|
}
|
2015-09-18 16:08:39 +02:00
|
|
|
|
|
|
|
open(my $fh, ">", $geoIPfile)
|
|
|
|
or die "cannot open $geoIPfile for writing: $!";
|
|
|
|
binmode($fh);
|
|
|
|
gunzip '../GeoIP.dat.gz' => $fh
|
2015-09-18 14:27:28 +02:00
|
|
|
or die "gunzip failed: $GunzipError\n";
|
2015-09-18 16:08:39 +02:00
|
|
|
close($fh);
|
2015-09-01 20:30:45 +02:00
|
|
|
|
2008-09-06 14:19:33 +02:00
|
|
|
my ($version);
|
|
|
|
|
2009-08-30 09:21:42 +02:00
|
|
|
$version = Build::ProductVersion(Build::PathFormat('../../build/product.version'));
|
|
|
|
$version =~ s/-dev//g;
|
2014-05-25 21:05:24 +02:00
|
|
|
$version .= '-git' . Build::GitRevNum('../../build');
|
2008-09-06 14:19:33 +02:00
|
|
|
|
2010-05-13 11:23:43 +02:00
|
|
|
# Append OS to package version
|
|
|
|
if ($^O eq "darwin")
|
|
|
|
{
|
|
|
|
$version .= '-mac';
|
|
|
|
}
|
2010-05-13 11:54:31 +02:00
|
|
|
elsif ($^O =~ /MSWin/)
|
|
|
|
{
|
|
|
|
$version .= '-windows';
|
|
|
|
}
|
2010-05-13 11:23:43 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$version .= '-' . $^O;
|
|
|
|
}
|
|
|
|
|
2011-05-01 07:17:11 +02:00
|
|
|
if (defined $tag)
|
|
|
|
{
|
|
|
|
$version .= '-' . $tag;
|
|
|
|
}
|
|
|
|
|
2008-09-06 14:19:33 +02:00
|
|
|
my ($filename);
|
|
|
|
$filename = 'sourcemod-' . $version;
|
|
|
|
if ($^O eq "linux")
|
|
|
|
{
|
|
|
|
$filename .= '.tar.gz';
|
|
|
|
print "tar zcvf $filename addons cfg\n";
|
|
|
|
system("tar zcvf $filename addons cfg");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$filename .= '.zip';
|
|
|
|
print "zip -r $filename addons cfg\n";
|
|
|
|
system("zip -r $filename addons cfg");
|
|
|
|
}
|
|
|
|
|
2015-10-26 19:10:27 +01:00
|
|
|
my ($tmpfh, $tmpfile) = tempfile();
|
|
|
|
print $tmpfh $filename;
|
|
|
|
$tmpfh->seek( 0, SEEK_END );
|
|
|
|
my $latest = "sourcemod-latest-";
|
|
|
|
if ($^O eq "darwin") {
|
|
|
|
$latest .= "mac";
|
|
|
|
}
|
|
|
|
elsif ($^O =~ /MSWin/) {
|
|
|
|
$latest .= "windows";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$latest .= $^O;
|
|
|
|
}
|
|
|
|
|
2008-09-06 14:19:33 +02:00
|
|
|
my ($major,$minor) = ($version =~ /^(\d+)\.(\d+)/);
|
|
|
|
$ftp_path .= "/$major.$minor";
|
|
|
|
|
|
|
|
my ($ftp);
|
|
|
|
|
2014-03-03 12:21:50 +01:00
|
|
|
$ftp = Net::FTP->new($ftp_host, Debug => 0, Passive => 1)
|
2008-09-06 14:19:33 +02:00
|
|
|
or die "Cannot connect to host $ftp_host: $@";
|
|
|
|
|
|
|
|
$ftp->login($ftp_user, $ftp_pass)
|
|
|
|
or die "Cannot connect to host $ftp_host as $ftp_user: " . $ftp->message . "\n";
|
|
|
|
|
|
|
|
if ($ftp_path ne '')
|
|
|
|
{
|
|
|
|
$ftp->cwd($ftp_path)
|
|
|
|
or die "Cannot change to folder $ftp_path: " . $ftp->message . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$ftp->binary();
|
|
|
|
$ftp->put($filename)
|
|
|
|
or die "Cannot drop file $filename ($ftp_path): " . $ftp->message . "\n";
|
2015-10-26 19:10:27 +01:00
|
|
|
$ftp->put($tmpfile, $latest)
|
|
|
|
or die "Cannot drop file $latest ($ftp_path): " . $ftp->message . "\n";
|
2008-09-06 14:19:33 +02:00
|
|
|
|
|
|
|
$ftp->close();
|
|
|
|
|
|
|
|
print "File sent to drop site as $filename -- build succeeded.\n";
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|