| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Run::Parts; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Offers functionality of Debian's run-parts tool in Perl |
|
4
|
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
314910
|
use Modern::Perl; |
|
|
5
|
|
|
|
|
4
|
|
|
|
5
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
1250
|
use File::Slurp 9999.17; |
|
|
5
|
|
|
|
|
24562
|
|
|
|
5
|
|
|
|
|
215
|
|
|
8
|
5
|
|
|
5
|
|
929
|
use Run::Parts::Common; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
485
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.06_90'; # VERSION generated by DZP::OurPkgVersion |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
|
14
|
10
|
|
|
10
|
1
|
4893
|
my $self = {}; |
|
15
|
10
|
|
|
|
|
30
|
bless($self, shift); |
|
16
|
10
|
|
|
|
|
35
|
$self->{dir} = shift; |
|
17
|
|
|
|
|
|
|
|
|
18
|
10
|
|
|
|
|
16
|
my $backend = shift; |
|
19
|
10
|
100
|
|
|
|
29
|
if (defined $backend) { |
|
20
|
8
|
100
|
100
|
|
|
82
|
if (ref $backend) { |
|
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
7
|
$self->{backend} = ref($backend)->new($self->{dir}); |
|
22
|
|
|
|
|
|
|
} elsif ($backend eq 'debian' or $backend eq 'run-parts') { |
|
23
|
5
|
|
|
5
|
|
995
|
use Run::Parts::Debian; |
|
|
5
|
|
|
|
|
5
|
|
|
|
5
|
|
|
|
|
194
|
|
|
24
|
3
|
|
|
|
|
14
|
$self->{backend} = Run::Parts::Debian->new($self->{dir}); |
|
25
|
|
|
|
|
|
|
} elsif ($backend eq 'perl' or $backend eq 'module') { |
|
26
|
5
|
|
|
5
|
|
979
|
use Run::Parts::Perl; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
1044
|
|
|
27
|
3
|
|
|
|
|
21
|
$self->{backend} = Run::Parts::Perl->new($self->{dir}); |
|
28
|
|
|
|
|
|
|
} else { |
|
29
|
1
|
|
|
|
|
8
|
warn "Unknown backend $backend in use"; |
|
30
|
1
|
|
|
|
|
45
|
require $backend; |
|
31
|
|
|
|
|
|
|
# uncoverable statement |
|
32
|
0
|
|
|
|
|
0
|
$self->{backend} = $backend->new($self->{dir}); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} else { |
|
35
|
|
|
|
|
|
|
# uncoverable branch false |
|
36
|
2
|
50
|
|
|
|
21
|
if (-x '/bin/run-parts') { |
|
37
|
2
|
|
|
|
|
13
|
$self->{backend} = Run::Parts::Debian->new($self->{dir}); |
|
38
|
|
|
|
|
|
|
} else { |
|
39
|
|
|
|
|
|
|
# uncoverable statement |
|
40
|
0
|
|
|
|
|
0
|
$self->{backend} = Run::Parts::Perl->new($self->{dir}); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
9
|
|
|
|
|
16
|
return $self; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub run_parts_command { |
|
49
|
52
|
|
|
52
|
1
|
82
|
my $self = shift; |
|
50
|
52
|
|
|
|
|
189
|
return $self->{backend}->run_parts_command(@_); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub list { |
|
55
|
28
|
|
|
28
|
1
|
3894
|
my $self = shift; |
|
56
|
28
|
|
|
|
|
63
|
return $self->run_parts_command('list'); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub test { |
|
61
|
16
|
|
|
16
|
1
|
2129
|
my $self = shift; |
|
62
|
16
|
|
|
|
|
33
|
return $self->run_parts_command('test'); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub run { |
|
67
|
8
|
|
|
8
|
1
|
17
|
my $self = shift; |
|
68
|
8
|
|
|
|
|
17
|
return $self->run_parts_command(); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub concat { |
|
73
|
12
|
|
|
12
|
1
|
20
|
my $self = shift; |
|
74
|
12
|
|
|
|
|
19
|
return lines(map { read_file($_, { chomp => 1 }) } $self->list()); |
|
|
48
|
|
|
|
|
2045
|
|
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
42; # End of Run::Parts |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding UTF-8 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Run::Parts - Offers functionality of Debian's run-parts tool in Perl |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 VERSION |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
version 0.06_90 |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Run::Parts offers functionality of Debian's L<run-parts(8)> tool in |
|
97
|
|
|
|
|
|
|
Perl. |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
run-parts runs all the executable files named within constraints |
|
100
|
|
|
|
|
|
|
described in L<run-parts(8)> and L<Run::Parts::Perl>, found |
|
101
|
|
|
|
|
|
|
in the given directory. Other files and directories are silently |
|
102
|
|
|
|
|
|
|
ignored. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Additionally it can just print the names of the all matching files |
|
105
|
|
|
|
|
|
|
(not limited to executables, but ignores blacklisted files like |
|
106
|
|
|
|
|
|
|
e.g. backup files), but don't actually run them. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This is useful when functionality or configuration is split over |
|
109
|
|
|
|
|
|
|
multiple files in one directory. A typical convention is that the |
|
110
|
|
|
|
|
|
|
directory name ends in ".d". Common examples for such split |
|
111
|
|
|
|
|
|
|
configuration directories: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
/etc/cron.d/ |
|
114
|
|
|
|
|
|
|
/etc/apt/apt.conf.d/ |
|
115
|
|
|
|
|
|
|
/etc/apt/sources.list.d/, |
|
116
|
|
|
|
|
|
|
/etc/aptitude-robot/pkglist.d/ |
|
117
|
|
|
|
|
|
|
/etc/logrotate.d/ |
|
118
|
|
|
|
|
|
|
/etc/rsyslog.d/ |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Perhaps a little code snippet. |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
use Run::Parts; |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $rp = Run::Parts->new('directory'); # chooses backend automatically |
|
125
|
|
|
|
|
|
|
my $rpp = Run::Parts->new('directory', 'perl'); # pure perl backend |
|
126
|
|
|
|
|
|
|
my $rpd = Run::Parts->new('directory', 'debian'); # uses /bin/run-parts |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
my @file_list = $rp->list; |
|
129
|
|
|
|
|
|
|
my @executables_list = $rpp->test; |
|
130
|
|
|
|
|
|
|
my $commands_output = $rpd->run; |
|
131
|
|
|
|
|
|
|
... |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=begin readme |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 INSTALLATION |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
To install this module, run the following commands: |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
perl Build.PL |
|
140
|
|
|
|
|
|
|
./Build |
|
141
|
|
|
|
|
|
|
./Build test |
|
142
|
|
|
|
|
|
|
./Build install |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=end readme |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 BACKENDS |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L<Run::Parts> contains two backend implementations. |
|
149
|
|
|
|
|
|
|
L<Run::Parts::Debian> actually uses /bin/run-parts and |
|
150
|
|
|
|
|
|
|
L<Run::Parts::Perl> is a pure Perl implementation of a basic set of |
|
151
|
|
|
|
|
|
|
L<run-parts(8)>' functionality. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L<Run::Parts::Debian> may or may not work with RedHat's simplified |
|
154
|
|
|
|
|
|
|
shell-script based reimplementation of Debian's L<run-parts(8)>. |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
By default L<Run::Parts> uses L<Run::Parts::Debian> if /bin/run-parts |
|
157
|
|
|
|
|
|
|
exists, L<Run::Parts::Perl> otherwise. But you can also choose any of |
|
158
|
|
|
|
|
|
|
the backends explicitly. |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=for readme stop |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 METHODS |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 new (Constructor) |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Creates a new L<Run::Parts> object. Takes one parameter, the directory |
|
167
|
|
|
|
|
|
|
on which run-parts should work. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 run_parts_command |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns the L<run-parts(8)> command to run with the given command |
|
172
|
|
|
|
|
|
|
parameter. |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 list |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Lists all relevant files in the given directory. Equivalent to |
|
177
|
|
|
|
|
|
|
"run-parts --list". |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 test |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Lists all relevant executables in the given directory. Equivalent to |
|
182
|
|
|
|
|
|
|
"run-parts --test". |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 run |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
Runs all relevant executables in the given directory. Equivalent to |
|
187
|
|
|
|
|
|
|
"run-parts". |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 concat |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Returns the concatenated contents of all relevant files in the given |
|
192
|
|
|
|
|
|
|
directory. Equivalent to "cat `run-parts --list`". |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=for readme continue |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
L<run-parts(8)>, L<Run::Parts::Debian>, L<Run::Parts::Perl> |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 BUGS |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-run-parts at |
|
203
|
|
|
|
|
|
|
rt.cpan.org>, or through the web interface at |
|
204
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Run-Parts>. I will |
|
205
|
|
|
|
|
|
|
be notified, and then you'll automatically be notified of progress on |
|
206
|
|
|
|
|
|
|
your bug as I make changes. |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 CODE |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
You can find a git repository of Run::Parts' code at |
|
211
|
|
|
|
|
|
|
L<https://github.com/xtaran/run-parts>. |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 SUPPORT |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=begin readme |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
perldoc Run::Parts |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
You can also look for information at: |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=end readme |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over 4 |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Run-Parts> |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Run-Parts> |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Run-Parts> |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item * Search CPAN |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Run-Parts/> |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=back |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 AUTHOR |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Axel Beckert <abe@deuxchevaux.org> |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Axel Beckert. |
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
255
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=cut |