Back to home page

Enduro/X

 
 

    


0001 #!/usr/bin/perl
0002 
0003 
0004 ################################################################################
0005 # @(#) Generate license texts
0006 # Run manually once new licese is added
0007 ################################################################################
0008 
0009 use strict;
0010 use warnings;
0011 
0012 my @files = glob("*.txt");
0013 
0014 my $outfile="../doc/third_party_licences.adoc";
0015 
0016 # here i 'open' the file, saying i want to write to it with the '>>' symbol
0017 open (FILE, "> $outfile") || die "problem opening $outfile\n";
0018 
0019 
0020 print FILE <<EOS;
0021 Third party library licenses used by Enduro/X
0022 =============================================
0023 
0024 :sectnums:
0025 :chapter-label:
0026 :doctype: book
0027 
0028 EOS
0029 
0030 #
0031 # Loop over the license texts 
0032 #
0033 foreach my $file (@files)
0034 {
0035 
0036     # Parse the file name
0037     # mask: <module>_<lic_type>.txt
0038     # module may contain _, which later needs to be replaced with
0039     # spaces
0040     
0041     my ($module, $ltype) = ($file=~m/^(.*)_([^_]+)\.txt$/);
0042     $module =~ s/_/ /g;
0043     
0044     
0045     # convert the string to lowercase
0046     $ltype = lc $ltype;
0047     $ltype = ucfirst $ltype;
0048     
0049     #print "$file module [$module] type [$ltype]\n";
0050     
0051     
0052     print FILE "== $ltype for \"$module\" library\n\n";
0053     
0054     print FILE "--------------------------------------------------------------------------------\n\n";
0055     open(READH, '<', $file)
0056         or die "Could not open file '$file' $!";
0057     
0058     while (my $row = <READH>) 
0059     {
0060         chomp $row; 
0061         chop($row) if ($row =~ m/\r$/);
0062         print FILE "$row\n";
0063     }
0064     
0065     print FILE "\n";
0066 
0067     close(READH);
0068     
0069     print FILE "\n--------------------------------------------------------------------------------\n\n";
0070     
0071 }
0072 
0073 close(FILE);
0074 
0075 exit 0;