-
Notifications
You must be signed in to change notification settings - Fork 16
/
update.pl
123 lines (104 loc) · 3.71 KB
/
update.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/perl -w
#
# This program update SPADS components in current directory from remote repository.
#
# Copyright (C) 2008-2024 Yann Riou <yaribzh@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Version 0.16 (2024/09/10)
use strict;
use FindBin;
use List::Util qw'any all none notall';
use lib $FindBin::Bin;
use SimpleLog;
use SpadsUpdater;
my $win=$^O eq 'MSWin32' ? 1 : 0;
my $macOs=$^O eq 'darwin';
my $sLog=SimpleLog->new(logFiles => [""],
logLevels => [4],
useANSICodes => [-t STDOUT ? 1 : 0],
useTimestamps => [-t STDOUT ? 0 : 1],
prefix => "[Update] ");
sub invalidUsage {
$sLog->log("Invalid usage",1);
print <<EOM;
Usage:
perl $0 <release> [-f] -a
perl $0 <release> [-f] <packageName> [<packageName2> [<packageName3> ...]]
<release>: SPADS release to update ("stable", "testing", "unstable" or "contrib")
-f: force update (even if it requires manual updates of configuration files)
-a: update all SPADS packages
<packageName>: SPADS package to update
EOM
exit 1;
}
invalidUsage() if($#ARGV < 1 || none {$ARGV[0] eq $_} qw/stable testing unstable contrib/);
my $release=$ARGV[0];
my %packages;
my $force=0;
for my $argNb (1..$#ARGV) {
if($ARGV[$argNb] eq '-f') {
$force=1;
}elsif($ARGV[$argNb] eq '-a') {
%packages=('getDefaultModOptions.pl' => 1,
'help.dat' => 1,
'helpSettings.dat' => 1,
'PerlUnitSync.pm' => 1,
'springLobbyCertificates.dat' => 1,
'SpringAutoHostInterface.pm' => 1,
'SpringLobbyProtocol.pm' => 1,
'SpringLobbyInterface.pm' => 1,
'SimpleEvent.pm' => 1,
'SimpleLog.pm' => 1,
'spads.pl' => 1,
'SpadsConf.pm' => 1,
'spadsInstaller.pl' => 1,
'SpadsPluginApi.pm' => 1,
'SpadsUpdater.pm' => 1,
'update.pl' => 1,
'argparse.py' => 1,
'replay_upload.py' => 1,
'sequentialSpadsUnitsyncProcess.pl' => 1);
if($win) {
$packages{'7za.exe'}=1;
}elsif(! $macOs) {
$packages{'7za'}=1;
}
}else{
$packages{$ARGV[$argNb]}=1;
}
}
my @packs=keys %packages;
invalidUsage() unless(@packs);
my $updaterLog=SimpleLog->new(logFiles => [''],
logLevels => [4],
useANSICodes => [-t STDOUT ? 1 : 0],
useTimestamps => [-t STDOUT ? 0 : 1],
prefix => '[SpadsUpdater] ');
my $updater=SpadsUpdater->new(sLog => $updaterLog,
repository => 'http://planetspads.free.fr/spads/repository',
release => $release,
packages => \@packs);
my $updaterRc=$updater->update($force,$force);
if($updaterRc < 0) {
$sLog->log('Unable to update package(s)',1);
exit 1;
}
if($updaterRc > 0) {
$sLog->log("$updaterRc package(s) updated for $release release.",3);
}else{
$sLog->log("No update available for $release release.",3);
}
exit 0;