/
make-perl6-wix-installer
61 lines (57 loc) · 1.52 KB
/
make-perl6-wix-installer
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
use App::InstallerMaker::WiX::Configuration;
use App::InstallerMaker::WiX::PreCheck;
use App::InstallerMaker::WiX::InstallerBuilder;
use Shell::Command;
sub MAIN(Str $yaml-description) {
my $conf-promise = start App::InstallerMaker::WiX::Configuration.parse(
$yaml-description
);
do-pre-checks();
my $conf = do {
CATCH {
bust "Parsing configuration failed. $_";
}
await $conf-promise;
}
my $work-dir = $*TMPDIR ~ '\\install-build-' ~ time;
mkdir $work-dir;
LEAVE rm_rf $work-dir;
react {
whenever build-installer($conf, $work-dir) {
print "{.name } {'.' x 50 - .name.chars} ";
if .success {
say "OK";
}
else {
say "FAILED";
note .error;
bust "A step in building the installer failed; aborting.";
}
}
}
say "Generating installer completed";
}
sub do-pre-checks() {
my $pre-check-failed = 0;
react {
whenever pre-check() {
print "{.name } {'.' x 50 - .name.chars} ";
if .success {
say "OK";
}
else {
say "FAILED";
$pre-check-failed++;
}
}
}
if $pre-check-failed {
bust "$pre-check-failed pre-check(s) failed; ensure these missing " ~
"tools are installed and in the PATH";
}
say "Pre-checks completed\n";
}
sub bust($message) {
note $message;
exit 1;
}