-
Notifications
You must be signed in to change notification settings - Fork 0
/
bundler.pl
93 lines (80 loc) · 1.84 KB
/
bundler.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
#!/usr/bin/perl
use 5.14.0;
use strict;
use warnings;
use File::Copy;
use lib "./optlib";
use lib "./src";
use Bot::AiRS;
my $version = $Bot::AiRS::VERSION;
print "This script is used to bundle AiRS for distribution.\n"
. "Are you sure you wanted to run this? [yN] ";
chomp(my $ans = <STDIN>);
exit(0) unless $ans eq "y";
# Required commands.
print "Testing for required commands...\n";
foreach my $cmd (qw(cp rm tar)) {
system("which $cmd");
if ($?) {
die "The command $cmd wasn't found. This script can't work!";
}
}
my $root = "AiRS-$version";
if (-d $root) {
die "The `dist` folder already exists... this isn't right!";
}
# Make the distribution copy.
print "Creating distribution root $root\n";
mkdir($root);
# Copy everything to it.
my @files = qw(
brains
doc
listeners
replies
res
src
bundler.pl
cli.pl
License.txt
README.txt
);
foreach my $f (@files) {
if (-d $f) {
say "Copy: cp -r $f $root/";
system("cp", "-r", $f, "$root/");
}
else {
say "Copy: cp $f $root/";
system("cp", $f, "$root/");
}
}
# Create user directories.
mkdir("$root/bots");
mkdir("$root/conf");
mkdir("$root/users");
open (my $dummy, ">", "$root/users/delete.me");
close ($dummy);
# Copy default configs.
print "Copying default configs...\n";
copy("./doc/Sample.json", "./$root/bots/Sample.json");
copy("./doc/botmaster.json", "./$root/conf/botmaster.json");
copy("./doc/colors.json", "./$root/conf/colors.json");
# Build the command for tar.
print "Building 'lite' distribution...\n";
sleep 1;
my @command = (
"tar", "-czvf", "$root.tar.gz", "$root"
);
system(@command);
# Add the 'heavy' lib.
say "Copy: cp -r optlib $root/";
print "Building 'full' distribution...\n";
sleep 1;
system("cp", "-r", "optlib", "$root/");
$command[2] = "$root-full.tar.gz";
system(@command);
# Remove build root.
say "Removing build root.";
system("rm", "-rf", $root);
say "Done!";