Filename | /root/tor-browser-build/rbm/lib/RBM/DefaultConfig.pm |
Statements | Executed 295734 statements in 1.39s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
19910 | 1 | 1 | 938ms | 312s | __ANON__[rbm/lib/RBM/DefaultConfig.pm:557] | RBM::DefaultConfig::
1991 | 1 | 1 | 247ms | 130s | lsb_release | RBM::DefaultConfig::
37829 | 4 | 1 | 77.2ms | 77.2ms | CORE:match (opcode) | RBM::DefaultConfig::
1991 | 1 | 1 | 75.2ms | 137s | __ANON__[rbm/lib/RBM/DefaultConfig.pm:578] | RBM::DefaultConfig::
1992 | 1 | 1 | 55.9ms | 77.8s | __ANON__[rbm/lib/RBM/DefaultConfig.pm:156] | RBM::DefaultConfig::
1991 | 1 | 1 | 41.7ms | 41.7ms | CORE:ftfile (opcode) | RBM::DefaultConfig::
3976 | 1 | 1 | 39.8ms | 147s | __ANON__[rbm/lib/RBM/DefaultConfig.pm:605] | RBM::DefaultConfig::
1990 | 1 | 1 | 26.8ms | 2119s | __ANON__[rbm/lib/RBM/DefaultConfig.pm:606] (recurses: max depth 11, inclusive time 8843s) | RBM::DefaultConfig::
26 | 1 | 1 | 663µs | 5.70ms | rbm_tmp_dir | RBM::DefaultConfig::
1 | 1 | 1 | 19µs | 20µs | BEGIN@13 | RBM::DefaultConfig::
1 | 1 | 1 | 16µs | 19µs | BEGIN@3 | RBM::DefaultConfig::
1 | 1 | 1 | 10µs | 27µs | BEGIN@15 | RBM::DefaultConfig::
1 | 1 | 1 | 9µs | 61µs | BEGIN@16 | RBM::DefaultConfig::
1 | 1 | 1 | 8µs | 29µs | BEGIN@14 | RBM::DefaultConfig::
1 | 1 | 1 | 8µs | 46µs | BEGIN@12 | RBM::DefaultConfig::
1 | 1 | 1 | 8µs | 8µs | BEGIN@6 | RBM::DefaultConfig::
1 | 1 | 1 | 6µs | 22µs | BEGIN@4 | RBM::DefaultConfig::
1 | 1 | 1 | 700ns | 700ns | __ANON__ (xsub) | RBM::DefaultConfig::
0 | 0 | 0 | 0s | 0s | __ANON__[rbm/lib/RBM/DefaultConfig.pm:534] | RBM::DefaultConfig::
0 | 0 | 0 | 0s | 0s | __ANON__[rbm/lib/RBM/DefaultConfig.pm:607] | RBM::DefaultConfig::
0 | 0 | 0 | 0s | 0s | docker_version | RBM::DefaultConfig::
0 | 0 | 0 | 0s | 0s | get_arch | RBM::DefaultConfig::
0 | 0 | 0 | 0s | 0s | git_describe | RBM::DefaultConfig::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package RBM::DefaultConfig; | ||||
2 | |||||
3 | 2 | 21µs | 2 | 21µs | # spent 19µs (16+2) within RBM::DefaultConfig::BEGIN@3 which was called:
# once (16µs+2µs) by RBM::BEGIN@20 at line 3 # spent 19µs making 1 call to RBM::DefaultConfig::BEGIN@3
# spent 2µs making 1 call to strict::import |
4 | 2 | 56µs | 2 | 38µs | # spent 22µs (6+16) within RBM::DefaultConfig::BEGIN@4 which was called:
# once (6µs+16µs) by RBM::BEGIN@20 at line 4 # spent 22µs making 1 call to RBM::DefaultConfig::BEGIN@4
# spent 16µs making 1 call to warnings::import |
5 | |||||
6 | # spent 8µs within RBM::DefaultConfig::BEGIN@6 which was called:
# once (8µs+0s) by RBM::BEGIN@20 at line 10 | ||||
7 | 1 | 200ns | require Exporter; | ||
8 | 1 | 4µs | our @ISA = qw(Exporter); | ||
9 | 1 | 3µs | our @EXPORT = qw(%default_config); | ||
10 | 1 | 18µs | 1 | 8µs | } # spent 8µs making 1 call to RBM::DefaultConfig::BEGIN@6 |
11 | |||||
12 | 2 | 22µs | 2 | 83µs | # spent 46µs (8+38) within RBM::DefaultConfig::BEGIN@12 which was called:
# once (8µs+38µs) by RBM::BEGIN@20 at line 12 # spent 46µs making 1 call to RBM::DefaultConfig::BEGIN@12
# spent 38µs making 1 call to Exporter::import |
13 | 2 | 35µs | 2 | 20µs | # spent 20µs (19+700ns) within RBM::DefaultConfig::BEGIN@13 which was called:
# once (19µs+700ns) by RBM::BEGIN@20 at line 13 # spent 20µs making 1 call to RBM::DefaultConfig::BEGIN@13
# spent 700ns making 1 call to RBM::DefaultConfig::__ANON__ |
14 | 2 | 25µs | 2 | 51µs | # spent 29µs (8+22) within RBM::DefaultConfig::BEGIN@14 which was called:
# once (8µs+22µs) by RBM::BEGIN@20 at line 14 # spent 29µs making 1 call to RBM::DefaultConfig::BEGIN@14
# spent 22µs making 1 call to Exporter::import |
15 | 2 | 25µs | 2 | 44µs | # spent 27µs (10+17) within RBM::DefaultConfig::BEGIN@15 which was called:
# once (10µs+17µs) by RBM::BEGIN@20 at line 15 # spent 27µs making 1 call to RBM::DefaultConfig::BEGIN@15
# spent 17µs making 1 call to Exporter::import |
16 | 2 | 1.59ms | 2 | 114µs | # spent 61µs (9+52) within RBM::DefaultConfig::BEGIN@16 which was called:
# once (9µs+52µs) by RBM::BEGIN@20 at line 16 # spent 61µs making 1 call to RBM::DefaultConfig::BEGIN@16
# spent 52µs making 1 call to Exporter::import |
17 | |||||
18 | sub git_describe { | ||||
19 | my ($project, $options) = @_; | ||||
20 | my $git_hash = RBM::project_config($project, 'git_hash', $options) | ||||
21 | || RBM::exit_error('No git_hash specified'); | ||||
22 | my %res; | ||||
23 | $RBM::config->{projects}{$project}{describe} = {}; | ||||
24 | my $old_cwd = getcwd; | ||||
25 | RBM::git_clone_fetch_chdir($project, $options); | ||||
26 | my ($stdout, $stderr, $success, $exit_code) | ||||
27 | = capture_exec('git', 'describe', '--long', $git_hash); | ||||
28 | if ($success) { | ||||
29 | @res{qw(tag tag_reach hash)} = $stdout =~ m/^(.+)-(\d+)-g([^-\n]+)$/; | ||||
30 | } | ||||
31 | chdir($old_cwd); | ||||
32 | return $success ? \%res : undef; | ||||
33 | } | ||||
34 | |||||
35 | # spent 130s (247ms+130) within RBM::DefaultConfig::lsb_release which was called 1991 times, avg 65.4ms/call:
# 1991 times (247ms+130s) by RBM::config_p at line 94 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 65.4ms/call | ||||
36 | 1991 | 5.81ms | my ($project, $options) = @_; | ||
37 | 1991 | 6.14ms | 1991 | 0s | my $distribution = RBM::project_config($project, 'distribution', $options); # spent 2.18s making 1991 calls to RBM::project_config, avg 1.10ms/call, recursion: max depth 52, sum of overlapping time 2.18s |
38 | 1991 | 1.22ms | if ($distribution) { | ||
39 | my ($id, $release) = split '-', $distribution; | ||||
40 | return { id => $id, release => $release }; | ||||
41 | } | ||||
42 | 1991 | 2.08ms | my $res = {}; | ||
43 | |||||
44 | 1991 | 64.9ms | 1991 | 41.7ms | if (-f '/usr/bin/sw_vers') { # spent 41.7ms making 1991 calls to RBM::DefaultConfig::CORE:ftfile, avg 21µs/call |
45 | # If sw_vers exists, we assume we are on OSX and use it | ||||
46 | my ($stdout, $stderr, $success, $exit_code) | ||||
47 | = capture_exec('/usr/bin/sw_vers', '-productName'); | ||||
48 | RBM::exit_error("sw_vers: unknown ProductName") | ||||
49 | unless $success; | ||||
50 | ($res->{id}) = split("\n", $stdout); | ||||
51 | ($stdout, $stderr, $success, $exit_code) | ||||
52 | = capture_exec('/usr/bin/sw_vers', '-productVersion'); | ||||
53 | RBM::exit_error("sw_vers: unknown ProductVersion") | ||||
54 | unless $success; | ||||
55 | ($res->{release}) = split("\n", $stdout); | ||||
56 | $res->{codename} = $res->{release}; | ||||
57 | return $res; | ||||
58 | } | ||||
59 | |||||
60 | 1991 | 15.3ms | 1991 | 128s | my ($stdout, $stderr, $success, $exit_code) # spent 128s making 1991 calls to IO::CaptureOutput::capture_exec, avg 64.1ms/call |
61 | = capture_exec('lsb_release', '-irc'); | ||||
62 | 1991 | 1.49ms | if ($success) { | ||
63 | 1991 | 12.8ms | foreach (split "\n", $stdout) { | ||
64 | 5973 | 86.7ms | 5973 | 30.4ms | $res->{id} = $1 if (m/^Distributor ID:\s+(.+)$/); # spent 30.4ms making 5973 calls to RBM::DefaultConfig::CORE:match, avg 5µs/call |
65 | 5973 | 52.0ms | 5973 | 7.85ms | $res->{release} = $1 if (m/^Release:\s+(.+)$/); # spent 7.85ms making 5973 calls to RBM::DefaultConfig::CORE:match, avg 1µs/call |
66 | 5973 | 48.0ms | 5973 | 6.85ms | $res->{codename} = $1 if (m/^Codename:\s+(.+)$/); # spent 6.85ms making 5973 calls to RBM::DefaultConfig::CORE:match, avg 1µs/call |
67 | } | ||||
68 | 1991 | 16.7ms | return $res; | ||
69 | } | ||||
70 | |||||
71 | ($stdout, $stderr, $success, $exit_code) | ||||
72 | = capture_exec('uname', '-s'); | ||||
73 | RBM::exit_error("Unknown OS") unless $success; | ||||
74 | ($res->{id}) = split("\n", $stdout); | ||||
75 | ($stdout, $stderr, $success, $exit_code) | ||||
76 | = capture_exec('uname', '-r'); | ||||
77 | RBM::exit_error("Unknown OS release") unless $success; | ||||
78 | ($res->{release}) = split("\n", $stdout); | ||||
79 | $res->{codename} = $res->{release}; | ||||
80 | return $res; | ||||
81 | } | ||||
82 | |||||
83 | sub get_arch { | ||||
84 | my ($stdout, $stderr, $success, $exit_code) = capture_exec('uname', '-m'); | ||||
85 | return "unknown" unless $success; | ||||
86 | chomp $stdout; | ||||
87 | return $stdout; | ||||
88 | } | ||||
89 | |||||
90 | sub docker_version { | ||||
91 | my ($stdout, $stderr, $success) | ||||
92 | = capture_exec('docker', 'version', '--format', '{{.Client.Version}}'); | ||||
93 | if ($success) { | ||||
94 | chomp $stdout; | ||||
95 | return $stdout; | ||||
96 | } | ||||
97 | ($stdout, $stderr, $success) = capture_exec('docker', 'version'); | ||||
98 | RBM::exit_error("Error running 'docker version'") unless $success; | ||||
99 | foreach my $line (split "\n", $stdout) { | ||||
100 | return $1 if ($line =~ m/Client version: (.*)$/); | ||||
101 | } | ||||
102 | RBM::exit_error("Could not find docker version"); | ||||
103 | } | ||||
104 | |||||
105 | # spent 5.70ms (663µs+5.04) within RBM::DefaultConfig::rbm_tmp_dir which was called 26 times, avg 219µs/call:
# 26 times (663µs+5.04ms) by RBM::config_p at line 94 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 219µs/call | ||||
106 | 26 | 78µs | my ($project, $options) = @_; | ||
107 | CORE::state $rbm_tmp_dir; | ||||
108 | 26 | 586µs | 50 | 440µs | return $rbm_tmp_dir->dirname if $rbm_tmp_dir; # spent 275µs making 25 calls to File::Temp::NUMIFY, avg 11µs/call
# spent 165µs making 25 calls to File::Temp::Dir::dirname, avg 7µs/call |
109 | 1 | 3µs | 1 | 4.23ms | my $tmp_dir = RBM::get_tmp_dir($project, $options) # spent 4.23ms making 1 call to RBM::get_tmp_dir |
110 | || RBM::exit_error('No tmp_dir specified'); | ||||
111 | 1 | 7µs | 1 | 360µs | $rbm_tmp_dir = File::Temp->newdir(TEMPLATE => 'rbm-XXXXXX', # spent 360µs making 1 call to File::Temp::newdir |
112 | DIR => $tmp_dir); | ||||
113 | 1 | 10µs | 1 | 2µs | return $rbm_tmp_dir->dirname; # spent 2µs making 1 call to File::Temp::Dir::dirname |
114 | } | ||||
115 | |||||
116 | our %default_config = ( | ||||
117 | sysconf_file => '/etc/rbm.conf', | ||||
118 | localconf_file=> 'rbm.local.conf', | ||||
119 | tmp_dir => '[% GET ENV.TMPDIR ? ENV.TMPDIR : "/tmp"; %]', | ||||
120 | rbm_tmp_dir => \&rbm_tmp_dir, | ||||
121 | projects_dir => 'projects', | ||||
122 | output_dir => 'out', | ||||
123 | git_clone_dir => 'git_clones', | ||||
124 | hg_clone_dir => 'hg_clones', | ||||
125 | fetch => 'if_needed', | ||||
126 | rpmspec => '[% SET tmpl = project _ ".spec"; INCLUDE $tmpl -%]', | ||||
127 | build => '[% INCLUDE build -%]', | ||||
128 | build_log => '-', | ||||
129 | build_log_append => '1', | ||||
130 | notmpl => [ qw(projects_dir) ], | ||||
131 | describe => \&git_describe, | ||||
132 | abbrev_length => '12', | ||||
133 | abbrev => '[% | ||||
134 | IF c("git_url"); | ||||
135 | exec("git log -1 --abbrev=" _ c("abbrev_length") _ " --format=%h " _ c("git_hash")); | ||||
136 | ELSE; | ||||
137 | exec(c("hg") _ " id -i -r " _ c("hg_hash")); | ||||
138 | END; | ||||
139 | %]', | ||||
140 | # spent 77.8s (55.9ms+77.7) within RBM::DefaultConfig::__ANON__[rbm/lib/RBM/DefaultConfig.pm:156] which was called 1992 times, avg 39.0ms/call:
# 1992 times (55.9ms+77.7s) by RBM::config_p at line 94 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 39.0ms/call | ||||
141 | 1992 | 13.8ms | my ($project, $options) = @_; | ||
142 | 1992 | 7.09ms | 2988 | 0s | if (RBM::project_config($project, 'git_url', $options)) { # spent 4.96s making 2988 calls to RBM::project_config, avg 1.66ms/call, recursion: max depth 51, sum of overlapping time 4.96s |
143 | 996 | 3.19ms | 996 | 0s | my $git_hash = RBM::project_config($project, 'git_hash', $options); # spent 2.62s making 996 calls to RBM::project_config, avg 2.63ms/call, recursion: max depth 48, sum of overlapping time 2.62s |
144 | 996 | 23.1ms | 996 | 70.1s | return RBM::execute($project, # spent 70.1s making 996 calls to RBM::execute, avg 70.4ms/call |
145 | "git show -s --format=format:%ct ${git_hash}^{commit}", $options); | ||||
146 | } elsif (RBM::project_config($project, 'hg_url', $options)) { | ||||
147 | my $hg = RBM::project_config($project, 'hg', $options); | ||||
148 | my $hg_hash = RBM::project_config($project, 'hg_hash', $options); | ||||
149 | my $changeset = RBM::execute($project, | ||||
150 | "$hg export --noninteractive -r $hg_hash", $options); | ||||
151 | foreach my $line (split "\n", $changeset) { | ||||
152 | return $1 if ($line =~ m/^# Date (\d+) \d+/); | ||||
153 | } | ||||
154 | } | ||||
155 | 996 | 22.9ms | return '946684800'; | ||
156 | }, | ||||
157 | debug => 0, | ||||
158 | version => <<END, | ||||
159 | [%- | ||||
160 | IF c('version_command'); | ||||
161 | exec(c('version_command')); | ||||
162 | ELSIF c(['describe', 'tag']); | ||||
163 | c(['describe', 'tag']); | ||||
164 | ELSE; | ||||
165 | exit_error('No version specified'); | ||||
166 | END; | ||||
167 | -%] | ||||
168 | END | ||||
169 | #### | ||||
170 | #### | ||||
171 | #### | ||||
172 | pkg_type => 'build', | ||||
173 | rpm => '[% c("rpmbuild", { rpmbuild_action => "-ba" }) %]', | ||||
174 | srpm => '[% c("rpmbuild", { rpmbuild_action => "-bs" }) %]', | ||||
175 | #### | ||||
176 | #### | ||||
177 | #### | ||||
178 | rpmbuild => <<END, | ||||
179 | [% USE date -%] | ||||
180 | #!/bin/sh | ||||
181 | set -e -x | ||||
182 | srcdir=\$(pwd) | ||||
183 | cat > '[% project %].spec' << 'RBM_END_RPM_SPEC' | ||||
184 | [% c('rpmspec') %] | ||||
185 | RBM_END_RPM_SPEC | ||||
186 | touch -m -t [% date.format(c('timestamp'), format = '%Y%m%d%H%M') %] [% project %].spec | ||||
187 | rpmbuild [% c('rpmbuild_action', {error_if_undef => 1}) %] --define "_topdir \$srcdir" \\ | ||||
188 | --define "_sourcedir \$srcdir" \\ | ||||
189 | --define '_srcrpmdir [% dest_dir %]' \\ | ||||
190 | --define '_rpmdir [% dest_dir %]' \\ | ||||
191 | --define '_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' \\ | ||||
192 | "\$srcdir/[% project %].spec" | ||||
193 | END | ||||
194 | #### | ||||
195 | #### | ||||
196 | #### | ||||
197 | rpm_rel => <<OPT_END, | ||||
198 | [%- | ||||
199 | IF c('pkg_rel').defined; | ||||
200 | GET c('pkg_rel'); | ||||
201 | ELSIF c('describe/tag_reach'); | ||||
202 | GET '1.' _ c('describe/tag_reach') _ '.g' _ c('describe/hash'); | ||||
203 | ELSE; | ||||
204 | GET '1.g' _ c('abbrev'); | ||||
205 | END; | ||||
206 | -%] | ||||
207 | OPT_END | ||||
208 | #### | ||||
209 | #### | ||||
210 | #### | ||||
211 | gpg_bin => 'gpg', | ||||
212 | gpg_args => '', | ||||
213 | gpg_keyring_dir => '[% config.basedir %]/keyring', | ||||
214 | gpg_wrapper => <<GPGEND, | ||||
215 | #!/bin/sh | ||||
216 | export LC_ALL=C | ||||
217 | [% | ||||
218 | IF c('gpg_keyring'); | ||||
219 | SET gpg_kr = '--keyring ' _ path(c('gpg_keyring'), path(c('gpg_keyring_dir'))) | ||||
220 | _ ' --no-default-keyring --no-auto-check-trustdb --trust-model always'; | ||||
221 | END; | ||||
222 | -%] | ||||
223 | exec [% c('gpg_bin') %] [% c('gpg_args') %] --with-fingerprint [% gpg_kr %] "\$@" | ||||
224 | GPGEND | ||||
225 | #### | ||||
226 | #### | ||||
227 | #### | ||||
228 | debian_create => <<DEBEND, | ||||
229 | [%- | ||||
230 | FOREACH f IN c('debian_files'); | ||||
231 | GET 'cat > ' _ tmpl(f.name) _ " << 'END_DEBIAN_FILE'\n"; | ||||
232 | GET tmpl(f.content); | ||||
233 | GET "\nEND_DEBIAN_FILE\n\n"; | ||||
234 | END; | ||||
235 | -%] | ||||
236 | DEBEND | ||||
237 | #### | ||||
238 | #### | ||||
239 | #### | ||||
240 | deb_src => <<DEBEND, | ||||
241 | #!/bin/sh | ||||
242 | set -e -x | ||||
243 | [% SET tarfile = project _ '-' _ c('version') _ '.tar.' _ c('compress_tar') -%] | ||||
244 | tar xvf [% tarfile %] | ||||
245 | mv [% tarfile %] [% dest_dir %]/[% project %]_[% c('version') %].orig.tar.[% c('compress_tar') %] | ||||
246 | cd [% project %]-[% c('version') %] | ||||
247 | builddir=\$(pwd) | ||||
248 | mkdir debian debian/source | ||||
249 | cd debian | ||||
250 | [% c('debian_create') %] | ||||
251 | cd [% dest_dir %] | ||||
252 | dpkg-source -b "\$builddir" | ||||
253 | DEBEND | ||||
254 | #### | ||||
255 | #### | ||||
256 | #### | ||||
257 | deb => <<DEBEND, | ||||
258 | #!/bin/sh | ||||
259 | set -e -x | ||||
260 | [% SET tarfile = project _ '-' _ c('version') _ '.tar.' _ c('compress_tar') -%] | ||||
261 | tar xvf [% tarfile %] | ||||
262 | mv [% tarfile %] [% project %]_[% c('version') %].orig.tar.[% c('compress_tar') %] | ||||
263 | cd [% project %]-[% c('version') %] | ||||
264 | builddir=\$(pwd) | ||||
265 | mkdir debian debian/source | ||||
266 | cd debian | ||||
267 | [% c('debian_create') %] | ||||
268 | cd .. | ||||
269 | ls .. | ||||
270 | [% IF c('debsign_keyid'); | ||||
271 | pdebuild_sign = '--debsign-k ' _ c('debsign_keyid'); | ||||
272 | debuild_sign = '-k' _ c('debsign_keyid'); | ||||
273 | ELSE; | ||||
274 | pdebuild_sign = ''; | ||||
275 | debuild_sign = '-uc -us'; | ||||
276 | END -%] | ||||
277 | [% IF c('use_pbuilder') -%] | ||||
278 | pdebuild [% pdebuild_sign %] --buildresult [% dest_dir %] | ||||
279 | [% ELSE -%] | ||||
280 | debuild [% debuild_sign %] | ||||
281 | cd .. | ||||
282 | rm -f build | ||||
283 | for file in * | ||||
284 | do | ||||
285 | if [ -f "\$file" ] | ||||
286 | then | ||||
287 | mv "\$file" [% dest_dir %] | ||||
288 | fi | ||||
289 | done | ||||
290 | [% END -%] | ||||
291 | DEBEND | ||||
292 | #### | ||||
293 | #### | ||||
294 | #### | ||||
295 | debian_revision => <<OPT_END, | ||||
296 | [%- | ||||
297 | IF c('pkg_rel'); | ||||
298 | GET c('pkg_rel').defined; | ||||
299 | ELSIF c('describe/tag_reach'); | ||||
300 | GET '1.' _ c('describe/tag_reach') _ '~g' _ c('describe/hash'); | ||||
301 | ELSE; | ||||
302 | GET '1'; | ||||
303 | END; | ||||
304 | -%] | ||||
305 | OPT_END | ||||
306 | #### | ||||
307 | #### | ||||
308 | #### | ||||
309 | ssh_remote_exec => <<OPT_END, | ||||
310 | [%- | ||||
311 | ssh_user = c('exec_as_root') ? '-l root' : ''; | ||||
312 | -%] | ||||
313 | ssh [% GET c('ssh_options') IF c('ssh_options') %] [% ssh_user %] [% GET '-p ' _ c('ssh_port') IF c('ssh_port') %] [% c('ssh_host') %] [% shell_quote(c('exec_cmd')) -%] | ||||
314 | OPT_END | ||||
315 | #### | ||||
316 | #### | ||||
317 | #### | ||||
318 | chroot_remote_exec => <<OPT_END, | ||||
319 | [%- | ||||
320 | chroot_user = c('exec_as_root') ? '' : shell_quote(c("chroot_user", { error_if_undef => 1 })); | ||||
321 | -%] | ||||
322 | sudo -- chroot [% shell_quote(c("chroot_path", { error_if_undef => 1 })) %] su - [% chroot_user %] -c [% shell_quote(c("exec_cmd")) -%] | ||||
323 | OPT_END | ||||
324 | #### | ||||
325 | #### | ||||
326 | #### | ||||
327 | remote_exec => <<OPT_END, | ||||
328 | [% | ||||
329 | IF c('remote_docker'); | ||||
330 | GET c('docker_remote_exec'); | ||||
331 | RETURN; | ||||
332 | END; | ||||
333 | IF c('remote_ssh'); | ||||
334 | GET c('ssh_remote_exec'); | ||||
335 | RETURN; | ||||
336 | END; | ||||
337 | IF c('remote_chroot'); | ||||
338 | GET c('chroot_remote_exec'); | ||||
339 | RETURN; | ||||
340 | END; | ||||
341 | -%] | ||||
342 | OPT_END | ||||
343 | #### | ||||
344 | #### | ||||
345 | #### | ||||
346 | remote_get => <<OPT_END, | ||||
347 | [% | ||||
348 | IF c('remote_docker'); | ||||
349 | GET c('docker_remote_get'); | ||||
350 | RETURN; | ||||
351 | END; | ||||
352 | |||||
353 | SET src = shell_quote(c('get_src', { error_if_undef => 1 })); | ||||
354 | SET dst = shell_quote(c('get_dst', { error_if_undef => 1 })); | ||||
355 | -%] | ||||
356 | #!/bin/sh | ||||
357 | set -e | ||||
358 | mkdir -p [% dst %] | ||||
359 | cd [% dst %] | ||||
360 | if [% c('remote_exec', { exec_cmd => 'test -f ' _ src }) %] | ||||
361 | then | ||||
362 | [% c('remote_exec', { exec_cmd => 'cd \$(dirname ' _ src _ ') && tar -cf - \$(basename ' _ src _ ')' }) %] | tar -xf - | ||||
363 | else | ||||
364 | [% c('remote_exec', { exec_cmd => 'cd ' _ src _ ' && tar -cf - .' }) %] | tar -xf - | ||||
365 | fi | ||||
366 | OPT_END | ||||
367 | #### | ||||
368 | #### | ||||
369 | #### | ||||
370 | remote_put => <<OPT_END, | ||||
371 | [% | ||||
372 | IF c('remote_docker'); | ||||
373 | GET c('docker_remote_put'); | ||||
374 | RETURN; | ||||
375 | END; | ||||
376 | |||||
377 | SET src = shell_quote(c('put_src', { error_if_undef => 1 })); | ||||
378 | SET dst = shell_quote(c('put_dst', { error_if_undef => 1 })); | ||||
379 | -%] | ||||
380 | #!/bin/sh | ||||
381 | set -e | ||||
382 | if [ -f [% src %] ] | ||||
383 | then | ||||
384 | cd \$(dirname [% src %]) | ||||
385 | tar -cf - \$(basename [% src %]) | [% c('remote_exec', { exec_cmd => 'mkdir -p ' _ dst _ '&& cd ' _ dst _ '&& tar -xf -' }) %] | ||||
386 | else | ||||
387 | cd [% src %] | ||||
388 | tar -cf . | [% c('remote_exec', { exec_cmd => 'mkdir -p' _ dst _ '&& cd ' _ dst _ '&& tar -xf -' }) %] | ||||
389 | fi | ||||
390 | |||||
391 | OPT_END | ||||
392 | #### | ||||
393 | #### | ||||
394 | #### | ||||
395 | remote_start => <<OPT_END, | ||||
396 | [% | ||||
397 | IF c('remote_docker'); | ||||
398 | GET c('docker_remote_start'); | ||||
399 | RETURN; | ||||
400 | END; | ||||
401 | -%] | ||||
402 | OPT_END | ||||
403 | #### | ||||
404 | #### | ||||
405 | #### | ||||
406 | remote_finish => <<OPT_END, | ||||
407 | [% | ||||
408 | IF c('remote_docker'); | ||||
409 | GET c('docker_remote_finish'); | ||||
410 | RETURN; | ||||
411 | END; | ||||
412 | -%] | ||||
413 | OPT_END | ||||
414 | #### | ||||
415 | #### | ||||
416 | #### | ||||
417 | docker_version => \&docker_version, | ||||
418 | #### | ||||
419 | #### | ||||
420 | #### | ||||
421 | docker_build_image => 'rbm-[% sha256(c("build_id")).substr(0, 12) %]', | ||||
422 | #### | ||||
423 | #### | ||||
424 | #### | ||||
425 | docker_remote_start => <<OPT_END, | ||||
426 | #!/bin/sh | ||||
427 | set -e | ||||
428 | ciddir=\$(mktemp -d) | ||||
429 | cidfile="\$ciddir/cid" | ||||
430 | [% | ||||
431 | SET user=c('docker_user'); | ||||
432 | SET cmd = '/bin/sh -c ' _ shell_quote("id \$user >/dev/null 2>&1 || adduser -m \$user || useradd -m \$user"); | ||||
433 | -%] | ||||
434 | docker run --cidfile="\$cidfile" [% c("docker_opt") %] [% shell_quote(c('docker_image', {error_if_undef => 1})) %] [% cmd %] | ||||
435 | cid=\$(cat \$cidfile) | ||||
436 | rm -rf "\$ciddir" | ||||
437 | docker commit \$cid [% c('docker_build_image') %] > /dev/null < /dev/null | ||||
438 | docker rm -f \$cid > /dev/null | ||||
439 | OPT_END | ||||
440 | #### | ||||
441 | #### | ||||
442 | #### | ||||
443 | docker_remote_finish => <<OPT_END, | ||||
444 | #!/bin/sh | ||||
445 | set -e | ||||
446 | [% IF c('docker_save_image') -%] | ||||
447 | docker tag [% IF versioncmp(c('docker_version'), '1.10.0') == -1; GET '-f'; END; %] [% c('docker_build_image') %] [% c('docker_save_image') %] | ||||
448 | [% END -%] | ||||
449 | docker rmi -f [% c('docker_build_image') %] > /dev/null | ||||
450 | OPT_END | ||||
451 | #### | ||||
452 | #### | ||||
453 | #### | ||||
454 | docker_user => 'rbm', | ||||
455 | #### | ||||
456 | #### | ||||
457 | #### | ||||
458 | docker_remote_exec => <<OPT_END, | ||||
459 | #!/bin/sh | ||||
460 | set -e | ||||
461 | ciddir=\$(mktemp -d) | ||||
462 | cidfile="\$ciddir/cid" | ||||
463 | set +e | ||||
464 | docker run [% IF c('interactive') %]-i -t[% END %] \\ | ||||
465 | [% IF c('exec_as_root') %]-u=root[% | ||||
466 | ELSE %]-u=[% shell_quote(c('docker_user')) %][% END %] \\ | ||||
467 | --cidfile="\$cidfile" [% c("docker_opt") %] [% c('docker_build_image') %] \\ | ||||
468 | /bin/sh -c [% shell_quote(c('exec_cmd')) %] | ||||
469 | ret=\$? | ||||
470 | set -e | ||||
471 | cid=\$(cat \$cidfile) | ||||
472 | rm -rf "\$ciddir" | ||||
473 | docker commit \$cid [% c('docker_build_image') %] > /dev/null < /dev/null | ||||
474 | docker rm -f \$cid > /dev/null | ||||
475 | test \$ret -eq 0 | ||||
476 | OPT_END | ||||
477 | #### | ||||
478 | #### | ||||
479 | #### | ||||
480 | docker_remote_put => <<OPT_END, | ||||
481 | [% | ||||
482 | SET src = c('put_src', { error_if_undef => 1 }); | ||||
483 | SET dst = c('put_dst', { error_if_undef => 1 }); | ||||
484 | SET p = fileparse(src); | ||||
485 | SET src_filename = shell_quote(p.0); | ||||
486 | SET src_dir = shell_quote(p.1); | ||||
487 | SET dst = shell_quote(dst); | ||||
488 | GET c("docker_remote_exec", { docker_opt => '-v ' _ src_dir _ ':/rbm_copy', | ||||
489 | exec_as_root => 1, | ||||
490 | exec_cmd => 'su ' _ c('docker_user') _ " -c 'mkdir -p " _ dst _ "';" | ||||
491 | _ 'cp -ar /rbm_copy/' _ src_filename _ ' ' _ dst | ||||
492 | _ '; chown -h ' _ c('docker_user') _ ' ' _ dst _ '/' _ src_filename | ||||
493 | _ '; chown ' _ c('docker_user') _ ' ' _ dst }); | ||||
494 | %] | ||||
495 | OPT_END | ||||
496 | #### | ||||
497 | #### | ||||
498 | #### | ||||
499 | uid => $>, | ||||
500 | docker_remote_get => <<OPT_END, | ||||
501 | [% | ||||
502 | SET src = c('get_src', { error_if_undef => 1 }); | ||||
503 | SET dst = c('get_dst', { error_if_undef => 1 }); | ||||
504 | -%] | ||||
505 | #!/bin/sh | ||||
506 | set -e | ||||
507 | tmpdir=\$(mktemp -d) | ||||
508 | [% | ||||
509 | GET c("docker_remote_exec", { docker_opt => '-v \$tmpdir:/rbm_copy', | ||||
510 | exec_as_root => 1, | ||||
511 | exec_cmd => 'cd ' _ src _ '; tar -cf - . | tar -C /rbm_copy -xf -; chown -R ' _ c('uid') _ ' /rbm_copy'}); | ||||
512 | %] | ||||
513 | cd \$tmpdir | ||||
514 | tar -cf - . | tar -C [% dst %] --no-same-owner -xf - | ||||
515 | cd - > /dev/null | ||||
516 | rm -Rf \$tmpdir | ||||
517 | OPT_END | ||||
518 | #### | ||||
519 | #### | ||||
520 | #### | ||||
521 | lsb_release => \&lsb_release, | ||||
522 | pkg_type => sub { | ||||
523 | my ($project, $options) = @_; | ||||
524 | my $distro = RBM::project_config($project, 'lsb_release/id', $options); | ||||
525 | my %pkg_types = qw( | ||||
526 | Fedora rpm | ||||
527 | CentOS rpm | ||||
528 | Mageia rpm | ||||
529 | openSuSe rpm | ||||
530 | Debian deb | ||||
531 | Ubuntu deb | ||||
532 | ); | ||||
533 | return $pkg_types{$distro}; | ||||
534 | }, | ||||
535 | # spent 312s (938ms+311) within RBM::DefaultConfig::__ANON__[rbm/lib/RBM/DefaultConfig.pm:557] which was called 19910 times, avg 15.7ms/call:
# 19910 times (938ms+311s) by RBM::config_p at line 94 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 15.7ms/call | ||||
536 | 19910 | 14.9ms | my ($project, $options) = @_; | ||
537 | 19910 | 74.1ms | 19910 | 0s | my $distro = RBM::project_config($project, 'lsb_release/id', $options); # spent 156s making 19910 calls to RBM::project_config, avg 7.85ms/call, recursion: max depth 52, sum of overlapping time 156s |
538 | 19910 | 76.0ms | 19910 | 0s | my $release = RBM::project_config($project, 'lsb_release/release', $options); # spent 155s making 19910 calls to RBM::project_config, avg 7.79ms/call, recursion: max depth 52, sum of overlapping time 155s |
539 | 19910 | 31.2ms | my $yum = 'rpm -q [% c("pkg_name") %] > /dev/null || yum install -y [% c("pkg_name") %]'; | ||
540 | 19910 | 15.1ms | my $dnf = 'rpm -q [% c("pkg_name") %] > /dev/null || dnf install -y [% c("pkg_name") %]'; | ||
541 | 19910 | 12.4ms | my $zypper = 'rpm -q [% c("pkg_name") %] > /dev/null || zypper install [% c("pkg_name") %]'; | ||
542 | 19910 | 16.0ms | my $urpmi = 'rpm -q [% c("pkg_name") %] > /dev/null || urpmi [% c("pkg_name") %]'; | ||
543 | 19910 | 16.7ms | my $apt = 'dpkg -s [% c("pkg_name") %] 2> /dev/null | grep -q "^Status: install ok installed\$" || DEBIAN_FRONTEND=noninteractive apt-get install -q -y [% c("pkg_name") %]'; | ||
544 | 19910 | 175ms | my %install = ( | ||
545 | Fedora => $dnf, | ||||
546 | 'Fedora-20' => $yum, | ||||
547 | 'Fedora-21' => $yum, | ||||
548 | CentOS => $dnf, | ||||
549 | Mageia => $urpmi, | ||||
550 | openSuSe => $zypper, | ||||
551 | Debian => $apt, | ||||
552 | Ubuntu => $apt, | ||||
553 | ); | ||||
554 | 19910 | 185ms | 19910 | 32.0ms | return $yum if "$distro-$release" =~ m/^Centos-[56]\./; # spent 32.0ms making 19910 calls to RBM::DefaultConfig::CORE:match, avg 2µs/call |
555 | 19910 | 36.4ms | return $install{"$distro-$release"} if $install{"$distro-$release"}; | ||
556 | 19910 | 212ms | return $install{$distro}; | ||
557 | }, | ||||
558 | urlget => <<URLGET, | ||||
559 | #!/bin/sh | ||||
560 | set -e | ||||
561 | tmpfile="\$(mktemp -p [% shell_quote(c("tmp_dir")) %])" | ||||
562 | wget -O"\$tmpfile" [% shell_quote(c("URL")) %] | ||||
563 | mv -f "\$tmpfile" [% shell_quote(dest_dir _ "/" _ c("filename")) %] | ||||
564 | URLGET | ||||
565 | sig_ext => [ qw(gpg asc sig) ], | ||||
566 | enable => 1, | ||||
567 | # spent 137s (75.2ms+137) within RBM::DefaultConfig::__ANON__[rbm/lib/RBM/DefaultConfig.pm:578] which was called 1991 times, avg 69.0ms/call:
# 1991 times (75.2ms+137s) by RBM::config_p at line 94 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 69.0ms/call | ||||
568 | 1991 | 11.1ms | my ($project, $options) = @_; | ||
569 | 1991 | 7.39ms | 1991 | 0s | my $distro = RBM::project_config($project, 'lsb_release/id', $options); # spent 137s making 1991 calls to RBM::project_config, avg 68.9ms/call, recursion: max depth 51, sum of overlapping time 137s |
570 | 1991 | 29.6ms | my %non_gnu = ( | ||
571 | 'Mac OS X' => 1, | ||||
572 | NetBSD => 1, | ||||
573 | OpenBSD => 1, | ||||
574 | FreeBSD => 1, | ||||
575 | DragonFly => 1, | ||||
576 | ); | ||||
577 | 1991 | 16.4ms | return ! $non_gnu{$distro}; | ||
578 | }, | ||||
579 | tar => <<TAR_END, | ||||
580 | [%- SET src = c('tar_src', { error_if_undef => 1 }) -%] | ||||
581 | find [% src.join(' ') %] [% IF c('gnu_utils') %]-executable[% ELSE %]-perm +0111[% END %] -exec chmod 700 {} \\; | ||||
582 | find [% src.join(' ') %] ! [% IF c('gnu_utils') %]-executable[% ELSE %]-perm +0111[% END %] -exec chmod 600 {} \\; | ||||
583 | find [% src.join(' ') %] | sort | \ | ||||
584 | GZIP="--no-name \${GZIP}" tar --no-recursion [% IF c('gnu_utils') -%] | ||||
585 | --owner=root --group=root --mtime=@[% c('timestamp') %] | ||||
586 | [%- END -%] | ||||
587 | [% c('tar_args', { error_if_undef => 1 }) %] -T - | ||||
588 | TAR_END | ||||
589 | #### | ||||
590 | #### | ||||
591 | #### | ||||
592 | zip => <<ZIP_END, | ||||
593 | [%- SET src = c('zip_src', { error_if_undef => 1 }) -%] | ||||
594 | [% USE date -%] | ||||
595 | find [% src.join(' ') %] -exec touch -m -t [% date.format(c('timestamp'), format = '%Y%m%d%H%M') %] -- {} + | ||||
596 | find [% src.join(' ') %] [% IF c('gnu_utils') %]-executable[% ELSE %]-perm +0111[% END %] -exec chmod 700 {} \\; | ||||
597 | find [% src.join(' ') %] ! [% IF c('gnu_utils') %]-executable[% ELSE %]-perm +0111[% END %] -exec chmod 600 {} \\; | ||||
598 | find [% src.join(' ') %] | sort | \ | ||||
599 | zip -q -@ -X [% c('zip_args', { error_if_undef => 1 }) %] | ||||
600 | ZIP_END | ||||
601 | #### | ||||
602 | #### | ||||
603 | #### | ||||
604 | arch => \&get_arch, | ||||
605 | 3976 | 52.5ms | 3976 | 2.42s | # spent 147s (39.8ms+147) within RBM::DefaultConfig::__ANON__[rbm/lib/RBM/DefaultConfig.pm:605] which was called 3976 times, avg 37.0ms/call:
# 3976 times (39.8ms+147s) by RBM::config_p at line 94 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 37.0ms/call # spent 147s making 3976 calls to RBM::input_files, avg 37.0ms/call, recursion: max depth 11, sum of overlapping time 145s |
606 | 1990 | 19.5ms | 1990 | 1475s | # spent 2119s (26.8ms+2119) within RBM::DefaultConfig::__ANON__[rbm/lib/RBM/DefaultConfig.pm:606] which was called 1990 times, avg 1.06s/call:
# 1990 times (26.8ms+2119s) by RBM::config_p at line 94 of /root/tor-browser-build/rbm/lib/RBM.pm, avg 1.06s/call # spent 10962s making 1990 calls to RBM::input_files, avg 5.51s/call, recursion: max depth 11, sum of overlapping time 9486s |
607 | input_files_paths => sub { RBM::input_files('getfpaths', @_); }, | ||||
608 | 1 | 185µs | steps => { | ||
609 | srpm => 'rpm', | ||||
610 | 'deb-src' => 'deb', | ||||
611 | }, | ||||
612 | suexec => 'sudo -- [% c("suexec_cmd") %]', | ||||
613 | hg => 'hg [% c("hg_opt") %]', | ||||
614 | ); | ||||
615 | |||||
616 | 1 | 16µs | 1; | ||
617 | # vim: expandtab sw=4 | ||||
# spent 41.7ms within RBM::DefaultConfig::CORE:ftfile which was called 1991 times, avg 21µs/call:
# 1991 times (41.7ms+0s) by RBM::DefaultConfig::lsb_release at line 44, avg 21µs/call | |||||
# spent 77.2ms within RBM::DefaultConfig::CORE:match which was called 37829 times, avg 2µs/call:
# 19910 times (32.0ms+0s) by RBM::DefaultConfig::__ANON__[rbm/lib/RBM/DefaultConfig.pm:557] at line 554, avg 2µs/call
# 5973 times (30.4ms+0s) by RBM::DefaultConfig::lsb_release at line 64, avg 5µs/call
# 5973 times (7.85ms+0s) by RBM::DefaultConfig::lsb_release at line 65, avg 1µs/call
# 5973 times (6.85ms+0s) by RBM::DefaultConfig::lsb_release at line 66, avg 1µs/call | |||||
# spent 700ns within RBM::DefaultConfig::__ANON__ which was called:
# once (700ns+0s) by RBM::DefaultConfig::BEGIN@13 at line 13 |