-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.pl
More file actions
executable file
·102 lines (80 loc) · 1.67 KB
/
Copy pathbuild.pl
File metadata and controls
executable file
·102 lines (80 loc) · 1.67 KB
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
#!/usr/bin/env perl
use v5.20;
use File::Spec;
use File::Path qw(make_path remove_tree);
# === Build configuration
my @files = qw<
src/clean_files.sh
src/Uweh.php
src/UwehTpl.php
src/config.template.php
public/index.php
public/upload.php
public/about.php
public/api.php
public/status.php
public/main.css
public/main.js
bin/set_permissions.sh
bin/protect_status.pl
bin/add_tracking_include.pl
README.md
LICENSE
CHANGELOG.md
>;
my @custom_files = qw<
src/config.php
src/tracking.html
public/favicon-32.png
public/favicon-16.png
public/favicon-196.png
public/riamu.png
public/riamu.webp
>;
my $build_dir = "build";
my $date = `date +%F_%H-%M-%S`; chomp $date;
my $output_tar = "$build_dir/uweh-$date.tar.gz";
my $custom_output_tar = "$build_dir/uweh-mine-$date.tar.gz";
# ...
my $want_help = grep { /^(?: -h | --help )/x } @ARGV;
my $no_args = @ARGV == 0;
if ($want_help) {
print <<~END;
Usage: $0 <subcommand>
$0 --help | -h
Subcommands:
start Build a tarball
clean Remove all previous builds
END
exit 0;
}
if ($no_args) {
print <<~END;
Usage: ./build.pl start
Help: ./build.pl --help
END
exit 0;
}
my $command = shift @ARGV;
if ($command eq 'start') {
make_path($build_dir);
my $c = "tar czf $output_tar @files";
print `echo Running: $c`;
`$c`;
if ($?) {
say "Build failed";
exit -1;
}
} elsif ($command eq 'mine') {
make_path($build_dir);
my $c = "tar czf $custom_output_tar --ignore-failed-read @files @custom_files";
`$c`;
if ($?) {
say "Build failed";
exit -1;
}
} elsif ($command eq 'clean') {
remove_tree($build_dir, { keep_root => 1 });
} else {
say "Unknown subcommand $command, see $0 --help";
}