forked from Drifter321/DHooks2
-
Notifications
You must be signed in to change notification settings - Fork 11
/
package.pl
99 lines (75 loc) · 1.85 KB
/
package.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/perl
use strict;
use Cwd;
use File::Basename;
use Net::FTP;
my ($ftp_file, $ftp_host, $ftp_user, $ftp_pass, $ftp_path, $tag);
$ftp_file = shift;
$tag = shift;
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;
my ($myself, $path) = fileparse($0);
chdir($path);
require 'helpers.pm';
my ($version);
$version = Build::ProductVersion(Build::PathFormat('product.version'));
$version .= '-hg' . Build::HgRevNum('.');
# Append OS to package version
if ($^O eq "darwin")
{
$version .= '-mac';
}
elsif ($^O =~ /MSWin/)
{
$version .= '-windows';
}
else
{
$version .= '-' . $^O;
}
#Switch to the output folder.
chdir(Build::PathFormat('../../OUTPUT/package'));
my ($dirlist, $filename, $cmd);
$dirlist = "addons";
$filename = 'dhooks-' . $version;
if ($^O eq "linux")
{
$filename .= '.tar.gz';
$cmd = "tar zcvf $filename $dirlist";
}
else
{
$filename .= '.zip';
$cmd = "zip -r $filename $dirlist";
}
print "$cmd\n";
system($cmd);
$ftp_path .= "/dhooks";
my ($major,$minor) = ($version =~ /^(\d+)\.(\d+)/);
$ftp_path .= "/$major.$minor";
my ($ftp);
$ftp = Net::FTP->new($ftp_host, Debug => 0, Passive => 1)
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 '')
{
# YOU LEAVE ME NO CHOICE
$ftp->mkdir($ftp_path, 1);
$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";
$ftp->close();
print "File sent to drop site as $filename -- build succeeded.\n";
exit(0);