2 # Copyright (c) The Exim Maintainers 2016
19 # ------------------------------------------------------------------
21 sub get_and_check_version
{
25 # make sure this looks like a real release version
26 # which should (currently) be 4.xx[.y] or 4.xx[.y]_RCx
27 unless ( $release =~ /^(?<release>(?<major>4\.\d\d)(?:\.(?<minor>\d+))?(?:_RC\d+)?)$/ ) {
28 croak
"The given version number does not look right - $release";
30 $context->{release
} = $+{release
};
31 $context->{major
} = $+{major
};
32 $context->{minor
} = $+{minor
};
34 ($context->{trelease
} = $+{release
}) =~ s/_RC\d+//;
37 # ------------------------------------------------------------------
42 # The CVS tag consists of exim-$version where $version
43 # is the version number with . replaced with _
44 my $modversion = $context->{release
};
45 $modversion =~ tr/0-9RC/_/cs;
47 return sprintf( 'exim-%s', $modversion );
50 # ------------------------------------------------------------------
52 sub deal_with_working_directory
{
56 # Set default directory
57 $context->{directory
} ||= File
::Spec
->rel2abs( sprintf( 'exim-packaging-%s', $context->{release
} ) );
58 my $directory = $context->{directory
};
60 # ensure the working directory is not in place
61 if ( -d
$directory ) {
63 print "Deleting existing $directory\n" if ($verbose);
64 rmtree
( $directory, { verbose
=> $debug } );
66 if ( -d
$directory ) {
67 croak
"Working directory $directory exists";
71 # create base directory
72 mkpath
( $context->{directory
}, { verbose
=> ( $verbose || $debug ) } );
74 # set and create subdirectories
75 foreach (qw(release_tree pkgs pkgdirs docbook tmp)) {
76 $context->{$_} = File
::Spec
->catdir( $context->{directory
}, $_ );
77 mkpath
( $context->{$_}, { verbose
=> ( $verbose || $debug ) } );
81 # ------------------------------------------------------------------
87 my $archive_file = sprintf( '%s/%s-%s.tar', $context->{tmp
}, $context->{pkgname
}, $context->{release
} );
88 $context->{tmp_archive_file
} = $archive_file;
89 my @cmd = ( 'git', 'archive', '--format=tar', "--output=$archive_file", $context->{tag
} );
91 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
92 system(@cmd) == 0 || croak
"Export failed";
95 # ------------------------------------------------------------------
100 die "Cannot see archive file\n" unless ( -f
$context->{tmp_archive_file
} );
101 my @cmd = ( 'tar', 'xf', $context->{tmp_archive_file
}, '-C', $context->{release_tree
} );
104 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
105 system(@cmd) == 0 || croak
"Unpack failed";
108 # ------------------------------------------------------------------
110 sub make_version_script
{
113 my $variant = substr( $context->{release
}, length($context->{trelease
}) );
114 if ( $context->{release
} ne $context->{trelease
} . $variant ) {
115 die "Broken version numbering, I'm buggy";
118 my $srcdir = File
::Spec
->catdir( $context->{release_tree
}, 'src', 'src' );
119 chdir $srcdir or die "chdir $srcdir: $!\n";
121 if ( -f
"version.sh" ) {
122 print( "WARNING: version.sh already exists - leaving it in place\n" );
126 # Currently (25. Feb. 2016) the mk_exim_release.pl up to now can't
127 # deal with security releases.!? So we need a current
128 # mk_exim_release.pl. But if we use a current (master), the
129 # reversion script returns wrong version info (it's running inside
130 # the Git tree and uses git --describe, which always returns the
131 # current version of master.) I do not want to change the old
132 # reversion scripts (in 4.86.1, 4.85.1).
134 # Thus we've to provide the version.sh, based on the info we have
135 # about the release. If reversion finds this, it doesn't try to find
136 # it's own way to get a valid version number from the git.
137 open(my $v, '>', 'version.sh') or die "Can't open '>version.sh' $!\n";
139 # initial version automatically generated from $0
140 EXIM_RELEASE_VERSION
=$context->{major
}
141 EXIM_VARIANT_VERSION
=@
{[$context->{minor
}?
'_'.$context->{minor
}:'']}
142 EXIM_COMPILE_NUMBER
=0
148 # Later, if we get the reversion script fixed, we can call it again.
149 # For now (25. Feb. 2016) we'll leave it unused.
150 my @cmd = ("../scripts/reversion", "release", $context->{tag
});
151 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
152 system(@cmd) == 0 || croak
"reversion failed";
156 -f
"version.sh" or die "failed to create version.sh";
159 # ------------------------------------------------------------------
161 sub build_html_documentation
{
164 my $genpath = $context->{webgen_base
} . '/script/gen.pl';
165 my $templates = $context->{webgen_base
} . '/templates';
166 my $dir = File
::Spec
->catdir( $context->{release_tree
}, 'html' );
167 my $spec = File
::Spec
->catfile( $context->{docbook
}, 'spec.xml' );
168 my $filter = File
::Spec
->catfile( $context->{docbook
}, 'filter.xml' );
173 $genpath, '--spec', $spec, '--filter',
174 $filter, '--latest', $context->{trelease
}, '--tmpl',
175 $templates, '--docroot', $dir, '--localstatic'
177 push @cmd, '--verbose' if $verbose or $debug;
179 print "Executing ", join( ' ', @cmd ), "\n";
182 # move directory into right place
183 my $sourcedir = File
::Spec
->catdir( $context->{docbook
}, 'filter.xml' );
186 File
::Spec
->catdir( $dir, sprintf( 'exim-html-%s', $context->{trelease
} ) ),
187 File
::Spec
->catdir( $context->{pkgdirs
}, sprintf( 'exim-html-%s', $context->{release
} ) )
191 # ------------------------------------------------------------------
193 sub copy_docbook_files
{
196 # where the generated docbook files can be found
197 my $docdir = File
::Spec
->catdir( $context->{release_tree
}, 'doc', 'doc-docbook' );
199 # where the website docbook source dir is - push files to here
200 my $webdir = File
::Spec
->catdir( $context->{webgen_base
}, 'docbook', $context->{trelease
} );
201 mkpath
( $webdir, { verbose
=> ( $verbose || $debug ) } );
203 foreach my $file ( 'spec.xml', 'filter.xml' ) {
204 my $from = File
::Spec
->catfile( $docdir, $file );
205 my $to = File
::Spec
->catfile( $context->{docbook
}, $file );
206 my $webto = File
::Spec
->catfile( $webdir, $file );
208 copy
( $from, $webto );
212 # ------------------------------------------------------------------
214 sub build_documentation
{
217 my $docdir = File
::Spec
->catdir( $context->{release_tree
}, 'doc', 'doc-docbook' );
218 # documentation building gets the truncated release, without RC
219 system("cd '$docdir' && ./OS-Fixups && $context->{make_cmd} EXIM_VER=$context->{trelease} everything") == 0
220 || croak
"Doc build failed";
222 copy_docbook_files
($context);
223 build_html_documentation
($context) if $context->{web
};
226 # ------------------------------------------------------------------
228 sub move_text_docs_into_pkg
{
231 my $old_docdir = File
::Spec
->catdir( $context->{release_tree
}, 'doc', 'doc-docbook' );
232 my $old_txtdir = File
::Spec
->catdir( $context->{release_tree
}, 'doc', 'doc-txt' );
233 my $new_docdir = File
::Spec
->catdir( $context->{eximpkgdir
}, 'doc' );
234 mkpath
( $new_docdir, { verbose
=> ( $verbose || $debug ) } );
236 # move generated documents from docbook stuff
237 foreach my $file (qw
/exim.8 spec.txt filter.txt/) {
238 die "Empty file \"$file\"\n" if -z File
::Spec
->catfile( $old_docdir, $file );
239 move
( File
::Spec
->catfile( $old_docdir, $file ), File
::Spec
->catfile( $new_docdir, $file ) );
242 # move text documents across
243 foreach my $file ( glob( File
::Spec
->catfile( $old_txtdir, '*' ) ) ) {
245 # skip a few we dont want
246 my $fn = ( File
::Spec
->splitpath($file) )[2];
248 if ( ( $fn eq 'ABOUT' )
249 || ( $fn eq 'ChangeLog.0' )
250 || ( $fn eq 'test-harness.txt' )
251 # Debian issue re licensing of RFCs
252 || ( $fn =~ /^draft-ietf-.*/ )
253 || ( $fn =~ /^rfc.*/ )
255 move
( $file, File
::Spec
->catfile( $new_docdir, $fn ) );
259 # ------------------------------------------------------------------
261 sub build_pspdfinfo_directory
{
264 ##foreach my $format (qw/pdf postscript texinfo info/) {
265 foreach my $format (qw
/pdf postscript/) {
266 my $target = File
::Spec
->catdir( $context->{pkgdirs
}, sprintf( 'exim-%s-%s', $format, $context->{release
} ), 'doc' );
267 mkpath
( $target, { verbose
=> ( $verbose || $debug ) } );
269 # move documents across
273 $context->{release_tree
},
277 ( $format eq 'postscript' )
285 move
( $file, File
::Spec
->catfile( $target, ( File
::Spec
->splitpath($file) )[2] ) );
290 # ------------------------------------------------------------------
292 sub build_main_package_directory
{
295 # build the exim package directory path
296 $context->{eximpkgdir
} = File
::Spec
->catdir( $context->{pkgdirs
}, sprintf( 'exim-%s', $context->{release
} ) );
298 # initially we move the exim-src directory to the new directory name
299 rename( File
::Spec
->catdir( $context->{release_tree
}, 'src' ), $context->{eximpkgdir
} )
300 || croak
"Rename of src dir failed - $!";
302 # add Local subdirectory
303 mkpath
( File
::Spec
->catdir( $context->{eximpkgdir
}, 'Local' ), { verbose
=> ( $verbose || $debug ) } );
305 # now add the text docs
306 move_text_docs_into_pkg
($context);
309 # ------------------------------------------------------------------
311 sub build_package_directories
{
314 build_main_package_directory
($context);
315 build_pspdfinfo_directory
($context) if $context->{build_docs
};
318 # ------------------------------------------------------------------
323 print "Cleaning up\n" if ($verbose);
324 chdir( $context->{directory
} ) || die;
325 rmtree
( $context->{release_tree
}, { verbose
=> $debug } );
326 rmtree
( $context->{docbook
}, { verbose
=> $debug } );
327 rmtree
( $context->{pkgdirs
}, { verbose
=> $debug } );
330 # ------------------------------------------------------------------
332 # We prefer gtar to tar if gtar exists in $PATH
336 my $tar = $context->{tar_cmd
};
338 return unless $tar eq 'tar';
340 foreach my $d (File
::Spec
->path()) {
341 my $p = File
::Spec
->catfile($d, 'gtar');
343 $context->{tar_cmd
} = $p;
344 print "Switched tar command to: $p\n" if ($verbose);
350 # ------------------------------------------------------------------
352 sub create_tar_files
{
355 my $pkgs = $context->{pkgs
};
356 my $pkgdirs = $context->{pkgdirs
};
357 my $tar = $context->{tar_cmd
};
359 foreach my $c (keys %{ $context->{compressors
} }) {
360 print "Compression: $c\t$context->{compressors}{$c}\n";
364 # See also environment variables set in main, tuning compression levels
366 # compressors-dict-key, file-extension, flags-as-string
367 [ "gzip", "gz", "--gzip" ],
368 [ "bzip2", "bz2", "--bzip2" ],
369 [ "lzip", "lz", "--lzip" ],
370 [ "xz", "xz", "--xz" ],
373 foreach my $dir ( glob( File
::Spec
->catdir( $pkgdirs, ( 'exim*-' . $context->{release
} ) ) ) ) {
374 my $dirname = ( File
::Spec
->splitdir($dir) )[-1];
375 foreach my $comp (@COMPRESSIONS) {
376 my ($compkey, $extension, $flags) = @
{$comp};
377 next unless $context->{compressors
}{$compkey};
378 print "Creating: ${pkgs}/${dirname}.tar.${extension}\n" if ($verbose || $debug);
379 system("$tar cf ${pkgs}/${dirname}.tar.${extension} ${flags} --numeric-owner -C ${pkgdirs} ${dirname}");
385 # ------------------------------------------------------------------
388 $0 =~ m
|^(?
:\
./)?release-process/scripts
/|
389 or die "$0: please call this script from the root of the Exim project sources\n";
393 orig_dir
=> File
::Spec
->curdir(),
394 tmp_dir
=> File
::Temp
->newdir(),
395 webgen_base
=> "$FindBin::Bin/../../../exim-website",
409 ##$ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'};
410 # We are creating files for mass distribution, so work harder to make smaller files.
412 $ENV{'BZIP2'} = '-9';
413 # xz documents minimum file sizes for levels higher than -6 to be useful and each
414 # requires more RAM on the decompressing system. Exim tarball currently 24MiB so
416 $ENV{'XZ_DEFAULTS'} = '-8';
419 'directory=s' => \
$context->{directory
},
420 'webgen_base=s' => \
$context->{webgen_base
},
421 'tar=s' => \
$context->{tar_cmd
},
422 'make=s' => \
$context->{make_cmd
},
423 'lzip!' => \
$context->{compressors
}{lzip
},
424 'verbose!' => \
$verbose,
426 'help|?' => sub { pod2usage
(-verbose
=> 1, -exit => 0) },
427 'man!' => sub { pod2usage
(-verbose
=> 2, -exit => 0, -noperldoc
=> system('perldoc -V >/dev/null 2>&1')) },
428 'delete!' => \
$delete,
429 'cleanup!' => \
$cleanup,
430 'build-docs!' => \
$context->{build_docs
},
431 'web!' => \
$context->{web
},
432 ) and @ARGV == 1 or pod2usage
;
435 get_and_check_version
( shift, $context );
436 fix_paths_tar
($context);
437 $context->{tag
} = build_tag
($context);
438 deal_with_working_directory
( $context, $delete );
439 export_git_tree
($context);
440 chdir( $context->{directory
} ) || die;
441 unpack_tree
($context);
442 make_version_script
($context);
443 build_documentation
($context) if $context->{build_docs
};
444 build_package_directories
($context);
445 create_tar_files
($context);
446 do_cleanup
($context) if ($cleanup);
455 mk_exim_release - Build an exim release
459 mk_exim_release [options] version
463 B<mk_exim_release> builds an exim release.
465 Starting in a populated git repo that has already been tagged for
466 release it builds docs, packages etc. Parameter is the version number
467 to build as - ie 4.72 4.72RC1, 4.86.1, etc
469 After creating the release files, they should be signed. There is another
470 helper for creating the signatures:
471 F<release-process/scripts/sign_exim_packages>.
473 Call B<mk_exim_release> about like this:
475 release-process/scripts/mk_exim_release 4.99
484 Forces debug mode. (default: no debug info)
486 =item B<--[no]delete>
488 Delete a pre-existing package directory at start. (default: don't delete)
490 =item B<--directory> I<dir>
492 Change the name of the package directory (default: F<< exim-packaging-<version> >>)
496 Display short help and exit cleanly. (default: don't do that)
500 Control the creation of B<lzip> tarballs. (default: do not use lzip)
502 =item B<--make> I<cmd>
504 Force the use of a specific C<make> command. This may be necessary if C<make> is not
505 C<gmake> (default: C<make>)
509 Display man page and exit cleanly. (default: don't do that)
511 =item B<--tar> I<cmd>
513 Use to override the path to the C<tar> command. Need GNU tar in case
514 I<lzip> is selected. (default: C<gtar>, if not found, use C<tar>)
518 Control the creation of the website. For creation of the website, the F<../exim-website>
519 directory must exist. (default: create the website)
523 Force verbose mode. (default: no verbosity)
529 Nigel Metheringham <Nigel.Metheringham@dev.intechnology.co.uk>,
530 some changes by Heiko Schlittermann <hs@schlittermann.de>
534 Copyright 2010-2016 Exim Maintainers. All rights reserved.