Blame | Last modification | View Log | RSS feed
######################################################################### Copyright (c) VIX TECHNOLOGY (AUST) LTD## Module name : jats_gen_releasenote.pl# Module type : Makefile system# Compiler(s) : Perl# Environment(s): jats## Description : Generate the package Release Note# Requires# 1) Release Note data generated by jats_get_releasenote_data.pl# 2) Target package in dpkg_archive# 3) One or more built.files.xxx.xml## Will:# Merge built.files..xml files into the release note data# Insert build meta data# Save the Release Note MetaData within the package# Generate the HTML release note - save within the package## Usage: See POD##......................................................................#require 5.008_002;use strict;use warnings;use Pod::Usage;use Getopt::Long;use XML::Simple;use File::Path;use File::Copy;use XML::Simple;use JatsError;use JatsSystem;use Getopt::Long;use Pod::Usage;use FileUtils;use JatsEnv;my $VERSION = "1.0.0"; # Update this. Inserted into meta data field# User optionsmy $opt_verbose = 1;my $opt_help = 0;my $opt_archive;my $archive_tag;my $opt_pname;my $opt_pversion;my $opt_release_note;my $opt_pvid;my $opt_outname;# Global varsour $GBE_TOOLS;my $DPKG_ROOT;my $DPKG_DOC;my $JATS_RN;## Structure to translate -archive=xxx option to archive variable# These are the various dpkg_archives known to JATS#my %Archive2Var =( 'main' => 'GBE_DPKG','store' => 'GBE_DPKG_STORE','cache' => 'GBE_DPKG_CACHE','local' => 'GBE_DPKG_LOCAL','sandbox' => 'GBE_DPKG_SBOX','deploy' => 'GBE_DPLY',);#-------------------------------------------------------------------------------# Function : Main Entry## Description :## Inputs :## Returns :#{my $result = GetOptions ("help+" => \$opt_help, # flag, multiple use allowed"manual:3" => \$opt_help,"verbose:+" => \$opt_verbose, # flag"archive=s" => \$opt_archive, # string# "pname=s" => \$opt_pname, # string# "pversion=s" => \$opt_pversion, # string"releasenote=s" => \$opt_release_note, # string);## Process help and manual options#pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);pod2usage(-verbose => 1) if ($opt_help == 2 );pod2usage(-verbose => 2) if ($opt_help > 2);ErrorConfig( 'name' =>'GenRn', 'verbose' => $opt_verbose );## Needed EnvVars#EnvImport ('GBE_TOOLS');$JATS_RN = catdir($GBE_TOOLS, 'RELEASENOTES');Error("Release Note tools not found", $JATS_RN)unless (-d $JATS_RN);## Sanity Check## Error("Package Name not provided") unless $opt_pname;# Error("Package Version not provided") unless $opt_pversion;Error("Release Note data not provided") unless $opt_release_note;Error("Release Note data not found") unless -f $opt_release_note;## Determine the target archive# The default archive is GBE_DPKG, but this may be changed#$opt_archive = 'main' unless ( $opt_archive );my $archive_tag = $Archive2Var{$opt_archive};Error("Unknown archive specified: $opt_archive")unless ( $archive_tag );$DPKG_ROOT = $ENV{$archive_tag} || '';Verbose ("Archive Variable: $archive_tag" );Verbose2 ("Archive Path: $DPKG_ROOT" );## Process the release note and extract essential information#processReleaseNote();## Locate the target package#$DPKG_ROOT = catdir($DPKG_ROOT, $opt_pname, $opt_pversion);Verbose ("Package Path: $DPKG_ROOT" );Error ("Package not found in archive", $DPKG_ROOT) unless -d $DPKG_ROOT;## Locate the release note data file# This was created as a prerequisite to the build# Note: windows requires '/' in the file list#my @filesList;foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {$item =~ s~\\~/~g;push @filesList, $item;}Error("No file list found within the package") unless (scalar @filesList > 0);## Generate the name of the release note# RELEASE_NOTES_PVID_PKGNAME_CLEANV.html#my $cleanv = $opt_pversion;$cleanv =~ s~\.~_~g;$opt_outname = join('_','RELEASE_NOTES',$opt_pvid,$opt_pname,$cleanv,) . '.html';Verbose("Note Name: $opt_outname");## Create output directory within the package#$DPKG_DOC = catdir($DPKG_ROOT, 'doc');mkpath($DPKG_DOC, 0, 0775);## Merge the Release Note and the various file lists into a single# XML file. Keep the file local#System('--NoShell', '--Exit', 'java', '-jar',catdir($JATS_RN, 'saxon9he.jar'),'-xsl:' . catdir($JATS_RN, 'merge.xslt'),"-s:$opt_release_note",'fileList=' . join(',', @filesList),'-o:' . 'built.files.releasenote.xml');## Generate the HTML Release Note# Output directly to the body of the package#System('--NoShell', '--Exit', 'java', '-jar',catdir($JATS_RN, 'saxon9he.jar'),'-xsl:' . catdir($JATS_RN, 'releaseNote2html.xslt'),'-s:' . 'built.files.releasenote.xml',"-o:" . catdir($DPKG_DOC, $opt_outname));## Transfer the XML database directly into the package#unless( File::Copy::copy('built.files.releasenote.xml', catdir($DPKG_DOC, 'release_note.xml')) ){Error("Cannot transfer XML release note", $!);}## All done#exit 0;}#-------------------------------------------------------------------------------# Function : processReleaseNote## Description :## Inputs :## Returns :#sub processReleaseNote{my $xml = XMLin($opt_release_note);foreach my $item ( qw (name version pvid) ) {Error("Unexpected ReleaseNote format: package $item")unless (exists $xml->{package}{$item});}$opt_pname = $xml->{package}{name};$opt_pversion = $xml->{package}{version};$opt_pvid = $xml->{package}{pvid};Verbose("Package Name: $opt_pname") ;Verbose("Package Version: $opt_pversion") ;Verbose("Package Pvid: $opt_pvid") ;}#-------------------------------------------------------------------------------# Documentation#=pod=for htmltoc SYSUTIL::=head1 NAMEjats_get_releasenote_data - Get Release Note Data=head1 SYNOPSISjats get_releasenote_data [options]Options:-help - Brief help message-help -help - Detailed help message-man - Full documentation-verbose - Display additional progress messages-pvid=nn - PVID of package to process-outfile=name - [Optional] Name of the output XML file=head1 OPTIONS=over 8=item B<-help>Print a brief help message and exits.=item B<-help -help>Print a detailed help message with an explanation for each option.=item B<-man>Prints the manual page and exits.=item B<-pvid=nn>This option provides identifies the PackageVersion to be processed.This option is mandatory.=item B<-outfile=name>This option specifies the output file name.If not provided by the user the output filename will be created in the current directoryand it will be named after the package name and package version.If the filename does not end in .xml, then .xml will be appended to the file name.=back=head1 DESCRIPTIONThis utility program is used to extract sufficient information from Release Manager and otherassociated databases so that a Release Note can be created.The extracted data is stored in an XML format. The intent is that XSLT will be used to createan HTML based release note.=head1 EXAMPLE=head2 jats get_releasenote_data -pvid=983058 -outfile=tmpdata.xmlThis will locate a package-version with an id of 983058, extrat required information and createan XML file called tmpdata.xml.=cut