Fix build on Fedora 32
[exim-website.git] / script / gen
index dfb174eeb52c488ace69f0188211b349732617b1..91af773bccc8b2c1b855284e277c9fa35a258b3a 100755 (executable)
@@ -15,6 +15,7 @@ use JavaScript::Minifier::XS;
 use Pod::Usage;
 use XML::LibXML;
 use XML::LibXSLT;
+use FindBin qw'$Bin';
 
 my $canonical_url = 'https://www.exim.org/';
 
@@ -130,11 +131,21 @@ sub do_doc {
     my ( $type, $xml_path ) = @_;
 
     ## Read and validate the XML file
-    my $xml = XML::LibXML->new()->parse_file($xml_path) or die $!;
+    my $xml = XML::LibXML->new(expand_entities => 1)->parse_file($xml_path) or die $!;
 
     ## Get the version number
-    my $version = $xml->findvalue('/book/bookinfo/revhistory/revision/revnumber');
-    die "Unable to get version number\n" unless defined $version && $version =~ /^\d+(\.\d+)*$/;
+    my $version = do {
+       my $version = $xml->findvalue('/book/bookinfo/revhistory/revision/revnumber');
+       die "Unable to get version number\n"
+           unless defined $version and $version =~ /^
+               (?<version>
+                   \d+                     # major
+                   (?:\.\d+(?:\.\d+)?)?    # (minor(.patch))
+                   (?:\.\d+(?:\.\d+(?:\.\d+)?)?)?    # (minor(.patch.(fixes)))
+               )
+               (?:-RC\d+)?$/x;             # -RCX
+       $+{version};
+    };
 
     ## Prepend chapter filenames?
     my $prepend_chapter = $type eq 'filter' ? 'filter_' : '';
@@ -408,7 +419,7 @@ sub transform {
     $xml->documentElement()->appendTextChild( 'old_versions', $_ ) foreach old_docs_versions();
 
     ## Parse the ".xsl" file as XML
-    my $xsl = XML::LibXML->new()->parse_file($xsl_path) or die $!;
+    my $xsl = XML::LibXML->new(expand_entities => 1)->parse_file($xsl_path) or die $!;
 
     ## Generate a stylesheet from the ".xsl" XML.
     my $stylesheet = XML::LibXSLT->new()->parse_stylesheet($xsl);
@@ -464,7 +475,7 @@ sub error_help {
 ## Parse arguments
 sub parse_arguments {
 
-    my %opt = ( spec => [], filter => [], help => 0, man => 0, web => 0, minify => 1, verbose => 0, localstatic => 0 );
+    my %opt = ( spec => [], filter => [], help => 0, man => 0, web => 0, minify => 1, verbose => 0, localstatic => 0, tmpl => "$Bin/../templates" );
     GetOptions(
         \%opt,      'help|h!', 'man!',      'web!',    'spec=s{1,}', 'filter=s{1,}',
         'latest=s', 'tmpl=s',  'docroot=s', 'minify!', 'verbose!',   'localstatic!'
@@ -506,11 +517,11 @@ __END__
 
 =head1 NAME
 
-gen.pl - Generate exim html documentation and website
+gen - Generate exim html documentation and website
 
 =head1 SYNOPSIS
 
-gen.pl [options]
+gen [options]
 
  Options:
    --help              display this help and exits
@@ -590,7 +601,7 @@ Generates the exim website and HTML documentation.
 
 =head1 EXAMPLE
 
-    script/gen.pl \
+    script/gen \
       --web \
       --spec docbook/*/spec.xml \
       --filter  docbook/*/filter.xml \