Improve maintainer scripts.
* Makefile.am (alpha,alphacheck): Update rules. * mu-aux/gitinfo.pl: Obtain more data.
Showing
2 changed files
with
109 additions
and
53 deletions
... | @@ -165,7 +165,7 @@ dist-hook: ChangeLog | ... | @@ -165,7 +165,7 @@ dist-hook: ChangeLog |
165 | fi | 165 | fi |
166 | 166 | ||
167 | alpha: | 167 | alpha: |
168 | version=`$(GITINFO) -H'$$refversion{?$$n>0??-$$n?}'`;\ | 168 | version=`$(GITINFO) -H'$$refversion{?$$refdist>0??-$$refdist?}'`;\ |
169 | if test -n "$$version"; then\ | 169 | if test -n "$$version"; then\ |
170 | $(MAKE) dist distdir=$(PACKAGE)-$$version; \ | 170 | $(MAKE) dist distdir=$(PACKAGE)-$$version; \ |
171 | else \ | 171 | else \ |
... | @@ -174,7 +174,7 @@ alpha: | ... | @@ -174,7 +174,7 @@ alpha: |
174 | 174 | ||
175 | 175 | ||
176 | alphacheck: | 176 | alphacheck: |
177 | version=`$(GITINFO) -H'$$refversion{?$$n>0??-$$n?}'`;\ | 177 | version=`$(GITINFO) -H'$$refversion{?$$refdist>0??-$$refdist?}'`;\ |
178 | if test -n "$$version"; then\ | 178 | if test -n "$$version"; then\ |
179 | $(MAKE) distcheck distdir=$(PACKAGE)-$$version; \ | 179 | $(MAKE) distcheck distdir=$(PACKAGE)-$$version; \ |
180 | else \ | 180 | else \ | ... | ... |
... | @@ -27,15 +27,14 @@ gitinfo.pl - build version tag for mailutils | ... | @@ -27,15 +27,14 @@ gitinfo.pl - build version tag for mailutils |
27 | =head1 SYNOPSIS | 27 | =head1 SYNOPSIS |
28 | 28 | ||
29 | B<perl gitinfo.pl> | 29 | B<perl gitinfo.pl> |
30 | [B<-sv>] | ||
31 | [B<-C> I<DIR>] | 30 | [B<-C> I<DIR>] |
32 | [B<-H> I<FORMAT>] | 31 | [B<-H> I<FORMAT>] |
33 | [B<-o> I<FILE>] | 32 | [B<-o> I<FILE>] |
33 | [B<-r> B<recent> | B<released> | B<stable>] | ||
34 | [B<--directory=>I<DIR>] | 34 | [B<--directory=>I<DIR>] |
35 | [B<--format=>I<FORMAT>] | 35 | [B<--format=>I<FORMAT>] |
36 | [B<--output=>I<FILE>] | 36 | [B<--output=>I<FILE>] |
37 | [B<--stable>] | 37 | [B<--reference=>B<recent> | B<released> | B<stable>] |
38 | [B<--verbose>] | ||
39 | 38 | ||
40 | B<perl gitinfo.pl> B<-h> | B<--help> | B<--usage> | 39 | B<perl gitinfo.pl> B<-h> | B<--help> | B<--usage> |
41 | 40 | ||
... | @@ -53,31 +52,79 @@ The following variables are defined: | ... | @@ -53,31 +52,79 @@ The following variables are defined: |
53 | 52 | ||
54 | =over 4 | 53 | =over 4 |
55 | 54 | ||
56 | =item B<package> | 55 | =item B<package_name> |
57 | 56 | ||
58 | Package name, obtained from the B<AC_INIT> line in F<configure.ac>. | 57 | Package name, obtained from the B<AC_INIT> line in F<configure.ac>. |
59 | 58 | ||
60 | =item B<version> | 59 | =item B<package_version> |
61 | 60 | ||
62 | Package version, from the same source. | 61 | Package version, from the same source. |
63 | 62 | ||
63 | =item B<recent_version> | ||
64 | |||
65 | Most recent version as listed in the B<NEWS> file. | ||
66 | |||
67 | =item B<recent_date> | ||
68 | |||
69 | Date when the most recent version was released (if it was). | ||
70 | |||
71 | =item B<recent_commit> | ||
72 | |||
73 | Hash of the commit corresponding to the resent version. | ||
74 | |||
75 | =item B<recent_distance> | ||
76 | |||
77 | Distance (number of commits) between B<recent_commit> and B<HEAD>. | ||
78 | |||
79 | =item B<released_version> | ||
80 | |||
81 | The most recent released version as per B<NEWS> file. | ||
82 | |||
83 | =item B<released_date> | ||
84 | |||
85 | Date when it was released. | ||
86 | |||
87 | =item B<released_commit> | ||
88 | |||
89 | Hash of the commit corresponding to B<released_version>. | ||
90 | |||
91 | =item B<released_distance> | ||
92 | |||
93 | Distance (number of commits) between B<released_commit> and B<HEAD>. | ||
94 | |||
95 | =item B<stable_version> | ||
96 | |||
97 | The most recent stable version, i.e. most recently released version | ||
98 | which number doesn't have patchlevel part. Most often is the same | ||
99 | as B<released_version>. | ||
100 | |||
101 | =item B<stable_date> | ||
102 | |||
103 | Date of the stable release. | ||
104 | |||
105 | =item B<stable_commit> | ||
106 | |||
107 | Hash of the commit corresponding to B<stable_version>. | ||
108 | |||
109 | =item B<stable_distance> | ||
110 | |||
111 | Distance between B<stable_commit> and B<HEAD>. | ||
112 | |||
64 | =item B<refversion> | 113 | =item B<refversion> |
65 | 114 | ||
66 | Reference version. By default, it is the same as B<version> above. If, | 115 | Reference version, selected by the B<--reference> command line option. |
67 | however, the B<-s> (B<--stable>) option is given, B<refversion> is set | 116 | By default, it is the same as B<recent_version> above. |
68 | to the most recent stable release. The B<NEWS> file is analyzed in order | ||
69 | to find it. | ||
70 | 117 | ||
71 | =item B<refdate> | 118 | =item B<refdate> |
72 | 119 | ||
73 | Date when B<refversion> was released. Normally this is meaningful only for | 120 | Date when B<refversion> was released. May be absent, if the reference |
74 | stable versions (in other words, when the B<-s> option is given). | 121 | version was never released. |
75 | 122 | ||
76 | =item B<refcommit> | 123 | =item B<refcommit> |
77 | 124 | ||
78 | Hash of the commit corresponding to the B<refversion>. | 125 | Hash of the commit corresponding to the B<refversion>. |
79 | 126 | ||
80 | =item B<n> | 127 | =item B<refdist> |
81 | 128 | ||
82 | Number of commits between B<refcommit> and B<HEAD>. | 129 | Number of commits between B<refcommit> and B<HEAD>. |
83 | 130 | ||
... | @@ -131,7 +178,7 @@ format: | ... | @@ -131,7 +178,7 @@ format: |
131 | #define MU_GIT_COMMIT_HASH "$commit_hash" | 178 | #define MU_GIT_COMMIT_HASH "$commit_hash" |
132 | #define MU_GIT_COMMIT_TIME "$commit_time" | 179 | #define MU_GIT_COMMIT_TIME "$commit_time" |
133 | #define MU_GIT_COMMIT_SUBJECT "$commit_subject" | 180 | #define MU_GIT_COMMIT_SUBJECT "$commit_subject" |
134 | {?$n>0??#define MU_GIT_COMMIT_DISTANCE $n | 181 | {?$refdist>0??#define MU_GIT_COMMIT_DISTANCE $refdist |
135 | ?}#define MU_GIT_DESCRIBE_STRING "$describe{?$dirty??-dirty?}" | 182 | ?}#define MU_GIT_DESCRIBE_STRING "$describe{?$dirty??-dirty?}" |
136 | 183 | ||
137 | =item B<all> | 184 | =item B<all> |
... | @@ -160,14 +207,11 @@ Select output format. See B<DESCRIPTION> for the details. | ... | @@ -160,14 +207,11 @@ Select output format. See B<DESCRIPTION> for the details. |
160 | 207 | ||
161 | Output results to the I<FILE>, instead of the standard output. | 208 | Output results to the I<FILE>, instead of the standard output. |
162 | 209 | ||
163 | =item B<-s>, B<--stable> | 210 | =item B<-r>, B<--reference=>I<VERSION> |
164 | 211 | ||
165 | Count versions from the most recent stable version. | 212 | Select the reference version. Argument is one of: B<recent> (the default), |
213 | B<released>, or B<stable>. | ||
166 | 214 | ||
167 | =item B<-v>, B<--verbose> | ||
168 | |||
169 | Verbose output. | ||
170 | |||
171 | =item B<-h> | 215 | =item B<-h> |
172 | 216 | ||
173 | Display short help summary. | 217 | Display short help summary. |
... | @@ -199,7 +243,7 @@ sub find_commit($) { | ... | @@ -199,7 +243,7 @@ sub find_commit($) { |
199 | return $s; | 243 | return $s; |
200 | } | 244 | } |
201 | 245 | ||
202 | # find_count(VERSIN) | 246 | # find_count(VERSION) |
203 | # Returns number of commits between VERSION and the current commit. | 247 | # Returns number of commits between VERSION and the current commit. |
204 | sub find_count($) { | 248 | sub find_count($) { |
205 | my $v = shift; | 249 | my $v = shift; |
... | @@ -211,15 +255,10 @@ sub find_count($) { | ... | @@ -211,15 +255,10 @@ sub find_count($) { |
211 | return $s; | 255 | return $s; |
212 | } | 256 | } |
213 | 257 | ||
214 | # recent_version(STABLE) | 258 | sub scan_news($) { |
215 | # Returns the most recent version described in the NEWS file. | 259 | my ($hashref) = @_; |
216 | # If STABLE is true, returns the most recent stable version, i.e. | ||
217 | # the one, for which release date is set. | ||
218 | sub recent_version($) { | ||
219 | my ($stable) = @_; | ||
220 | my $file = 'NEWS'; | 260 | my $file = 'NEWS'; |
221 | open(my $fd, '<', $file) or die "can't open $file: $!"; | 261 | open(my $fd, '<', $file) or die "can't open $file: $!"; |
222 | my ($version, $date); | ||
223 | while (<$fd>) { | 262 | while (<$fd>) { |
224 | chomp; | 263 | chomp; |
225 | if (/^(?:\*[[:space:]]+)? | 264 | if (/^(?:\*[[:space:]]+)? |
... | @@ -227,13 +266,25 @@ sub recent_version($) { | ... | @@ -227,13 +266,25 @@ sub recent_version($) { |
227 | ([[:digit:]](?:[.,][[:digit:]]+){1,2}(?:[[:digit:]._-])*) | 266 | ([[:digit:]](?:[.,][[:digit:]]+){1,2}(?:[[:digit:]._-])*) |
228 | (?:(?:.*)[[:punct:]][[:space:]]* | 267 | (?:(?:.*)[[:punct:]][[:space:]]* |
229 | ([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}))?/x) { | 268 | ([[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}))?/x) { |
230 | next if ($stable && !defined($2)); | 269 | my ($ver, $date) = ($1, $2); |
231 | ($version, $date) = ($1, $2); | 270 | unless (exists($hashref->{recent_version})) { |
232 | last; | 271 | $hashref->{recent_version} = $ver; |
272 | $hashref->{recent_date} = $date if $date; | ||
273 | } | ||
274 | if ($date) { | ||
275 | if (!exists($hashref->{released_version})) { | ||
276 | $hashref->{released_version} = $ver; | ||
277 | $hashref->{released_date} = $date; | ||
278 | } | ||
279 | if ($ver =~ /^\d+\.\d+$/) { | ||
280 | $hashref->{stable_version} = $ver; | ||
281 | $hashref->{stable_date} = $date; | ||
282 | last; | ||
283 | } | ||
284 | } | ||
233 | } | 285 | } |
234 | } | 286 | } |
235 | close $fd; | 287 | close $fd; |
236 | return ($version, $date); | ||
237 | } | 288 | } |
238 | 289 | ||
239 | # this_version() | 290 | # this_version() |
... | @@ -375,8 +426,7 @@ sub eval_format { | ... | @@ -375,8 +426,7 @@ sub eval_format { |
375 | return join('', @res); | 426 | return join('', @res); |
376 | } | 427 | } |
377 | 428 | ||
378 | my $from_stable; | 429 | my $refpoint = 'recent'; |
379 | my $verbose; | ||
380 | my $output; | 430 | my $output; |
381 | my $format = 'all'; | 431 | my $format = 'all'; |
382 | 432 | ||
... | @@ -385,7 +435,7 @@ my %fmtab = ( | ... | @@ -385,7 +435,7 @@ my %fmtab = ( |
385 | #define MU_GIT_COMMIT_HASH "$commit_hash" | 435 | #define MU_GIT_COMMIT_HASH "$commit_hash" |
386 | #define MU_GIT_COMMIT_TIME "$commit_time" | 436 | #define MU_GIT_COMMIT_TIME "$commit_time" |
387 | #define MU_GIT_COMMIT_SUBJECT "$commit_subject" | 437 | #define MU_GIT_COMMIT_SUBJECT "$commit_subject" |
388 | {?$n>0??#define MU_GIT_COMMIT_DISTANCE $n | 438 | {?$refdist>0??#define MU_GIT_COMMIT_DISTANCE $refdist |
389 | ?}#define MU_GIT_DESCRIBE_STRING "$describe{?$dirty??-dirty?}" | 439 | ?}#define MU_GIT_DESCRIBE_STRING "$describe{?$dirty??-dirty?}" |
390 | EOT | 440 | EOT |
391 | , | 441 | , |
... | @@ -412,8 +462,7 @@ GetOptions("help" => sub { | ... | @@ -412,8 +462,7 @@ GetOptions("help" => sub { |
412 | pod2usage(-exitstatus => 0, -verbose => 0); | 462 | pod2usage(-exitstatus => 0, -verbose => 0); |
413 | }, | 463 | }, |
414 | "directory|C=s" => \$dir, | 464 | "directory|C=s" => \$dir, |
415 | "stable|s" => \$from_stable, | 465 | "reference|r=s" => \$refpoint, |
416 | "verbose|v" => \$verbose, | ||
417 | "format|H=s" => \$format, | 466 | "format|H=s" => \$format, |
418 | "output|o=s" => \$output | 467 | "output|o=s" => \$output |
419 | ) or exit(1); | 468 | ) or exit(1); |
... | @@ -431,26 +480,33 @@ if ($dir) { | ... | @@ -431,26 +480,33 @@ if ($dir) { |
431 | } | 480 | } |
432 | 481 | ||
433 | if (-d '.git') { | 482 | if (-d '.git') { |
434 | ($gitinfo{refversion}, my $date) = recent_version($from_stable); | 483 | scan_news(\%gitinfo); |
435 | $gitinfo{refdate} = $date if defined $date; | 484 | foreach my $pfx (qw(ref recent_ stable_ released_)) { |
436 | if ($verbose) { | 485 | my $name = $pfx . 'version'; |
437 | print STDERR "# counting from version $gitinfo{refversion}"; | 486 | if (exists($gitinfo{$name})) { |
438 | print STDERR ", released on $gitinfo{refdate}" | 487 | my $com = $gitinfo{$pfx . 'commit'} = find_commit($gitinfo{$name}); |
439 | if exists $gitinfo{refdate}; | 488 | my $n = find_count($com); |
440 | print STDERR "\n"; | 489 | if ($n =~ /^\d+$/) { |
490 | $gitinfo{$pfx . 'dist'} = $n; | ||
491 | } | ||
492 | } | ||
441 | } | 493 | } |
442 | 494 | ||
443 | $gitinfo{refcommit} = find_commit($gitinfo{refversion}); | 495 | unless (exists($gitinfo{$refpoint . '_version'})) { |
444 | print STDERR "# commit $gitinfo{refcommit}\n" | 496 | die "reference point '$refpoint' doesn't exist"; |
445 | if $verbose; | ||
446 | my $n = find_count($gitinfo{refcommit}); | ||
447 | |||
448 | if ($n =~ /^[1-9][0-9]*$/) { | ||
449 | $gitinfo{n} = $n; | ||
450 | } | 497 | } |
498 | |||
499 | @gitinfo{qw(refversion refdate refcommit refdist)} = | ||
500 | @gitinfo{map { "${refpoint}_$_" } qw(version date commit dist)}; | ||
501 | |||
451 | last_commit_info(\%gitinfo); | 502 | last_commit_info(\%gitinfo); |
452 | git_describe(\%gitinfo); | 503 | git_describe(\%gitinfo); |
453 | ($gitinfo{package}, $gitinfo{version}) = this_version; | 504 | ($gitinfo{package_name}, $gitinfo{package_version}) = this_version; |
505 | if ($gitinfo{recent_version} =~ /^\d+\.\d+$/) { | ||
506 | $gitinfo{upload_dest} = 'ftp'; | ||
507 | } else { | ||
508 | $gitinfo{upload_dest} = 'alpha'; | ||
509 | } | ||
454 | } | 510 | } |
455 | 511 | ||
456 | $format = $fmtab{$format} while exists $fmtab{$format}; | 512 | $format = $fmtab{$format} while exists $fmtab{$format}; | ... | ... |
-
Please register or sign in to post a comment