Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4455 dpurdie 1
########################################################################
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
3
#
4
# Module name   : jats_gen_releasenote.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Generate the package Release Note
10
#                 Requires
11
#                   1) Release Note data generated by jats_get_releasenote_data.pl
12
#                   2) Target package in dpkg_archive
13
#                   3) One or more built.files.xxx.xml
14
#
15
#                 Will:
16
#                   Merge built.files..xml files into the release note data
17
#                   Insert build meta data
18
#                   Save the Release Note MetaData within the package
19
#                   Generate the HTML release note - save within the package
20
#
21
# Usage:        See POD
22
#
23
#......................................................................#
24
 
25
require 5.008_002;
26
use strict;
27
use warnings;
28
 
29
use Pod::Usage;
30
use Getopt::Long;
31
use XML::Simple;
32
use File::Path;
33
use File::Copy;
34
use XML::Simple;
35
 
36
use JatsError;
37
use JatsSystem;
38
use Getopt::Long;
39
use Pod::Usage;
40
use FileUtils;
41
use JatsEnv;
42
 
43
my $VERSION = "1.0.0";                                      # Update this. Inserted into meta data field
44
 
45
# User options
46
my $opt_verbose = 1;
47
my $opt_help = 0;
48
my $opt_archive;
49
my $archive_tag;
50
my $opt_pname;
51
my $opt_pversion;
52
my $opt_release_note;
53
my $opt_pvid;
54
my $opt_outname;
55
 
56
#   Global vars
57
our $GBE_TOOLS;
58
my $DPKG_ROOT;
59
my $DPKG_DOC;
60
my $JATS_RN;
61
 
62
 
63
#
64
#   Structure to translate -archive=xxx option to archive variable
65
#   These are the various dpkg_archives known to JATS
66
#
67
my %Archive2Var =( 'main'       =>  'GBE_DPKG',
68
                   'store'      =>  'GBE_DPKG_STORE',
69
                   'cache'      =>  'GBE_DPKG_CACHE',
70
                   'local'      =>  'GBE_DPKG_LOCAL',
71
                   'sandbox'    =>  'GBE_DPKG_SBOX',
72
                   'deploy'     =>  'GBE_DPLY',
73
                   );
74
 
75
#-------------------------------------------------------------------------------
76
# Function        : Main Entry
77
#
78
# Description     :
79
#
80
# Inputs          :
81
#
82
# Returns         :
83
#
84
{
85
    my $result = GetOptions (
86
                    "help+"         => \$opt_help,          # flag, multiple use allowed
87
                    "manual:3"      => \$opt_help,
88
                    "verbose:+"     => \$opt_verbose,       # flag
89
                    "archive=s"     => \$opt_archive,       # string
90
#                    "pname=s"       => \$opt_pname,         # string
91
#                    "pversion=s"    => \$opt_pversion,      # string
92
                    "releasenote=s" => \$opt_release_note,  # string
93
                    );
94
 
95
    #
96
    #   Process help and manual options
97
    #
98
    pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
99
    pod2usage(-verbose => 1)  if ($opt_help == 2 );
100
    pod2usage(-verbose => 2)  if ($opt_help > 2);
101
 
102
    ErrorConfig( 'name'    =>'GenRn', 'verbose' => $opt_verbose );
103
 
104
    #
105
    #   Needed EnvVars
106
    #
107
    EnvImport ('GBE_TOOLS');
108
    $JATS_RN = catdir($GBE_TOOLS, 'RELEASENOTES');
109
    Error("Release Note tools not found", $JATS_RN)
110
        unless (-d $JATS_RN);
111
 
112
 
113
    #
114
    #   Sanity Check
115
    #
116
#    Error("Package Name not provided") unless $opt_pname;
117
#    Error("Package Version not provided") unless $opt_pversion;
118
    Error("Release Note data not provided") unless $opt_release_note;
119
    Error("Release Note data not found") unless -f $opt_release_note;
120
 
121
 
122
    #
123
    #   Determine the target archive
124
    #   The default archive is GBE_DPKG, but this may be changed
125
    #
126
    $opt_archive = 'main' unless ( $opt_archive );
127
    my $archive_tag = $Archive2Var{$opt_archive};
128
    Error("Unknown archive specified: $opt_archive")
129
        unless ( $archive_tag );
130
    $DPKG_ROOT = $ENV{$archive_tag} || '';
131
    Verbose ("Archive Variable: $archive_tag" );
132
    Verbose2 ("Archive Path: $DPKG_ROOT" );
133
 
134
    #
135
    #   Process the release note and extract essential information
136
    #
137
    processReleaseNote();
138
 
139
    #
140
    #   Locate the target package
141
    #
142
    $DPKG_ROOT = catdir($DPKG_ROOT, $opt_pname, $opt_pversion);
143
    Verbose ("Package Path: $DPKG_ROOT" );
144
    Error ("Package not found in archive", $DPKG_ROOT) unless -d $DPKG_ROOT;
145
 
146
    #
147
    #   Locate the release note data file
148
    #   This was created as a prerequisite to the build
149
    #   Note: windows requires '/' in the file list
150
    #
151
    my @filesList;
152
    foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {
153
        $item =~ s~\\~/~g;
154
        push @filesList, $item;
155
    }
156
    Error("No file list found within the package") unless (scalar @filesList > 0);
157
 
158
    #
159
    #   Generate the name of the release note
160
    #       RELEASE_NOTES_PVID_PKGNAME_CLEANV.html
161
    #
162
    my $cleanv = $opt_pversion;
163
    $cleanv =~ s~\.~_~g;
164
    $opt_outname = join('_',
165
                        'RELEASE_NOTES',
166
                        $opt_pvid,
167
                        $opt_pname,
168
                        $cleanv,    
169
                        ) . '.html';
170
    Verbose("Note Name: $opt_outname");
171
 
172
    #
173
    #   Create output directory within the package
174
    #
175
    $DPKG_DOC = catdir($DPKG_ROOT, 'doc');
176
    mkpath($DPKG_DOC, 0, 0775);
177
 
178
    #
179
    #   Merge the Release Note and the various file lists into a single
180
    #   XML file. Keep the file local
181
    #
182
    System('--NoShell', '--Exit', 'java', '-jar', 
183
           catdir($JATS_RN, 'saxon9he.jar'), 
184
           '-xsl:' . catdir($JATS_RN, 'merge.xslt'),
185
           "-s:$opt_release_note",
186
           'fileList=' . join(',', @filesList),
187
           '-o:' . 'built.files.releasenote.xml'
188
            );
189
 
190
    #
191
    #   Generate the HTML Release Note
192
    #   Output directly to the body of the package
193
    #
194
    System('--NoShell', '--Exit', 'java', '-jar', 
195
           catdir($JATS_RN, 'saxon9he.jar'), 
196
           '-xsl:' . catdir($JATS_RN, 'releaseNote2html.xslt'),
197
           '-s:' . 'built.files.releasenote.xml',
198
           "-o:" . catdir($DPKG_DOC, $opt_outname)
199
            );
200
 
201
    #
202
    #   Transfer the XML database directly into the package
203
    #
204
    unless( File::Copy::copy('built.files.releasenote.xml', catdir($DPKG_DOC, 'release_note.xml')) )
205
    {
206
        Error("Cannot transfer XML release note", $!);
207
    }
208
 
209
    #
210
    #   All done
211
    #
212
    exit 0;
213
}
214
 
215
#-------------------------------------------------------------------------------
216
# Function        : processReleaseNote 
217
#
218
# Description     : 
219
#
220
# Inputs          : 
221
#
222
# Returns         : 
223
#
224
sub processReleaseNote
225
{
226
    my $xml = XMLin($opt_release_note);
227
 
228
    foreach my $item ( qw (name version pvid) ) {
229
        Error("Unexpected ReleaseNote format: package $item")
230
            unless (exists $xml->{package}{$item});
231
    }
232
 
233
    $opt_pname = $xml->{package}{name};
234
    $opt_pversion = $xml->{package}{version};
235
    $opt_pvid = $xml->{package}{pvid};
236
 
237
    Verbose("Package Name: $opt_pname") ;
238
    Verbose("Package Version: $opt_pversion") ;
239
    Verbose("Package Pvid: $opt_pvid") ;
240
}
241
 
242
 
243
#-------------------------------------------------------------------------------
244
#   Documentation
245
#
246
 
247
=pod
248
 
249
=for htmltoc    SYSUTIL::
250
 
251
=head1 NAME
252
 
253
jats_get_releasenote_data - Get Release Note Data
254
 
255
=head1 SYNOPSIS
256
 
257
 jats get_releasenote_data [options]
258
 
259
 Options:
260
    -help              - Brief help message
261
    -help -help        - Detailed help message
262
    -man               - Full documentation
263
    -verbose           - Display additional progress messages
264
    -pvid=nn           - PVID of package to process
265
    -outfile=name      - [Optional] Name of the output XML file
266
 
267
 
268
=head1 OPTIONS
269
 
270
=over 8
271
 
272
=item B<-help>
273
 
274
Print a brief help message and exits.
275
 
276
=item B<-help -help>
277
 
278
Print a detailed help message with an explanation for each option.
279
 
280
=item B<-man>
281
 
282
Prints the manual page and exits.
283
 
284
=item B<-pvid=nn>
285
 
286
This option provides identifies the PackageVersion to be processed.
287
 
288
This option is mandatory.
289
 
290
=item B<-outfile=name>
291
 
292
This option specifies the output file name.
293
 
294
If not provided by the user the output filename will be created in the current directory
295
and it will be named after the package name and package version.
296
 
297
If the filename does not end in .xml, then .xml will be appended to the file name.
298
 
299
=back
300
 
301
=head1 DESCRIPTION
302
 
303
This utility program is used to extract sufficient information from Release Manager and other
304
associated databases so that a Release Note can be created.
305
 
306
The extracted data is stored in an XML format. The intent is that XSLT will be used to create
307
an HTML based release note.
308
 
309
 
310
=head1 EXAMPLE
311
 
312
=head2 jats get_releasenote_data -pvid=983058 -outfile=tmpdata.xml
313
 
314
This will locate a package-version with an id of 983058, extrat required information and create
315
an XML file called tmpdata.xml.
316
 
317
=cut