line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LCFG::Build::Tool::MicroVersion; # -*-cperl-*- |
2
|
1
|
|
|
1
|
|
1878
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
34
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# $Id: MicroVersion.pm.in 5770 2010-01-18 18:08:16Z squinney@INF.ED.AC.UK $ |
6
|
|
|
|
|
|
|
# $Source: /var/cvs/dice/LCFG-Build-Tools/lib/LCFG/Build/Tool/MicroVersion.pm.in,v $ |
7
|
|
|
|
|
|
|
# $Revision: 5770 $ |
8
|
|
|
|
|
|
|
# $HeadURL: https://svn.lcfg.org/svn/source/tags/LCFG-Build-Tools/LCFG_Build_Tools_0_4_0/lib/LCFG/Build/Tool/MicroVersion.pm.in $ |
9
|
|
|
|
|
|
|
# $Date: 2010-01-18 18:08:16 +0000 (Mon, 18 Jan 2010) $ |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.4.0'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
445
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
extends 'LCFG::Build::Tool'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# We do not want this option for these commands so use an override. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has '+resultsdir' => ( traits => ['NoGetopt'] ); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'logname' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => 'Str', |
24
|
|
|
|
|
|
|
lazy => 1, |
25
|
|
|
|
|
|
|
default => sub { $_[0]->spec->get_vcsinfo('logname') || 'ChangeLog' }, |
26
|
|
|
|
|
|
|
documentation => 'The VCS log file name', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'checkcommitted' => ( |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => 'Bool', |
32
|
|
|
|
|
|
|
lazy => 1, |
33
|
|
|
|
|
|
|
default => sub { $_[0]->spec->get_vcsinfo('checkcommitted') }, |
34
|
|
|
|
|
|
|
documentation => 'Check for uncommitted changes', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'genchangelog' => ( |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
isa => 'Bool', |
40
|
|
|
|
|
|
|
lazy => 1, |
41
|
|
|
|
|
|
|
default => sub { $_[0]->spec->get_vcsinfo('genchangelog') }, |
42
|
|
|
|
|
|
|
documentation => 'Generate the change log from the VCS log', |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
override '_load_vcs_module' => sub { |
46
|
|
|
|
|
|
|
my ($self) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $vcs = super; |
49
|
|
|
|
|
|
|
$vcs->logname( $self->logname ); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $vcs; |
52
|
|
|
|
|
|
|
}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub abstract { |
57
|
|
|
|
|
|
|
return q{Tag the source tree as a particular release}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub execute { |
61
|
|
|
|
|
|
|
my ( $self, $opt, $args ) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return $self->release('micro'); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub release { |
67
|
|
|
|
|
|
|
my ( $self, $reltype ) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$reltype ||= 'micro'; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my ( $spec, $vcs ) = ( $self->spec, $self->vcs ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
if ( $self->checkcommitted ) { |
74
|
|
|
|
|
|
|
my ( $ok, @files ) = $vcs->checkcommitted(); |
75
|
|
|
|
|
|
|
if ( !$ok ) { |
76
|
|
|
|
|
|
|
warn "There are uncommitted files\n"; |
77
|
|
|
|
|
|
|
if ( !$self->quiet ) { |
78
|
|
|
|
|
|
|
for my $file (@files) { |
79
|
|
|
|
|
|
|
warn "\t" . $file . "\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
exit 1; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
if ( $self->genchangelog ) { |
87
|
|
|
|
|
|
|
$vcs->genchangelog(); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
if ( $reltype eq 'micro' ) { |
91
|
|
|
|
|
|
|
$spec->update_micro(); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
elsif ( $reltype eq 'minor' ) { |
94
|
|
|
|
|
|
|
$spec->update_minor(); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
elsif ( $reltype eq 'major' ) { |
97
|
|
|
|
|
|
|
$spec->update_major(); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
else { |
100
|
|
|
|
|
|
|
$self->fail("Unrecognised update type: $reltype"); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
if ( $self->dryrun ) { |
104
|
|
|
|
|
|
|
$self->log('Dry-run so not saving any changes to the metafile.'); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
else { |
107
|
|
|
|
|
|
|
$spec->save_metafile(); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$vcs->tagversion( $spec->version ); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
return; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub minorversion { |
116
|
|
|
|
|
|
|
my ($self) = @_; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
return $self->release('minor'); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub majorversion { |
122
|
|
|
|
|
|
|
my ($self) = @_; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
return $self->release('major'); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
no Moose; |
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
__END__ |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 NAME |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
LCFG::Build::Tool::MicroVersion - LCFG software packaging tool |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 VERSION |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This documentation refers to LCFG::Build::Tool::MicroVersion version 0.4.0 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SYNOPSIS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
my $tool = LCFG::Build::Tool::MicroVersion->new( dir => '.' ); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$tool->execute; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $tool2 = LCFG::Build::Tool::MicroVersion->new_with_options(); |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
$tool2->execute; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 DESCRIPTION |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This module provides software release tools for the LCFG build |
152
|
|
|
|
|
|
|
suite. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This tool will increment the smallest part of the project version |
155
|
|
|
|
|
|
|
field and then tag a release of the project in the package |
156
|
|
|
|
|
|
|
version-control repository. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
It is possible to check that all changes to files have been committed |
159
|
|
|
|
|
|
|
prior to doing a new release. Prior to actually doing the tagging it |
160
|
|
|
|
|
|
|
is also possible to generate the project log file from the |
161
|
|
|
|
|
|
|
version-control system logs. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
More information on the LCFG build tools is available from the website |
164
|
|
|
|
|
|
|
http://www.lcfg.org/doc/buildtools/ |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
The following attributes are modifiable via the command-line (i.e. via |
169
|
|
|
|
|
|
|
@ARGV) as well as the normal way when the Tool object is |
170
|
|
|
|
|
|
|
created. Unless stated the options take strings as arguments and can |
171
|
|
|
|
|
|
|
be used like C<--foo=bar>. Boolean options can be expressed as either |
172
|
|
|
|
|
|
|
C<--foo> or C<--no-foo> to signify true and false values. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=over 4 |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item dryrun |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
A boolean value which indicates whether actions which permanently |
179
|
|
|
|
|
|
|
alter the contents of files should be carried out. The default value |
180
|
|
|
|
|
|
|
is false (0). When running in dry-run mode various you will typically |
181
|
|
|
|
|
|
|
get extra output to the screen showing what would have been done. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item quiet |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
A boolean value which indicates whether the actions should attempt to |
186
|
|
|
|
|
|
|
be quieter. The default value is false (0). |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item dir |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
The path of the project directory which contains the software for |
191
|
|
|
|
|
|
|
which you want to create a release. If this is not specified then a |
192
|
|
|
|
|
|
|
default value of the current directory (.) will be used. This |
193
|
|
|
|
|
|
|
directory must already contain the LCFG build metadata file (lcfg.yml) |
194
|
|
|
|
|
|
|
for the software. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item logname |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
The name of the changelog file for this software project (e.g. Changes |
199
|
|
|
|
|
|
|
or ChangeLog). By default the value specified in the LCFG metadata |
200
|
|
|
|
|
|
|
file will be used. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item checkcommitted |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This is a boolean value which signifies whether the software project |
205
|
|
|
|
|
|
|
should be checked for uncommitted files before a new release is |
206
|
|
|
|
|
|
|
made. By default the value specified in the LCFG metadata file will be |
207
|
|
|
|
|
|
|
used. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item genchangelog |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
This is a boolean value which signifies whether the changelog file for |
212
|
|
|
|
|
|
|
the software project should be generated from the commit logs of the |
213
|
|
|
|
|
|
|
version-control system. By default the value specified in the LCFG |
214
|
|
|
|
|
|
|
metadata file will be used. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=back |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
The following methods are not modifiable by the command-line, they are |
219
|
|
|
|
|
|
|
however directly modifiable via the Tool object if |
220
|
|
|
|
|
|
|
necessary. Typically you will only need to query these attributes, |
221
|
|
|
|
|
|
|
they are automatically created when you need them using values for |
222
|
|
|
|
|
|
|
some of the other command-line attributes. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=over 4 |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=item spec |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
This is a reference to the current project metadata object, see |
229
|
|
|
|
|
|
|
L<LCFG::Build::PkgSpec> for full details. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item vcs |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
This is a reference to the current version-control object, see |
234
|
|
|
|
|
|
|
L<LCFG::Build::VCS> for full details. |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=back |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=over 4 |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item execute() |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This will increment the smallest part of the version field and then |
245
|
|
|
|
|
|
|
uses the appropriate L<LCFG::Build::VCS> module to tag a new |
246
|
|
|
|
|
|
|
release. This also resets the release field to one. See |
247
|
|
|
|
|
|
|
L<LCFG::Build::PkgSpec> for full details regarding the version field. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
It is possible to check that all changes to files have been committed |
250
|
|
|
|
|
|
|
prior to doing a new release. If uncommitted changes are detected then |
251
|
|
|
|
|
|
|
the tool will exit with a code of 1. If you have not asked the tool to |
252
|
|
|
|
|
|
|
be quiet it will also print out the list of uncommitted files. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Prior to actually doing the tagging it is possible to generate the |
255
|
|
|
|
|
|
|
project log file from the version-control system logs. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
The C<tagversion> method of the appropriate L<LCFG::Build::VCS> module |
258
|
|
|
|
|
|
|
will be used to actually tag the project source code at the new |
259
|
|
|
|
|
|
|
version. |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item release($level) |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
This is the method which actually does the work. It takes one optional |
264
|
|
|
|
|
|
|
parameter which specifies the level of the release, if it is not |
265
|
|
|
|
|
|
|
specified then only the smallest (micro) part of the version field |
266
|
|
|
|
|
|
|
will be incremented. When specifying the level it can be any of |
267
|
|
|
|
|
|
|
'major', 'minor' or 'micro'. When the smallest part of the version |
268
|
|
|
|
|
|
|
field is incremented the release field is also reset to one. For |
269
|
|
|
|
|
|
|
details of the procedure for updating the other parts of the version |
270
|
|
|
|
|
|
|
field see below. |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item minorversion() |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This is a convenience method which calls the release() method with the |
275
|
|
|
|
|
|
|
level parameter set to 'minor'. As well as incrementing the middle |
276
|
|
|
|
|
|
|
part of the version field the smallest part will be reset to zero and |
277
|
|
|
|
|
|
|
the release field will be reset to one. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item majorversion() |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
This is a convenience method which calls the release() method with the |
282
|
|
|
|
|
|
|
level parameter set to 'major'. As well as incrementing the largest |
283
|
|
|
|
|
|
|
part of the version field the middle and smallest parts will be reset |
284
|
|
|
|
|
|
|
to zero and the release field will be reset to one. |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=item fail($message) |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Immediately fails (i.e. dies) and displays the message. |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=item log($message) |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
Logs the message to the screen if the C<quiet> attribute has not been |
293
|
|
|
|
|
|
|
specified. A message string is prefixed with 'LCFG: ' to help visually |
294
|
|
|
|
|
|
|
separate it from other output. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=back |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
This module is L<Moose> powered and uses L<MooseX::App::Cmd> to handle |
301
|
|
|
|
|
|
|
command-line options. |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
The following modules from the LCFG build tools suite are also |
304
|
|
|
|
|
|
|
required: L<LCFG::Build::Tool>, L<LCFG::Build::PkgSpec>, |
305
|
|
|
|
|
|
|
L<LCFG::Build::VCS> and VCS helper module for your preferred |
306
|
|
|
|
|
|
|
version-control system. |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
=head1 SEE ALSO |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
L<LCFG::Build::Tools>, L<LCFG::Build::Skeleton>, lcfg-reltool(1) |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
=head1 PLATFORMS |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
This is the list of platforms on which we have tested this |
315
|
|
|
|
|
|
|
software. We expect this software to work on any Unix-like platform |
316
|
|
|
|
|
|
|
which is supported by Perl. |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
Fedora12, Fedora13, ScientificLinux5, ScientificLinux6, MacOSX7 |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
There are no known bugs in this application. Please report any |
323
|
|
|
|
|
|
|
problems to bugs@lcfg.org, feedback and patches are also always very |
324
|
|
|
|
|
|
|
welcome. |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
=head1 AUTHOR |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
Stephen Quinney <squinney@inf.ed.ac.uk> |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
Copyright (C) 2008 University of Edinburgh. All rights reserved. |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
335
|
|
|
|
|
|
|
it under the terms of the GPL, version 2 or later. |
336
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
=cut |