+sub adjust_version_extension {
+ my $context = shift;
+
+ return if ($context->{release} eq $context->{trelease});
+
+ 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' );
+ my $version_h = File::Spec->catfile( $srcdir, 'version.h' );
+
+ my $fh = new IO::File $version_h, 'r';
+ die "Cannot read version.h: $!\n" unless ( defined $fh );
+ my @lines = <$fh>;
+ $fh->close() or die "Failed to close-read($version_h): $!\n";
+
+ my $found = 0;
+ my $i;
+ for ( $i = 0 ; $i < @lines ; ++$i ) {
+ if ( $lines[$i] =~ /EXIM_VARIANT_VERSION/ ) {
+ $found = 1;
+ last;
+ }
+ }
+ die "Cannot find version.h EXIM_VARIANT_VERSION\n" unless $found;
+ unless ( $lines[$i] =~ m/^\s* \# \s* define \s+ EXIM_VARIANT_VERSION \s+ "(.*)" \s* $/x ) {
+ die "Broken version.h EXIM_VARIANT_VERSION line\n";
+ }
+ if ( length $1 ) {
+ print( "WARNING: version.h has a variant tag already defined: $1\n" );
+ print( " not changing that tag\n" );
+ return;
+ }
+
+ $lines[$i] = qq{#define EXIM_VARIANT_VERSION\t\t"$variant"\n};
+ # deliberately not verbose constrained:
+ print( "Adjusting version.h for $variant release.\n" );
+
+ $fh = new IO::File $version_h, "w";
+ die "Cannot write version.h: $!\n" unless ( defined $fh );
+ $fh->print( @lines );
+ $fh->close() or die "Failed to close-write($version_h): $!\n";
+}
+
+# ------------------------------------------------------------------
+
+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 );
+
+ 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 );
+ }
+}
+
+# ------------------------------------------------------------------
+