mk_exim_release: include *full* version in docs
[exim.git] / release-process / scripts / mk_exim_release
CommitLineData
46c573de 1#!/usr/bin/env perl
525c441c 2# Copyright (c) The Exim Maintainers 2016-2018
3634fc25 3
8a483da6
NM
4use strict;
5use warnings;
6use Carp;
525c441c
HSHR
7use Cwd qw'abs_path';
8use File::Basename;
9use File::Path qw(make_path remove_tree);
8f29c950 10use File::Temp;
8a483da6 11use Getopt::Long;
ba41f854 12use IO::File;
8a483da6 13use Pod::Usage;
162e16b1 14use Digest::SHA;
525c441c
HSHR
15use if $ENV{DEBUG} => 'Smart::Comments';
16
17my $ME = basename $0;
18
8a483da6 19
cbae9e74 20my $debug = undef;
8a483da6
NM
21my $verbose = 0;
22
525c441c
HSHR
23# MAJOR.MINOR[.SECURITY[.FIXES]][-RCX]
24# 4 .90 .0 .22 -RC1
25my $version_pattern = qr/
26 (?<release>
cbae9e74 27 (?<target_release>
525c441c
HSHR
28 (?<major>\d) # 4
29 \.(?<minor>\d\d) # .90
30 (?:\.(?<security>\d+) # .0
31 (?:\.(?<fixes>)\d+)?)? # .22
cbae9e74 32 ) # target-release ->|
525c441c
HSHR
33 (?:-(?<rc>RC\d+)?)? # -RC1
34 )
35/x;
8a483da6 36
cbae9e74
HSHR
37my $quick_version_pattern = qr/
38 (?<release>
39 (?<last_tag>
40 (?<major>\d) # 4
41 \.(?<minor>\d\d) # .90
42 (?:\.(?<security>\d+) # .0
43 (?:\.(?<fixes>)\d+)?)? # .22
44 ) # last-tag ->|
45 (?:-(?<quick>\d+-g[[:xdigit:]]+))? # -3-gdeadbef
46 )
47/x;
48
525c441c 49# ------------------------------------------------------------------
8a483da6 50
525c441c
HSHR
51package Context {
52 use strict; # not strictly necessary yet, until in an own package
53 use warnings; # not strictly necessary yet, ...
54 use File::Spec::Functions qw'splitpath catfile catdir splitdir';
55 use File::Path qw'make_path remove_tree';
56 use File::Copy;
57 use Cwd qw'abs_path';
58 use Carp;
59
60 package PWD {
61 use Cwd;
62 sub TIESCALAR { bless do {\my $x} }
63 sub FETCH { cwd }
8a483da6 64 }
be914e6c 65
cbae9e74 66 tie my $cwd => 'PWD' or die; # this returns the current dir now, dynamically
8a483da6 67
525c441c
HSHR
68 sub new {
69 my $class = shift;
70 return bless { @_ } => $class;
71 }
8a483da6 72
525c441c
HSHR
73 sub check_version {
74 my $context = shift;
cbae9e74
HSHR
75 my $version = shift // 'HEAD';
76
77 #
78 # v => {
79 # release => 4.92-RC4 | 4.92-27-gabcdef
80 # target_release|last_tag => 4.92 | 4.92
81 #
82 # major => 4
83 # minor => 92
84 # security =>
85 # fixes =>
86 #
87 # rc|quick => RC4 | 27-gabcdef
88 # }
89
cf7e6ba8
HSHR
90 #
91 # v => {
92 # release => 4.92-RC4 | 4.92-27-gabcdef-dirty
93 # target_release|last_tag => 4.92 | 4.92
94 #
95 # major => 4
96 # minor => 92
97 # security =>
98 # fixes =>
99 #
100 # rc|quick => RC4 | 27-gabcdef-dirty
101 # }
102
cbae9e74
HSHR
103 if ($context->{quick}) {
104 # Try to find suitable version description
105 chomp(my $describe = do { # we wrap it into a open() to avoid hassle with
106 open(my $fh, '-|', # strange version descriptions
107 'git', describe => $version) or die;
108 <$fh>
109 } // exit 1);
110 $describe =~ /$quick_version_pattern/;
111
112 %{$context->{v}} = %+;
113 ($context->{commit}) = $version // ($context->{v}{quick} =~ /g([[:xdigit:]]+)/);
114 }
115 else {
116 croak "The given version number does not look right - $version"
117 if not $version =~ /$version_pattern/;
118 %{$context->{v}} = %+;
119
120 # find a valid vcs tag matching the version
121 my $pattern = "$context->{pkgname}-$context->{v}{release}" =~ s/[-_.]/[-_.]/gr;
122 chomp(my @tags = qx{git tag --list '$pattern'});
8a483da6 123
cbae9e74
HSHR
124 croak "The given version is ambigous, tags: @tags\n" if @tags > 1;
125 croak "The given version does not exist (no such tag: exim-$version)\n" if @tags == 0;
8a483da6 126
cbae9e74
HSHR
127 $context->{commit} = $tags[0];
128 # target_release: the release we aim to reach with release candidates
129 # FIXME: re-construct from the parsed version number
130 }
8a483da6 131
b315e9a9
HSHR
132 die "$ME: This script doesn't work for versions prior 4.92-RCx. "
133 ."Please checkout an older version.\n"
aa672401
HSHR
134 if $context->{v}{major} < 4
135 or $context->{v}{major} == 4 && $context->{v}{minor} < 92;
136
525c441c 137 ### v: $context->{v}
8a483da6 138
46c573de 139 }
8a483da6 140
8a483da6 141
525c441c
HSHR
142 # We prefer gtar to tar if gtar exists in $PATH
143 sub override_tar_cmd {
144 my $context = shift;
145 my $tar = $context->{tar_cmd};
8a483da6 146
525c441c 147 return unless $tar eq 'tar';
8a483da6 148
525c441c
HSHR
149 foreach my $d (File::Spec->path()) {
150 my $p = catfile($d, 'gtar');
151 if (-x $p) {
152 $context->{tar_cmd} = $p;
153 print "Switched tar command to: $p\n" if $verbose;
154 return;
155 }
156 }
157 }
8a483da6 158
525c441c
HSHR
159 sub prepare_working_directory {
160 my $context = shift;
161 my $workspace = $context->{workspace};
8f29c950 162
525c441c
HSHR
163 if (not defined $workspace) {
164 $workspace = $context->{workspace} = File::Temp->newdir(File::Spec->tmpdir . '/exim-packaging-XXXX');
165 }
166 else {
167 # ensure the working directory is not in place
168 if (-e $workspace) {
169 if ($context->{delete}) {
170 print "Deleting existing $workspace\n" if $verbose;
171 remove_tree $workspace, { verbose => $verbose || $debug };
172 }
173 else {
174 croak "Working directory $workspace exists" if -e $workspace;
175 }
176 }
177
178 # create base directory
179 make_path( $context->{directory}, { verbose => $verbose || $debug } );
180 }
8f29c950 181
525c441c
HSHR
182 # Set(!) and create subdirectories
183 foreach (qw(vcs_export pkg_tars pkg_trees tmp)) { # {dookbook}
184 make_path(
185 $context->{d}{$_} = catdir($workspace, $_),
186 { verbose => $verbose || $debug });
187 }
188 }
8f29c950 189
525c441c
HSHR
190 sub export_git_tree {
191 my $context = shift;
192
193 # build git command
194 my $archive_file = $context->{tmp_archive_file} = sprintf'%s/%s-%s.tar', $context->{d}{tmp}, $context->{pkgname}, $context->{v}{release};
195 ### $archive_file
cbae9e74 196 my @cmd = ( 'git', 'archive', '--format=tar', "--output=$archive_file", $context->{commit} );
525c441c
HSHR
197 ### @cmd
198 # run git command
199 print "[$cwd] Running: @cmd\n" if $verbose;
200 0 == system @cmd or croak "Export failed";
201 }
8f29c950 202
525c441c
HSHR
203 sub unpack_tree {
204 # TODO: Why can't we combine the export_git_tree with the
205 # unpack_tree function?
206 my $context = shift;
ba41f854 207
525c441c
HSHR
208 ### $context
209 die "Cannot see archive file\n" unless -f $context->{tmp_archive_file};
210 my @cmd = ('tar',
211 xf => $context->{tmp_archive_file},
212 -C => $context->{d}{vcs_export} );
5901f0ab 213
525c441c
HSHR
214 # run command
215 print "[$cwd] Running: @cmd\n" if $verbose;
216 system @cmd and croak "Unpack failed\n";
5901f0ab 217
ba41f854
PP
218 }
219
525c441c
HSHR
220 sub make_version_script {
221 my $context = shift;
222
223 #my $variant = substr( $context->{v}{release}, length($context->{v}{target_release}) );
224 #if ( $context->{v}{release} ne $context->{v}{target_release} . $variant ) {
225 # die "Broken version numbering, I'm buggy";
226 #}
227
228
229 # Work
230 if (not my $pid = fork // die "$ME: Cannot fork: $!\n") {
231
232 my $source_tree = catdir($context->{d}{vcs_export}, 'src', 'src');
233 ### $source_tree
234
235 chdir $source_tree or die "chdir $source_tree: $!\n";
236
525c441c
HSHR
237 croak "WARNING: version.sh already exists - leaving it in place\n"
238 if -f 'version.sh';
239
240 # Currently (25. Feb. 2016) the mk_exim_release.pl up to now can't
241 # deal with security releases.!? So we need a current
242 # mk_exim_release.pl. But if we use a current (master), the
243 # reversion script returns wrong version info (it's running inside
244 # the Git tree and uses git --describe, which always returns the
245 # current version of master.) I do not want to change the old
246 # reversion scripts (in 4.86.1, 4.85.1).
247 #
248 # Thus we've to provide the version.sh, based on the info we have
249 # about the release. If reversion finds this, it doesn't try to find
250 # it's own way to get a valid version number from the git.
251 #
252 # 4.89 series: the logic here did not handle _RC<N> thus breaking RC
253 # status in versions. nb: rc in context should be same as $variant
254 # in local context.
255
256 #my $stamp = $context->{minor} ? '_'.$context->{minor} : '';
257 #$stamp .= $context->{rc} if $context->{rc};
cbae9e74
HSHR
258 my $release = $context->{v}{rc} ? $context->{v}{target_release}
259 : $context->{v}{last_tag};
260
261 my $variant =
262 $context->{v}{rc} ? $context->{v}{rc}
263 : $context->{v}{quick} ? $context->{v}{quick}
264 : '';
525c441c
HSHR
265
266 print "[$cwd] create version.sh\n" if $verbose;
267 open(my $v, '>', 'version.sh') or die "Can't open version.sh for writing: $!\n";
268 print {$v} <<__;
269# initial version automatically generated by $0
cbae9e74 270EXIM_RELEASE_VERSION=$release
525c441c 271EXIM_VARIANT_VERSION=$variant
9677df8a 272EXIM_COMPILE_NUMBER=0
525c441c 273# echo "[[[ \$EXIM_RELEASE_VERSION | \$EXIM_VARIANT_VERSION | \$EXIM_COMPILE_NUMBER ]]]"
9677df8a 274__
525c441c
HSHR
275 close $v or die "$0: Can not close $source_tree/version.h: $!\n";
276 unlink 'version.h' or die "$ME: Can not unlink $source_tree/version.h: $!\n"
277 if -f 'version.h';
9677df8a 278
525c441c
HSHR
279 # Later, if we get the reversion script fixed, we can call it again.
280 # For now (25. Feb. 2016) we'll leave it unused.
cbae9e74 281 #my @cmd = ('../scripts/reversion', 'release', $context->{commit});
5901f0ab 282
525c441c
HSHR
283 my @cmd = ('../scripts/reversion', 'release');
284 print "[$cwd] Running: @cmd\n" if $verbose;
285 system(@cmd) and croak "reversion failed";
ba41f854 286
525c441c
HSHR
287 die "$ME: failed to create version.sh"
288 unless -f 'version.sh';
ba41f854 289
525c441c
HSHR
290 exit 0;
291 }
292 else {
293 $pid == waitpid($pid, 0) or die "$0: waidpid: $!\n";
294 exit $? >> 8 if $?;
295 }
296 }
ba41f854 297
525c441c
HSHR
298 sub build_documentation {
299 my $context = shift;
300 my $docdir = catdir $context->{d}{vcs_export}, 'doc', 'doc-docbook';
301
302 # documentation building does a chdir, so we'll do it in a
303 # subprocess
304 if (not my $pid = fork // die "$ME: Can't fork: $!\n") {
305 chdir $docdir or die "$ME: Can't chdir to $docdir: $!\n";
306 system('./OS-Fixups') == 0 or exit $?;
307 exec $context->{make_cmd},
cf7e6ba8
HSHR
308 "EXIM_VER=$context->{v}{release}", 'everything'
309 or die "$ME: [$cwd] Cannot exec $context->{make_cmd}: $!\n";
525c441c
HSHR
310 }
311 else {
312 waitpid($pid, 0);
313 exit $? >> 8 if $?;
314 }
be914e6c 315
525c441c 316 $context->copy_docbook_files;
525c441c 317 }
46c573de 318
525c441c
HSHR
319 sub copy_docbook_files {
320 my $context = shift;
be914e6c 321
525c441c
HSHR
322 # where the generated docbook files can be found
323 my $docdir = catdir $context->{d}{vcs_export}, 'doc', 'doc-docbook';
be914e6c 324
525c441c
HSHR
325 foreach ('spec.xml', 'filter.xml') {
326 my $from = catfile $docdir, $_;
327 my $to = catdir $context->{d}{tmp}; # {dookbook}
328 copy $from => $to or die $@;
329 }
330 }
be914e6c 331
525c441c
HSHR
332 sub build_html_documentation {
333 my $context = shift;
46c573de 334
525c441c
HSHR
335 # where the website docbook source dir is - push the generated
336 # files there
337 {
338 my $webdir = catdir $context->{website_base}, 'docbook', $context->{v}{target_release};
cbae9e74 339 make_path $webdir, { verbose => $verbose || $debug };
525c441c
HSHR
340 copy catfile($context->{d}{vcs_export}, 'doc', 'doc-docbook', $_)
341 => $webdir or die $@
342 for 'spec.xml', 'filter.xml';
343 }
46c573de 344
525c441c
HSHR
345 my $gen = catfile $context->{website_base}, 'script/gen';
346 my $outdir = catdir $context->{d}{pkg_trees}, "exim-html-$context->{v}{release}";
46c573de 347
525c441c 348 make_path $outdir, { verbose => $verbose || $debug };
46c573de 349
525c441c
HSHR
350 my @cmd = (
351 $gen,
352 '--spec' => catfile($context->{d}{tmp}, 'spec.xml'), # {dookbook}
353 '--filter' => catfile($context->{d}{tmp}, 'filter.xml'), # {dookbok}
354 '--latest' => $context->{v}{target_release},
355 '--docroot' => $outdir,
356 '--localstatic',
357 ($verbose || $debug ? '--verbose' : ()),
358 );
46c573de 359
525c441c
HSHR
360 print "[$cwd] Executing @cmd\n";
361 0 == system @cmd or exit $? >> 8;
46c573de 362
46c573de 363 }
be914e6c 364
162e16b1
HSHR
365 sub sign {
366 my $context = shift;
367 foreach my $tar (glob "$context->{d}{pkg_tars}/*") {
368 system gpg =>
369 '--quiet', '--batch',
370 defined $context->{gpg}{key}
371 ? ('--local-user' => $context->{gpg}{key})
372 : (),
373 '--detach-sig', '--armor', $tar;
374 }
375 }
376
525c441c
HSHR
377 sub move_to_outdir {
378 my $context = shift;
379 make_path $context->{OUTDIR}, { verbose => $verbose || $debug };
380 move $_ => $context->{OUTDIR} or die $@
381 for glob "$context->{d}{pkg_tars}/*";
382 }
8a483da6 383
525c441c
HSHR
384 sub build_src_package_directory {
385 my $context = shift;
8a483da6 386
525c441c
HSHR
387 # build the exim package directory path
388 $context->{d}{src} = catdir $context->{d}{pkg_trees}, "exim-$context->{v}{release}";
8a483da6 389
525c441c
HSHR
390 # initially we move the exim-src directory to the new directory name
391 move
392 catdir( $context->{d}{vcs_export}, 'src')
393 => $context->{d}{src}
394 or croak "Move of src dir failed - $!";
8a483da6 395
525c441c
HSHR
396 # add Local subdirectory
397 make_path( catdir( $context->{d}{src}, 'Local' ), { verbose => $verbose || $debug } );
8a483da6 398
525c441c
HSHR
399 # now add the text docs
400 $context->move_text_docs_into_pkg;
8a483da6 401 }
8a483da6 402
525c441c
HSHR
403 sub build_doc_packages_directory {
404 my $context = shift;
405
406 ##foreach my $format (qw/pdf postscript texinfo info/) {
407 foreach my $format (qw/pdf postscript/) {
408 my $target = catdir $context->{d}{pkg_trees}, "exim-$format-$context->{v}{release}", 'doc';
409 make_path( $target, { verbose => $verbose || $debug } );
410
411 # move documents across
412 foreach my $file (
413 glob(
414 catfile(
415 $context->{d}{vcs_export},
416 'doc',
417 'doc-docbook',
418 (
419 ( $format eq 'postscript' )
420 ? '*.ps'
421 : ( '*.' . $format )
422 )
8a483da6
NM
423 )
424 )
425 )
525c441c
HSHR
426 {
427 move( $file, catfile( $target, ( splitpath($file) )[2] ) );
428 }
8a483da6
NM
429 }
430 }
46c573de 431
525c441c
HSHR
432 sub move_text_docs_into_pkg {
433 my $context = shift;
9d0311ff 434
525c441c
HSHR
435 my $old_docdir = catdir( $context->{d}{vcs_export}, 'doc', 'doc-docbook' );
436 my $old_txtdir = catdir( $context->{d}{vcs_export}, 'doc', 'doc-txt' );
437 my $new_docdir = catdir( $context->{d}{src}, 'doc' );
438 make_path( $new_docdir, { verbose => $verbose || $debug } );
9d0311ff 439
525c441c
HSHR
440 # move generated documents from docbook stuff
441 foreach my $file (qw/exim.8 spec.txt filter.txt/) {
442 die "Empty file \"$file\"\n" if -z catfile( $old_docdir, $file );
443 move( catfile( $old_docdir, $file ), catfile( $new_docdir, $file ) );
444 }
9d0311ff 445
525c441c
HSHR
446 # move text documents across
447 foreach my $file ( glob( catfile( $old_txtdir, '*' ) ) ) {
448
449 # skip a few we dont want
450 my $fn = ( splitpath($file) )[2];
451 next
452 if ( ( $fn eq 'ABOUT' )
453 || ( $fn eq 'ChangeLog.0' )
454 || ( $fn eq 'test-harness.txt' )
455 # Debian issue re licensing of RFCs
456 || ( $fn =~ /^draft-ietf-.*/ )
457 || ( $fn =~ /^rfc.*/ )
458 );
459 move( $file, catfile( $new_docdir, $fn ) );
9d0311ff
PP
460 }
461 }
9d0311ff 462
525c441c
HSHR
463 sub create_tar_files {
464 my $context = shift;
9d0311ff 465
525c441c
HSHR
466 my $pkg_tars = $context->{d}{pkg_tars};
467 my $pkg_trees = $context->{d}{pkg_trees};
468 my $tar = $context->{tar_cmd};
469 if ($verbose) {
470 foreach my $c (keys %{ $context->{compressors} }) {
471 print "Compression: $c\t$context->{compressors}{$c}\n";
472 }
473 }
8a483da6 474
525c441c
HSHR
475 # We ideally do not want local system user information in release tarballs;
476 # those are artifacts of use of tar for backups and have no place in
477 # software release packaging; if someone extracts as root, then they should
478 # get sane file ownerships.
b315e9a9
HSHR
479 my @ownership = (
480 '--owner' => $context->{tar_perms}{user},
481 '--group' => $context->{tar_perms}{group},
525c441c 482 # on this GNU tar, --numeric-owner works during creation too
b315e9a9
HSHR
483 '--numeric-owner'
484 ) if qx/tar --help 2>&1/ =~ /^\s*--owner=/m;
9d0311ff 485
525c441c 486 # See also environment variables set in main, tuning compression levels
b315e9a9
HSHR
487 my %COMPRESSION = (
488 gzip => { extension => 'gz', flags => '--gzip' },
489 bzip2 => { extension => 'bz2', flags => '--bzip2' },
490 lzip => { extension => 'lz', flags => '--lzip' },
491 xz => { extension => 'xz', flags => '--xz' },
525c441c
HSHR
492 );
493
b315e9a9 494
162e16b1 495 my (%size, %sha256);
b315e9a9 496
525c441c
HSHR
497 foreach my $dir ( glob( catdir( $pkg_trees, ( 'exim*-' . $context->{v}{release} ) ) ) ) {
498 my $dirname = ( splitdir($dir) )[-1];
b315e9a9
HSHR
499 foreach my $comp (keys %COMPRESSION) {
500 next unless $context->{compressors}{$comp};
162e16b1 501
b315e9a9 502 my $basename = "$dirname.tar.$COMPRESSION{$comp}{extension}";
162e16b1
HSHR
503 my $outfile = catfile $pkg_tars, $basename;
504
505 print "Creating: $outfile\n" if $verbose || $debug;
b315e9a9
HSHR
506 0 == system($tar,
507 cf => $outfile,
508 $COMPRESSION{$comp}{flags},
509 @ownership, -C => $pkg_trees, $dirname)
525c441c 510 or exit $? >> 8;
162e16b1
HSHR
511
512 # calculate size and md5sum
513 $size{$basename} = -s $outfile;
514 $sha256{$basename} = do {
515 my $sha = Digest::SHA->new(256);
516 $sha->addfile($outfile);
517 $sha->hexdigest;
518 };
525c441c
HSHR
519 }
520 }
162e16b1
HSHR
521
522 # write the sizes file
cbae9e74
HSHR
523 if ($context->{sizes}) {
524 open my $sizes, '>', $_ = catfile $pkg_tars, 'sizes.txt'
525 or die "$ME: Can't open `$_': $!\n";
b315e9a9 526
cbae9e74
HSHR
527 print $sizes join "\n",
528 (map { "SIZE($_) = $size{$_}" } sort keys %size),
529 (map { "SHA256($_) = $sha256{$_}" } sort keys %sha256);
b315e9a9 530
cbae9e74
HSHR
531 close($sizes) or die "$ME: Can't close $_: $!\n";
532 }
45b75b0a
PP
533 }
534
525c441c
HSHR
535 sub do_cleanup {
536 my $context = shift;
00f7a87b 537
525c441c 538 print "Cleaning up\n" if $verbose;
cbae9e74 539 remove_tree $context->{d}{tmp}, { verbose => $verbose || $debug };
8a483da6 540 }
00f7a87b 541
8a483da6
NM
542}
543
91bde4a0
HSHR
544MAIN: {
545
525c441c
HSHR
546 # some of these settings are useful only if we're in the
547 # exim-projekt-root, but the check, if we're, is deferred
548 my $context = Context->new(
be914e6c 549 pkgname => 'exim',
525c441c 550 website_base => abs_path('../exim-website'),
9d0311ff 551 tar_cmd => 'tar',
45b75b0a
PP
552 tar_perms => {
553 user => '0',
554 group => '0',
555 },
cbae9e74 556 make_cmd => 'make', # for 'make'ing the docs
f8d3457b 557 sizes => 1,
9d0311ff
PP
558 compressors => {
559 gzip => 1,
560 bzip2 => 1,
00f7a87b 561 xz => 1,
e099cd0d 562 lzip => 0,
9d0311ff 563 },
525c441c 564 docs => 1,
2820726f 565 web => 1,
525c441c
HSHR
566 delete => 0,
567 cleanup => 1,
162e16b1
HSHR
568 gpg => {
569 sign => 1,
570 key => undef,
571 },
cbae9e74 572 quick => 0,
525c441c
HSHR
573 );
574
8f29c950 575 ##$ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'};
00f7a87b 576 # We are creating files for mass distribution, so work harder to make smaller files.
525c441c
HSHR
577 $ENV{GZIP} = -9;
578 $ENV{BZIP2} = -9;
00f7a87b
PP
579 # xz documents minimum file sizes for levels higher than -6 to be useful and each
580 # requires more RAM on the decompressing system. Exim tarball currently 24MiB so
581 # using -8.
525c441c 582 $ENV{XZ_DEFAULTS} = -8;
8a483da6 583
91bde4a0 584 GetOptions(
525c441c 585 $context,
cbae9e74 586 qw(workspace|tmp=s website_base|webgen_base=s tar_cmd|tar-cmd=s make_cmd|make-cmd=s
f8d3457b 587 docs|build-docs! web|build-web! sizes!
cbae9e74 588 delete! cleanup! quick|quick-release! minimal),
162e16b1
HSHR
589 'sign!' => \$context->{gpg}{sign},
590 'key=s' => \$context->{gpg}{key},
91bde4a0
HSHR
591 'lzip!' => \$context->{compressors}{lzip},
592 'verbose!' => \$verbose,
cbae9e74
HSHR
593 'debug:s' => \$debug,
594 'quick' => sub { $context->{web}--; $context->{quick} = 1 },
91bde4a0
HSHR
595 'help|?' => sub { pod2usage(-verbose => 1, -exit => 0) },
596 'man!' => sub { pod2usage(-verbose => 2, -exit => 0, -noperldoc => system('perldoc -V >/dev/null 2>&1')) },
cbae9e74
HSHR
597 ) and (@ARGV == 2 or ($context->{quick} and @ARGV >= 1))
598 or pod2usage;
525c441c 599
162e16b1
HSHR
600 -f '.exim-project-root'
601 or die "$ME: please call this script from the root of the Exim project sources\n";
525c441c
HSHR
602
603 $context->{OUTDIR} = pop @ARGV;
604
162e16b1
HSHR
605 if ($context->{gpg}{sign}) {
606 $context->{gpg}{key} //= do { chomp($_ = qx/git config user.signingkey/); $_ }
607 || $ENV{EXIM_KEY}
608 || do {
609 warn "$ME: No GPG key, using default\n";
610 undef;
611 }
612 }
613
525c441c
HSHR
614
615 warn "$ME: changed umask to 022\n" if umask(022) != 022;
616
cbae9e74
HSHR
617 $context->check_version(shift); # may be undef for a quick release
618
619 if ($debug//'' eq 'version') {
620 for (sort keys %{$context->{v}}) {
621 print "version $_: $context->{v}{$_}\n";
622 }
623 print "git commit: $context->{commit}\n";
624 exit 0;
625 }
525c441c
HSHR
626 $context->override_tar_cmd;
627 $context->prepare_working_directory;
628 $context->export_git_tree;
629 $context->unpack_tree;
630 $context->make_version_script;
cbae9e74 631
525c441c 632 $context->build_documentation if $context->{docs};
51420ec3 633 $context->build_html_documentation if $context->{docs} && $context->{web};
525c441c
HSHR
634
635 $context->build_src_package_directory;
636 $context->build_doc_packages_directory if $context->{docs};
637
638 $context->create_tar_files;
162e16b1 639 $context->sign if $context->{gpg}{sign};
525c441c
HSHR
640 $context->move_to_outdir;
641 $context->do_cleanup if $context->{cleanup};
642
643 ### $context
8a483da6
NM
644}
645
6461;
647
648__END__
649
650=head1 NAME
651
6bfa380e 652mk_exim_release - Build an exim release
8a483da6
NM
653
654=head1 SYNOPSIS
655
525c441c 656 mk_exim_release [options] version PKG-DIRECTORY
cbae9e74 657 mk_exim_release [options] --quick [version] PKG-DIRECTORY
91bde4a0
HSHR
658
659=head1 DESCRIPTION
660
661B<mk_exim_release> builds an exim release.
662
663Starting in a populated git repo that has already been tagged for
664release it builds docs, packages etc. Parameter is the version number
525c441c
HSHR
665to build as - ie 4.72 4.72-RC1, 4.86.1, etc, without any prefix.
666
667This scripts expects to find a tag "exim-<version>".
91bde4a0
HSHR
668
669After creating the release files, they should be signed. There is another
670helper for creating the signatures:
671F<release-process/scripts/sign_exim_packages>.
672
673Call B<mk_exim_release> about like this:
674
525c441c 675 release-process/scripts/mk_exim_release 4.99 OUT-DIR
8a483da6 676
8a483da6
NM
677
678=head1 OPTIONS
679
680=over 4
681
525c441c
HSHR
682=item B<--[no]cleanup>
683
684Do (or do not) cleanup the tmp directory at exit (default: do cleanup)
685
cbae9e74
HSHR
686=item B<--debug[=I<item>]>
687
688Forces debug mode. If (default: no debug info)
689
690=over 4
691
692=item item: B<version>
693
694Output the parsed/found version number and exit.
8a483da6 695
cbae9e74 696=back
8a483da6 697
91bde4a0 698=item B<--[no]delete>
9d0311ff 699
525c441c 700Delete a pre-existing tmp- and package-directory at start. (default: don't delete)
9d0311ff 701
cbae9e74 702=item B<--[no]doc>
a7637438 703
cbae9e74 704Do (not) build the documentation. This needs C<gnu-make> (default: build the docs)
a7637438 705
91bde4a0 706=item B<--[no]help>
9d0311ff 707
91bde4a0 708Display short help and exit cleanly. (default: don't do that)
9d0311ff 709
cbae9e74
HSHR
710=item B<--key> I<GPG key>
711
712Use this GPG key for signing. If nothing is specified the first one of this list
713is used:
714
715=over 8
716
717=item - git config user.signingkey
718
719=item - environment C<EXIM_KEY>
720
721=item - default GPG key
722
723=back
724
91bde4a0 725=item B<--[no]lzip>
8a483da6 726
91bde4a0 727Control the creation of B<lzip> tarballs. (default: do not use lzip)
8a483da6 728
cbae9e74 729=item B<--make-cmd> I<cmd>
8a483da6 730
91bde4a0 731Force the use of a specific C<make> command. This may be necessary if C<make> is not
cbae9e74 732C<gmake>. This is necessary to build the docs. (default: C<make>)
8a483da6 733
91bde4a0 734=item B<--[no]man>
8a483da6 735
91bde4a0 736Display man page and exit cleanly. (default: don't do that)
8a483da6 737
cbae9e74 738=item B<--quick>
8a483da6 739
cbae9e74
HSHR
740Create a quick release. The I<version> mandatory argument needs to be a git commit-ish.
741(try I<master> or I<HEAD> or similar). This mode switches off the
742website creation (which can be enabled by B<--web> again).
8a483da6 743
162e16b1
HSHR
744=item B<--[no]sign>
745
746Sign the created archive files (and the sizes.txt). (default: sign)
747
f8d3457b
HSHR
748=item B<--[no]sizes>
749
750Write the sizes information to F<sizes.txt>. (default: write sizes)
751
cbae9e74 752=item B<--tar-cmd> I<cmd>
162e16b1 753
cbae9e74
HSHR
754Use to override the path to the C<tar> command. Need GNU tar in case
755I<lzip> is selected. (default: C<gtar>, if not found, use C<tar>)
162e16b1 756
cbae9e74 757=item B<--tmpdir> I<dir>
162e16b1 758
cbae9e74 759Change the name of the tmp directory (default: temporary directory)
162e16b1 760
cbae9e74 761=item B<--verbose>
162e16b1 762
cbae9e74 763Force verbose mode. (default: no verbosity)
162e16b1 764
91bde4a0 765=item B<--[no]web>
8a483da6 766
91bde4a0 767Control the creation of the website. For creation of the website, the F<../exim-website>
cbae9e74
HSHR
768(but see the B<website-base> option) directory must exist. (default: create the website, except when
769in B<quick> mode)
525c441c
HSHR
770
771=item B<--website-base> I<dir>
772
773Base directory for the web site generation (default: F<../exim-website>)
8a483da6 774
cbae9e74 775=item B<-workspace>|B<--tmp> I<directory>
91bde4a0 776
cbae9e74
HSHR
777During release gerneration temporary storage is necessary. (default: F<exim-packaging-XXXX>
778under your system's default temporary directory (typically this is F</tmp>)).
91bde4a0
HSHR
779
780=back
8a483da6
NM
781
782=head1 AUTHOR
783
91bde4a0
HSHR
784Nigel Metheringham <Nigel.Metheringham@dev.intechnology.co.uk>,
785some changes by Heiko Schlittermann <hs@schlittermann.de>
8a483da6
NM
786
787=head1 COPYRIGHT
788
91bde4a0 789Copyright 2010-2016 Exim Maintainers. All rights reserved.
8a483da6
NM
790
791=cut
9d0311ff 792# vim: set sw=4 et :