+sub make_version_script {
+ my $context = shift;
+
+ my $variant = substr( $context->{release}, length($context->{trelease}) );
+ if ( $context->{release} ne $context->{trelease} . $variant ) {
+ die "Broken version numbering, I'm buggy";
+ }
+
+ my $srcdir = File::Spec->catdir( $context->{release_tree}, 'src', 'src' );
+ chdir $srcdir or die "chdir $srcdir: $!\n";
+
+ if ( -f "version.sh" ) {
+ print( "WARNING: version.sh already exists - leaving it in place\n" );
+ return;
+ }
+
+ # Currently (25. Feb. 2016) the mk_exim_release.pl up to now can't
+ # deal with security releases.!? So we need a current
+ # mk_exim_release.pl. But if we use a current (master), the
+ # reversion script returns wrong version info (it's running inside
+ # the Git tree and uses git --describe, which always returns the
+ # current version of master.) I do not want to change the old
+ # reversion scripts (in 4.86.1, 4.85.1).
+ #
+ # Thus we've to provide the version.sh, based on the info we have
+ # about the release. If reversion finds this, it doesn't try to find
+ # it's own way to get a valid version number from the git.
+ open(my $v, '>', 'version.sh') or die "Can't open '>version.sh' $!\n";
+ print {$v} <<__;
+# initial version automatically generated from $0
+EXIM_RELEASE_VERSION=$context->{major}
+EXIM_VARIANT_VERSION=@{[$context->{minor}?'_'.$context->{minor}:'']}
+EXIM_COMPILE_NUMBER=0
+__
+ close($v);
+ unlink 'version.h';
+ return;
+
+ # Later, if we get the reversion script fixed, we can call it again.
+ # For now (25. Feb. 2016) we'll leave it unused.
+ my @cmd = ("../scripts/reversion", "release", $context->{tag});
+ print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
+ system(@cmd) == 0 || croak "reversion failed";
+
+ unlink "version.h";
+
+ -f "version.sh" or die "failed to create version.sh";
+}
+
+# ------------------------------------------------------------------
+
+sub build_html_documentation {
+ my $context = shift;
+
+ my $genpath = $context->{webgen_base} . '/script/gen.pl';
+ my $templates = $context->{webgen_base} . '/templates';
+ my $dir = File::Spec->catdir( $context->{release_tree}, 'html' );
+ my $spec = File::Spec->catfile( $context->{docbook}, 'spec.xml' );
+ my $filter = File::Spec->catfile( $context->{docbook}, 'filter.xml' );
+
+ mkdir($dir);
+
+ my @cmd = (
+ $genpath, '--spec', $spec, '--filter',
+ $filter, '--latest', $context->{trelease}, '--tmpl',
+ $templates, '--docroot', $dir, '--localstatic'
+ );
+ push @cmd, '--verbose' if $verbose or $debug;
+
+ print "Executing ", join( ' ', @cmd ), "\n";
+ system(@cmd);
+
+ # move directory into right place
+ my $sourcedir = File::Spec->catdir( $context->{docbook}, 'filter.xml' );
+
+ rename(
+ File::Spec->catdir( $dir, sprintf( 'exim-html-%s', $context->{trelease} ) ),
+ File::Spec->catdir( $context->{pkgdirs}, sprintf( 'exim-html-%s', $context->{release} ) )
+ );
+}
+
+# ------------------------------------------------------------------
+
+sub copy_docbook_files {
+ my $context = shift;
+
+ # where the generated docbook files can be found
+ my $docdir = File::Spec->catdir( $context->{release_tree}, 'doc', 'doc-docbook' );
+
+ # where the website docbook source dir is - push files to here
+ my $webdir = File::Spec->catdir( $context->{webgen_base}, 'docbook', $context->{trelease} );
+ mkpath( $webdir, { verbose => ( $verbose || $debug ) } );
+
+ foreach my $file ( 'spec.xml', 'filter.xml' ) {
+ my $from = File::Spec->catfile( $docdir, $file );
+ my $to = File::Spec->catfile( $context->{docbook}, $file );
+ my $webto = File::Spec->catfile( $webdir, $file );
+ copy( $from, $to );
+ copy( $from, $webto );
+ }
+}
+
+# ------------------------------------------------------------------
+