line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PkgForge::App::Submit; # -*-perl-*- |
2
|
1
|
|
|
1
|
|
2637
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
60
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# $Id: Submit.pm.in 16544 2011-03-31 16:25:38Z squinney@INF.ED.AC.UK $ |
6
|
|
|
|
|
|
|
# $Source:$ |
7
|
|
|
|
|
|
|
# $Revision: 16544 $ |
8
|
|
|
|
|
|
|
# $HeadURL: https://svn.lcfg.org/svn/source/tags/PkgForge/PkgForge_1_4_8/lib/PkgForge/App/Submit.pm.in $ |
9
|
|
|
|
|
|
|
# $Date: 2011-03-31 17:25:38 +0100 (Thu, 31 Mar 2011) $ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.4.8'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use English qw(-no_match_vars); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
11
|
|
14
|
1
|
|
|
1
|
|
520
|
use File::HomeDir (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
15
|
1
|
|
|
1
|
|
5
|
use File::Spec (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
16
|
1
|
|
|
1
|
|
6
|
use PkgForge::SourceUtils (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
430
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use MooseX::Types::Moose qw(Str); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
extends qw(PkgForge::Job PkgForge::App); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'target' => ( |
24
|
|
|
|
|
|
|
is => 'ro', |
25
|
|
|
|
|
|
|
isa => Str, |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
documentation => 'Location into which jobs should be submitted', |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has '+directory' => ( |
31
|
|
|
|
|
|
|
traits => ['NoGetopt'], |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has '+yamlfile' => ( |
35
|
|
|
|
|
|
|
traits => ['NoGetopt'], |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has '+packages' => ( |
39
|
|
|
|
|
|
|
traits => ['NoGetopt'], |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has '+size' => ( |
43
|
|
|
|
|
|
|
traits => ['NoGetopt'], |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
has '+submitter' => ( |
47
|
|
|
|
|
|
|
traits => ['NoGetopt'], |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has '+subtime' => ( |
51
|
|
|
|
|
|
|
traits => ['NoGetopt'], |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
no Moose; |
55
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub abstract { return q{Submit a set of source packages for building}; } |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub submit { |
60
|
|
|
|
|
|
|
my ($self) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# We assume that the target is a directory in this simple case. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $target = $self->target; |
65
|
|
|
|
|
|
|
if ( !-d $target ) { |
66
|
|
|
|
|
|
|
die "Cannot find build job submission directory $target\n"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $new_obj = eval { $self->transfer($target) }; |
70
|
|
|
|
|
|
|
if ( !defined $new_obj || $EVAL_ERROR ) { |
71
|
|
|
|
|
|
|
die "Job submission failed: $EVAL_ERROR\n"; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return $new_obj->id; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub include_packages { |
78
|
|
|
|
|
|
|
my ( $self, @packages ) = @_; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
if ( scalar @packages == 0 ) { |
81
|
|
|
|
|
|
|
die "No packages specified, nothing to do.\n"; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my @build; |
85
|
|
|
|
|
|
|
for my $package (@packages) { |
86
|
|
|
|
|
|
|
if ( !-f $package ) { |
87
|
|
|
|
|
|
|
die "The file '$package' does not exist\n"; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $module = PkgForge::SourceUtils::find_handler($package); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
if ( !defined $module ) { |
93
|
|
|
|
|
|
|
die "Unsupported package type for $package, is it really a source package?\n"; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $pkg = $module->new($package); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
if ( $pkg->validate() ) { |
99
|
|
|
|
|
|
|
push @build, $pkg; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
|
|
|
|
|
|
die "$package is not a valid source package\n"; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return $self->add_packages(@build); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub execute { |
110
|
|
|
|
|
|
|
my ( $self, $opt, $args ) = @_; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my @packages = @{ $args }; |
113
|
|
|
|
|
|
|
$self->include_packages(@packages); |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $id = $self->submit(); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
if ( defined $id ) { |
118
|
|
|
|
|
|
|
my $pkg_count = scalar @packages; |
119
|
|
|
|
|
|
|
print "Successfully submitted $pkg_count packages as build job $id\n"; |
120
|
|
|
|
|
|
|
if ( $self->has_website && $self->website ) { |
121
|
|
|
|
|
|
|
print 'You can follow the progress at ' . $self->website . "\n"; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
} else { |
124
|
|
|
|
|
|
|
die "Failed to submit job\n"; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
return; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
__END__ |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 NAME |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
PkgForge::App::Submit - Package Forge application for submitting build jobs |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 VERSION |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
This documentation refers to PkgForge::App::Submit version 1.4.8 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 USAGE |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
% pkgforge submit --bucket devel foo-1-2.src.rpm bar-3-4.src.rpm |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
% pkgforge submit --bucket devel \ |
146
|
|
|
|
|
|
|
--archs '!x86_64' foobar-1-2.src.rpm |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
% pkgforge submit --bucket lcfg \ |
149
|
|
|
|
|
|
|
--platforms 'f13,sl5' foobar-1-2.src.rpm |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 DESCRIPTION |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This is a simple command-line tool for submitting jobs for the Package |
154
|
|
|
|
|
|
|
Forge software suite. This module relies on being able to do a simple |
155
|
|
|
|
|
|
|
copy of the necessary files from one location in the filesystem to |
156
|
|
|
|
|
|
|
another. This means you must be either using a networked filesystem, |
157
|
|
|
|
|
|
|
such as AFS or NFS, to allow remote submissions or requiring users to |
158
|
|
|
|
|
|
|
submit their jobs from the Package Forge master node. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
A build job may consist of multiple source packages, you must supply |
161
|
|
|
|
|
|
|
at least one valid source package. When multiple source packages are |
162
|
|
|
|
|
|
|
provided they will be built in the order they are specified. On some |
163
|
|
|
|
|
|
|
platforms, e.g. Redhat/Fedora where mock(1) is used, a build failure |
164
|
|
|
|
|
|
|
in one package does not result in the whole job failing |
165
|
|
|
|
|
|
|
immediately. Failed packages will be put to the end of the queue in |
166
|
|
|
|
|
|
|
the hope that the failure was down to missing dependencies which can |
167
|
|
|
|
|
|
|
be satisfied by building later packages in the build job. As long as |
168
|
|
|
|
|
|
|
more packages keep being built the entire job will not fail due to |
169
|
|
|
|
|
|
|
individual build failures. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 REQUIRED ARGUMENTS |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
You must specify at least one valid source package for submission as a |
174
|
|
|
|
|
|
|
build job. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 OPTIONS |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This is the list of command-line options which may be set when |
179
|
|
|
|
|
|
|
submitting build jobs. Note that some of the options can take multiple |
180
|
|
|
|
|
|
|
values. In all cases you can use the shortest unique name for an |
181
|
|
|
|
|
|
|
option (e.g. C<plat> for C<platforms>. Some options also have |
182
|
|
|
|
|
|
|
single-character alternatives. As well as specifying them each time a |
183
|
|
|
|
|
|
|
job is submitted the options can be permanently set using the |
184
|
|
|
|
|
|
|
configuration files for this application. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=over 4 |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item C<--bucket|-B> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
This is the name of the package repository bucket into which binary |
191
|
|
|
|
|
|
|
packages will be submitted once they are built. This option is |
192
|
|
|
|
|
|
|
required. For RPMs this will be done using the pkgsubmit(8) |
193
|
|
|
|
|
|
|
command. For some platforms (e.g. those which use mock(1) to build |
194
|
|
|
|
|
|
|
packages) this may also alter which build chroot configuration is |
195
|
|
|
|
|
|
|
used. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item C<--archs|-a> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This is the list of architectures (e.g. i386 and x86_64) for which you |
200
|
|
|
|
|
|
|
want the binary packages to be built. If nothing is specified then |
201
|
|
|
|
|
|
|
build tasks will be registered for all available architectures. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This option may have multiple values, these can be expressed as a |
204
|
|
|
|
|
|
|
comma-separated list (e.g. C<--archs i386,x86_64>) or via putting the |
205
|
|
|
|
|
|
|
same option multiple times (e.g. C<--arch i386 --arch x86_64>). Note |
206
|
|
|
|
|
|
|
that values can also be negated by prefixing with an C<!> (exclamation |
207
|
|
|
|
|
|
|
mark). This can be useful when you want all the architectures |
208
|
|
|
|
|
|
|
B<except> one specific case. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item C<--platforms|-p> |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
This is the list of platforms (e.g. sl5 and f13) for which you want |
213
|
|
|
|
|
|
|
the binary packages to be built. If nothing is specified then build |
214
|
|
|
|
|
|
|
tasks will be registered for all available platforms. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This option may have multiple values, these can be expressed as a |
217
|
|
|
|
|
|
|
comma-separated list (e.g. C<--platforms f13,sl5>) or via putting the |
218
|
|
|
|
|
|
|
same option multiple times (e.g. C<--plat f13 --plat sl5>). Note that |
219
|
|
|
|
|
|
|
values can also be negated by prefixing with an C<!> (exclamation |
220
|
|
|
|
|
|
|
mark). This can be useful when you want all the platforms B<except> |
221
|
|
|
|
|
|
|
one specific case. |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item C<--report|-r> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This option can be used to set an email address (or set of email |
226
|
|
|
|
|
|
|
addresses) to which a summary report should be sent after the job has |
227
|
|
|
|
|
|
|
completed. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item C<--verbose> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Makes the output from verbose to see what is happening. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item C<--configfile|-c> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
This attribute is used to override the default configuration |
236
|
|
|
|
|
|
|
files. See the B<CONFIGURATION AND ENVIRONMENT> section below for |
237
|
|
|
|
|
|
|
details of how the configuration is normally loaded from files. If you |
238
|
|
|
|
|
|
|
specify a particular configuration file then B<ONLY> that file will be |
239
|
|
|
|
|
|
|
parsed, any others will be ignored. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item C<--target> |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
This is the location (e.g. normally a directory) into which the job |
244
|
|
|
|
|
|
|
should be submitted. Normally this would be specified in a |
245
|
|
|
|
|
|
|
configuration file and would not need to be specified on the command |
246
|
|
|
|
|
|
|
line. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=item C<--id> |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This is a unique identifier used to track the job to be |
251
|
|
|
|
|
|
|
submitted. Normally it is not necessary to specify the ID as a new |
252
|
|
|
|
|
|
|
unique string will be selected automatically. You may specify any, |
253
|
|
|
|
|
|
|
previously unused, string you like as long as all the characters match |
254
|
|
|
|
|
|
|
the set C<A-Za-z0-9_-> and the string is no more than 50 characters |
255
|
|
|
|
|
|
|
long. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=back |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
The standard C</etc/pkgforge/pkgforge.yml> file will always be |
262
|
|
|
|
|
|
|
consulted, if it exists. The application-specific files in |
263
|
|
|
|
|
|
|
C</etc/pkgforge> and C<$HOME/.pkgforge> are also examined, if they |
264
|
|
|
|
|
|
|
exist. For the C<submit> command the following configuration files |
265
|
|
|
|
|
|
|
will be examined, if the exist (in this order) |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=over |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item C</etc/pkgforge/pkgforge.yml> |
270
|
|
|
|
|
|
|
=item C</etc/pkgforge/submit.yml> |
271
|
|
|
|
|
|
|
=item C<$HOME/.pkgforge/pkgforge.yml> |
272
|
|
|
|
|
|
|
=item C<$HOME/.pkgforge/submit.yml> |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=back |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Settings in files later in the sequence override those earlier in the |
277
|
|
|
|
|
|
|
list. So settings in a user's home directory override the common |
278
|
|
|
|
|
|
|
application settings which override the system-wide settings. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
The configuration format is YAML, in this case all that is required |
281
|
|
|
|
|
|
|
are simple key-value pairs separated with a colon, one per-line, for |
282
|
|
|
|
|
|
|
example C<bucket: lcfg> |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 EXIT STATUS |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
After successfully running a command it will exit with code zero. An |
287
|
|
|
|
|
|
|
error will result in a non-zero error code. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
This module is powered by L<Moose> and uses |
292
|
|
|
|
|
|
|
L<MooseX::App::Cmd::Command> and L<MooseX::Types>. |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head1 SEE ALSO |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
L<PkgForge>, L<PkgForge::Job>, L<PkgForge::Source>, |
297
|
|
|
|
|
|
|
L<PkgForge::SourceUtils>, L<PkgForge::ConfigFile>, L<PkgForge::App> |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
Normally you would not use this class directly but would use the |
300
|
|
|
|
|
|
|
C<submit> command via the pkgforge(1) command. |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head1 PLATFORMS |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
This is the list of platforms on which we have tested this |
305
|
|
|
|
|
|
|
software. We expect this software to work on any Unix-like platform |
306
|
|
|
|
|
|
|
which is supported by Perl. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
ScientificLinux5, Fedora13 |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
Please report any bugs or problems (or praise!) to bugs@lcfg.org, |
313
|
|
|
|
|
|
|
feedback and patches are also always very welcome. |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=head1 AUTHOR |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
Stephen Quinney <squinney@inf.ed.ac.uk> |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
Copyright (C) 2010-2011 University of Edinburgh. All rights reserved. |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
324
|
|
|
|
|
|
|
it under the terms of the GPL, version 2 or later. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=cut |
327
|
|
|
|
|
|
|
|