| 4455 |
dpurdie |
1 |
########################################################################
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 4455 |
dpurdie |
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
|
| 4619 |
dpurdie |
13 |
# 3) One or more built.files.xxx.xml (optional, but desirable)
|
| 4455 |
dpurdie |
14 |
#
|
|
|
15 |
# Will:
|
| 4619 |
dpurdie |
16 |
# Merge built.files.xxx.xml files into the release note data
|
| 4455 |
dpurdie |
17 |
# Insert build meta data
|
|
|
18 |
# Save the Release Note MetaData within the package
|
|
|
19 |
# Generate the HTML release note - save within the package
|
| 4619 |
dpurdie |
20 |
# Insert Release_Contents into RM Database
|
| 4455 |
dpurdie |
21 |
#
|
|
|
22 |
# Usage: See POD
|
|
|
23 |
#
|
|
|
24 |
#......................................................................#
|
|
|
25 |
|
|
|
26 |
require 5.008_002;
|
|
|
27 |
use strict;
|
|
|
28 |
use warnings;
|
|
|
29 |
|
|
|
30 |
use Pod::Usage;
|
|
|
31 |
use Getopt::Long;
|
|
|
32 |
use XML::Simple;
|
|
|
33 |
use File::Path;
|
|
|
34 |
use File::Copy;
|
|
|
35 |
use XML::Simple;
|
| 4546 |
dpurdie |
36 |
use Digest::MD5;
|
|
|
37 |
use File::Find;
|
| 4455 |
dpurdie |
38 |
|
|
|
39 |
use JatsError;
|
|
|
40 |
use JatsSystem;
|
|
|
41 |
use Getopt::Long;
|
|
|
42 |
use Pod::Usage;
|
|
|
43 |
use FileUtils;
|
|
|
44 |
use JatsEnv;
|
| 4550 |
dpurdie |
45 |
use JatsRmApi;
|
| 4455 |
dpurdie |
46 |
|
| 4550 |
dpurdie |
47 |
use DBI;
|
|
|
48 |
|
| 4455 |
dpurdie |
49 |
my $VERSION = "1.0.0"; # Update this. Inserted into meta data field
|
|
|
50 |
|
|
|
51 |
# User options
|
| 4612 |
dpurdie |
52 |
my $opt_verbose = 0;
|
| 4455 |
dpurdie |
53 |
my $opt_help = 0;
|
|
|
54 |
my $opt_archive;
|
|
|
55 |
my $archive_tag;
|
|
|
56 |
my $opt_pname;
|
|
|
57 |
my $opt_pversion;
|
|
|
58 |
my $opt_release_note;
|
|
|
59 |
my $opt_pvid;
|
|
|
60 |
my $opt_outname;
|
| 4619 |
dpurdie |
61 |
my $opt_outputXml;
|
| 4550 |
dpurdie |
62 |
my $opt_updateRmFiles;
|
| 4612 |
dpurdie |
63 |
my $opt_workingDir;
|
| 4455 |
dpurdie |
64 |
|
|
|
65 |
# Global vars
|
| 4546 |
dpurdie |
66 |
our $GBE_HOSTNAME;
|
| 4455 |
dpurdie |
67 |
our $GBE_TOOLS;
|
|
|
68 |
my $DPKG_ROOT;
|
|
|
69 |
my $DPKG_DOC;
|
|
|
70 |
my $JATS_RN;
|
| 4612 |
dpurdie |
71 |
my $OUT_ROOT;
|
| 4455 |
dpurdie |
72 |
|
|
|
73 |
|
|
|
74 |
#
|
|
|
75 |
# Structure to translate -archive=xxx option to archive variable
|
|
|
76 |
# These are the various dpkg_archives known to JATS
|
|
|
77 |
#
|
| 4688 |
dpurdie |
78 |
my %Archive2Var =( 'main' => 'GBE_DPKG',
|
|
|
79 |
'store' => 'GBE_DPKG_STORE',
|
|
|
80 |
'cache' => 'GBE_DPKG_CACHE',
|
|
|
81 |
'local' => 'GBE_DPKG_LOCAL',
|
|
|
82 |
'sandbox' => 'GBE_DPKG_SBOX',
|
|
|
83 |
'deploy' => 'GBE_DPLY',
|
|
|
84 |
'replica' => 'GBE_DPKG_REPLICA',
|
| 4455 |
dpurdie |
85 |
);
|
|
|
86 |
|
|
|
87 |
#-------------------------------------------------------------------------------
|
|
|
88 |
# Function : Main Entry
|
|
|
89 |
#
|
|
|
90 |
# Description :
|
|
|
91 |
#
|
|
|
92 |
# Inputs :
|
|
|
93 |
#
|
|
|
94 |
# Returns :
|
|
|
95 |
#
|
|
|
96 |
{
|
|
|
97 |
my $result = GetOptions (
|
| 4550 |
dpurdie |
98 |
"help+" => \$opt_help, # flag, multiple use allowed
|
|
|
99 |
"manual:3" => \$opt_help, # flag, set value
|
|
|
100 |
"verbose:+" => \$opt_verbose, # flag, increment
|
|
|
101 |
"archive=s" => \$opt_archive, # string
|
|
|
102 |
"releasenote=s" => \$opt_release_note, # string
|
| 4612 |
dpurdie |
103 |
"UpdateRmFiles" => \$opt_updateRmFiles, # flag
|
|
|
104 |
"WorkDir=s" => \$opt_workingDir, # String
|
| 4455 |
dpurdie |
105 |
);
|
|
|
106 |
|
|
|
107 |
#
|
|
|
108 |
# Process help and manual options
|
|
|
109 |
#
|
|
|
110 |
pod2usage(-verbose => 0, -message => "Version: $VERSION") if ($opt_help == 1 || ! $result);
|
|
|
111 |
pod2usage(-verbose => 1) if ($opt_help == 2 );
|
|
|
112 |
pod2usage(-verbose => 2) if ($opt_help > 2);
|
|
|
113 |
|
|
|
114 |
ErrorConfig( 'name' =>'GenRn', 'verbose' => $opt_verbose );
|
| 4612 |
dpurdie |
115 |
InitFileUtils();
|
| 4455 |
dpurdie |
116 |
|
|
|
117 |
#
|
|
|
118 |
# Needed EnvVars
|
|
|
119 |
#
|
| 4546 |
dpurdie |
120 |
EnvImport ('GBE_HOSTNAME');
|
| 4455 |
dpurdie |
121 |
EnvImport ('GBE_TOOLS');
|
|
|
122 |
$JATS_RN = catdir($GBE_TOOLS, 'RELEASENOTES');
|
|
|
123 |
Error("Release Note tools not found", $JATS_RN)
|
|
|
124 |
unless (-d $JATS_RN);
|
|
|
125 |
|
|
|
126 |
|
|
|
127 |
#
|
|
|
128 |
# Sanity Check
|
|
|
129 |
#
|
|
|
130 |
Error("Release Note data not provided") unless $opt_release_note;
|
|
|
131 |
Error("Release Note data not found") unless -f $opt_release_note;
|
| 4612 |
dpurdie |
132 |
if (defined $opt_workingDir)
|
|
|
133 |
{
|
|
|
134 |
$opt_workingDir = FullPath($opt_workingDir);
|
|
|
135 |
Error("Working directory is not a directory") unless -d $opt_workingDir;
|
|
|
136 |
Error("Working directory is writable") unless -w $opt_workingDir;
|
|
|
137 |
}
|
| 4455 |
dpurdie |
138 |
|
|
|
139 |
#
|
|
|
140 |
# Determine the target archive
|
|
|
141 |
# The default archive is GBE_DPKG, but this may be changed
|
|
|
142 |
#
|
|
|
143 |
$opt_archive = 'main' unless ( $opt_archive );
|
|
|
144 |
my $archive_tag = $Archive2Var{$opt_archive};
|
|
|
145 |
Error("Unknown archive specified: $opt_archive")
|
|
|
146 |
unless ( $archive_tag );
|
|
|
147 |
$DPKG_ROOT = $ENV{$archive_tag} || '';
|
|
|
148 |
Verbose ("Archive Variable: $archive_tag" );
|
|
|
149 |
Verbose2 ("Archive Path: $DPKG_ROOT" );
|
|
|
150 |
|
|
|
151 |
#
|
|
|
152 |
# Process the release note and extract essential information
|
|
|
153 |
#
|
|
|
154 |
processReleaseNote();
|
|
|
155 |
|
|
|
156 |
#
|
|
|
157 |
# Locate the target package
|
|
|
158 |
#
|
|
|
159 |
$DPKG_ROOT = catdir($DPKG_ROOT, $opt_pname, $opt_pversion);
|
| 4546 |
dpurdie |
160 |
Verbose ("Package Path: ", DisplayPath($DPKG_ROOT) );
|
| 4455 |
dpurdie |
161 |
Error ("Package not found in archive", $DPKG_ROOT) unless -d $DPKG_ROOT;
|
|
|
162 |
|
| 4612 |
dpurdie |
163 |
# OUT_ROOT is really only used for testing
|
|
|
164 |
# Needs to mimic $DPKG_ROOT
|
|
|
165 |
$OUT_ROOT = defined($opt_workingDir) ? $opt_workingDir : $DPKG_ROOT;
|
|
|
166 |
Verbose2 ("Output Path: $OUT_ROOT" );
|
|
|
167 |
|
| 4455 |
dpurdie |
168 |
#
|
| 4619 |
dpurdie |
169 |
# Calculate output filenames
|
|
|
170 |
# Html Release Note:
|
|
|
171 |
# RELEASE_NOTES_PVID_PKGNAME_CLEANV.html
|
|
|
172 |
#
|
|
|
173 |
$DPKG_DOC = catdir($OUT_ROOT, 'doc');
|
|
|
174 |
$opt_outputXml = catdir($DPKG_DOC, 'release_note.xml');
|
|
|
175 |
|
|
|
176 |
my $cleanv = $opt_pversion;
|
|
|
177 |
$cleanv =~ s~\.~_~g;
|
|
|
178 |
$opt_outname = join('_',
|
|
|
179 |
'RELEASE_NOTES',
|
|
|
180 |
$opt_pvid,
|
|
|
181 |
$opt_pname,
|
|
|
182 |
$cleanv,
|
|
|
183 |
) . '.html';
|
|
|
184 |
Verbose("Note Name: $opt_outname");
|
|
|
185 |
|
|
|
186 |
#
|
| 4455 |
dpurdie |
187 |
# Locate the release note data file
|
|
|
188 |
# This was created as a prerequisite to the build
|
|
|
189 |
# Note: windows requires '/' in the file list
|
|
|
190 |
#
|
|
|
191 |
my @filesList;
|
|
|
192 |
foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {
|
|
|
193 |
$item =~ s~\\~/~g;
|
|
|
194 |
push @filesList, $item;
|
|
|
195 |
}
|
| 4546 |
dpurdie |
196 |
unless (scalar @filesList > 0)
|
|
|
197 |
{
|
| 4619 |
dpurdie |
198 |
Warning("No file list found within the package");
|
| 4546 |
dpurdie |
199 |
#
|
|
|
200 |
# No filelist found in the package
|
|
|
201 |
# This may occur for packages that did not go though the build system
|
|
|
202 |
# Create a package-list
|
|
|
203 |
#
|
|
|
204 |
my $item = generateFileList();
|
|
|
205 |
$item =~ s~\\~/~g;
|
|
|
206 |
push @filesList, $item;
|
|
|
207 |
}
|
| 4455 |
dpurdie |
208 |
|
|
|
209 |
#
|
|
|
210 |
# Create output directory within the package
|
|
|
211 |
#
|
|
|
212 |
mkpath($DPKG_DOC, 0, 0775);
|
|
|
213 |
|
|
|
214 |
#
|
|
|
215 |
# Merge the Release Note and the various file lists into a single
|
|
|
216 |
# XML file. Keep the file local
|
|
|
217 |
#
|
|
|
218 |
System('--NoShell', '--Exit', 'java', '-jar',
|
|
|
219 |
catdir($JATS_RN, 'saxon9he.jar'),
|
|
|
220 |
'-xsl:' . catdir($JATS_RN, 'merge.xslt'),
|
|
|
221 |
"-s:$opt_release_note",
|
|
|
222 |
'fileList=' . join(',', @filesList),
|
|
|
223 |
'-o:' . 'built.files.releasenote.xml'
|
|
|
224 |
);
|
|
|
225 |
|
|
|
226 |
#
|
|
|
227 |
# Generate the HTML Release Note
|
|
|
228 |
# Output directly to the body of the package
|
|
|
229 |
#
|
|
|
230 |
System('--NoShell', '--Exit', 'java', '-jar',
|
|
|
231 |
catdir($JATS_RN, 'saxon9he.jar'),
|
|
|
232 |
'-xsl:' . catdir($JATS_RN, 'releaseNote2html.xslt'),
|
|
|
233 |
'-s:' . 'built.files.releasenote.xml',
|
|
|
234 |
"-o:" . catdir($DPKG_DOC, $opt_outname)
|
|
|
235 |
);
|
|
|
236 |
|
|
|
237 |
#
|
|
|
238 |
# Transfer the XML database directly into the package
|
|
|
239 |
#
|
| 4619 |
dpurdie |
240 |
unless( File::Copy::copy('built.files.releasenote.xml', $opt_outputXml) )
|
| 4455 |
dpurdie |
241 |
{
|
| 4619 |
dpurdie |
242 |
Error("Cannot transfer XML release note", $!, $opt_outputXml);
|
| 4455 |
dpurdie |
243 |
}
|
|
|
244 |
|
|
|
245 |
#
|
| 4619 |
dpurdie |
246 |
# Delete the built.files.xxx.xml that may be present in the root of the package
|
|
|
247 |
# These are no longer needed - they have been incorporated into the release_note.xml file
|
|
|
248 |
#
|
|
|
249 |
foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {
|
|
|
250 |
unlink $item;
|
|
|
251 |
}
|
|
|
252 |
|
|
|
253 |
#
|
| 4550 |
dpurdie |
254 |
# Update the Release Manager entry - File Data
|
|
|
255 |
#
|
|
|
256 |
if ($opt_updateRmFiles)
|
|
|
257 |
{
|
|
|
258 |
updateRmFiles();
|
|
|
259 |
updateRmNoteInfo();
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
#
|
| 4455 |
dpurdie |
263 |
# All done
|
|
|
264 |
#
|
| 4546 |
dpurdie |
265 |
Verbose ("Release Note:", DisplayPath(catdir($DPKG_DOC, $opt_outname)));
|
| 4455 |
dpurdie |
266 |
exit 0;
|
|
|
267 |
}
|
|
|
268 |
|
|
|
269 |
#-------------------------------------------------------------------------------
|
|
|
270 |
# Function : processReleaseNote
|
|
|
271 |
#
|
| 4546 |
dpurdie |
272 |
# Description : Extract essential information from the Release Note Data
|
| 4455 |
dpurdie |
273 |
#
|
|
|
274 |
# Inputs :
|
|
|
275 |
#
|
| 4546 |
dpurdie |
276 |
# Returns : Populates global variables
|
| 4455 |
dpurdie |
277 |
#
|
|
|
278 |
sub processReleaseNote
|
|
|
279 |
{
|
|
|
280 |
my $xml = XMLin($opt_release_note);
|
|
|
281 |
|
|
|
282 |
foreach my $item ( qw (name version pvid) ) {
|
|
|
283 |
Error("Unexpected ReleaseNote format: package $item")
|
|
|
284 |
unless (exists $xml->{package}{$item});
|
|
|
285 |
}
|
|
|
286 |
|
|
|
287 |
$opt_pname = $xml->{package}{name};
|
|
|
288 |
$opt_pversion = $xml->{package}{version};
|
|
|
289 |
$opt_pvid = $xml->{package}{pvid};
|
|
|
290 |
|
|
|
291 |
Verbose("Package Name: $opt_pname") ;
|
|
|
292 |
Verbose("Package Version: $opt_pversion") ;
|
|
|
293 |
Verbose("Package Pvid: $opt_pvid") ;
|
|
|
294 |
}
|
|
|
295 |
|
| 4546 |
dpurdie |
296 |
#-------------------------------------------------------------------------------
|
|
|
297 |
# Function : generateFileList
|
|
|
298 |
# generateFileListProc
|
|
|
299 |
#
|
|
|
300 |
# Description : A fileList has not been found in the target package
|
|
|
301 |
# Perhaps the package was not created by the build system
|
|
|
302 |
#
|
|
|
303 |
# Generate a fileList
|
|
|
304 |
#
|
|
|
305 |
# Inputs : None
|
|
|
306 |
#
|
|
|
307 |
# Returns : Path to the generated file list
|
|
|
308 |
#
|
|
|
309 |
my @generateFileListData;
|
|
|
310 |
my $baseLength;
|
|
|
311 |
sub generateFileList
|
|
|
312 |
{
|
|
|
313 |
my $outXmlFile;
|
|
|
314 |
Verbose("Generate internal filelist - none found in package");
|
| 4455 |
dpurdie |
315 |
|
| 4546 |
dpurdie |
316 |
#
|
|
|
317 |
# Scan the package and process each file
|
|
|
318 |
#
|
|
|
319 |
$baseLength = length($DPKG_ROOT);
|
|
|
320 |
File::Find::find( \&generateFileListProc, $DPKG_ROOT );
|
|
|
321 |
|
|
|
322 |
#
|
|
|
323 |
# Write out XML of the Generated file list
|
|
|
324 |
#
|
|
|
325 |
my $data;
|
|
|
326 |
$data->{file} = \@generateFileListData;
|
|
|
327 |
|
|
|
328 |
#
|
|
|
329 |
# Write out sections of XML
|
|
|
330 |
# Want control over the output order
|
|
|
331 |
# Use lots of attributes and only elements for arrays
|
|
|
332 |
# Save as one attribute per line - for readability
|
|
|
333 |
#
|
| 4612 |
dpurdie |
334 |
$outXmlFile = catdir($OUT_ROOT,"built.files.$GBE_HOSTNAME.xml");
|
| 4546 |
dpurdie |
335 |
|
|
|
336 |
Verbose2('Meta File', $outXmlFile);
|
|
|
337 |
my $xs = XML::Simple->new( NoAttr =>0, AttrIndent => 1 );
|
|
|
338 |
|
|
|
339 |
open (my $XML, '>', $outXmlFile) || Error ("Cannot create output file: $outXmlFile", $!);
|
|
|
340 |
$xs->XMLout($data,
|
|
|
341 |
'RootName' => 'files',
|
|
|
342 |
'XMLDecl' => '<?xml version="1.0" encoding="UTF-8"?>',
|
|
|
343 |
'OutputFile' => $XML);
|
|
|
344 |
close $XML;
|
|
|
345 |
|
|
|
346 |
return $outXmlFile;
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
sub generateFileListProc
|
|
|
350 |
{
|
|
|
351 |
my %data;
|
|
|
352 |
my $md5sum;
|
|
|
353 |
my $source = $File::Find::name;
|
|
|
354 |
my $type = 'dir';
|
|
|
355 |
|
|
|
356 |
my $target = substr($source, $baseLength);
|
|
|
357 |
$target =~ s~^/~~;
|
|
|
358 |
$target =~ s~/$~~;
|
|
|
359 |
Verbose2("GenFileList: $source, $target");
|
|
|
360 |
return if (length ($target) == 0);
|
|
|
361 |
|
|
|
362 |
if (-l $source)
|
|
|
363 |
{
|
|
|
364 |
$type = 'link';
|
|
|
365 |
}
|
|
|
366 |
elsif ( -f $source)
|
|
|
367 |
{
|
|
|
368 |
$type = 'file';
|
|
|
369 |
Verbose2("Calculate MD5 Digest: $source");
|
|
|
370 |
open(my $fh , $source) or Error ("Can't open '$source': $!");
|
|
|
371 |
binmode $fh, ':crlf';
|
|
|
372 |
$md5sum = Digest::MD5->new->addfile($fh)->hexdigest;
|
|
|
373 |
close $fh;
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
|
|
|
377 |
if (-d $source)
|
|
|
378 |
{
|
|
|
379 |
$data{path} = $target;
|
|
|
380 |
}
|
|
|
381 |
else
|
|
|
382 |
{
|
|
|
383 |
$data{path} = StripFileExt($target);
|
|
|
384 |
$data{name} = StripDir($target);
|
|
|
385 |
if (defined $md5sum)
|
|
|
386 |
{
|
|
|
387 |
$data{size} = (stat($source))[7];
|
|
|
388 |
$data{md5sum} = $md5sum;
|
|
|
389 |
}
|
|
|
390 |
}
|
|
|
391 |
|
|
|
392 |
$data{fullname} = $target;
|
|
|
393 |
$data{type} = $type;
|
|
|
394 |
$data{machtype} = 'unknown';
|
|
|
395 |
$data{host} = $GBE_HOSTNAME;
|
|
|
396 |
|
|
|
397 |
# Put a nice '/' on the end of the patch elements
|
|
|
398 |
$data{path} .= '/'
|
|
|
399 |
if ( exists ($data{path}) && length($data{path}) > 0);
|
|
|
400 |
|
|
|
401 |
push @generateFileListData, \%data;
|
|
|
402 |
}
|
|
|
403 |
|
| 4550 |
dpurdie |
404 |
#-------------------------------------------------------------------------------
|
|
|
405 |
# Function : updateRmFiles
|
|
|
406 |
#
|
|
|
407 |
# Description :
|
|
|
408 |
#
|
|
|
409 |
# Inputs :
|
|
|
410 |
#
|
|
|
411 |
# Returns :
|
|
|
412 |
#
|
|
|
413 |
my $RM_DB;
|
|
|
414 |
my $updateRmFilesData;
|
|
|
415 |
sub updateRmFiles
|
|
|
416 |
{
|
|
|
417 |
my $eCount = 0;
|
|
|
418 |
#
|
|
|
419 |
# If in use the the autobuilder - which it should be, then
|
| 4612 |
dpurdie |
420 |
# modify the user name to access RM with a proxy user. This is the
|
|
|
421 |
# same method used in the 'buildtool'
|
| 4550 |
dpurdie |
422 |
#
|
| 4612 |
dpurdie |
423 |
if ($ENV{GBE_ABT} && $ENV{GBE_RM_USERNAME} && $ENV{GBE_RM_USERNAME} !~ m~]$~ )
|
| 4550 |
dpurdie |
424 |
{
|
| 4612 |
dpurdie |
425 |
Verbose("Access RM database as proxy user");
|
| 4550 |
dpurdie |
426 |
$ENV{GBE_RM_USERNAME} = $ENV{GBE_RM_USERNAME} . '[release_manager]';
|
|
|
427 |
}
|
|
|
428 |
|
|
|
429 |
#
|
|
|
430 |
# Read in the release note data base
|
|
|
431 |
#
|
|
|
432 |
my $rnDataBase = catdir($DPKG_DOC, 'release_note.xml');
|
|
|
433 |
if (! -f $rnDataBase )
|
|
|
434 |
{
|
|
|
435 |
Error("Release Note XML database not found: $!", $rnDataBase);
|
|
|
436 |
}
|
|
|
437 |
my $xml = XMLin($rnDataBase);
|
|
|
438 |
|
|
|
439 |
#
|
|
|
440 |
# Sanity Test the data
|
|
|
441 |
#
|
|
|
442 |
Error("Sanity Check Failure. PVID") unless($opt_pvid eq $xml->{package}{pvid});
|
|
|
443 |
Error("Sanity Check Failure. Name") unless($opt_pname eq $xml->{package}{name});
|
|
|
444 |
Error("Sanity Check Failure. Version") unless($opt_pversion eq $xml->{package}{version});
|
|
|
445 |
Error("Sanity Check Failure. File Section") unless(exists $xml->{files}{file});
|
| 4618 |
dpurdie |
446 |
#DebugDumpData("XML DATA", \$xml);
|
| 4550 |
dpurdie |
447 |
|
|
|
448 |
#
|
|
|
449 |
# Delete any existing entry(s)
|
|
|
450 |
#
|
|
|
451 |
updateRmFilesDelete();
|
|
|
452 |
|
|
|
453 |
#
|
|
|
454 |
# Scan each entry and pump required data into the RM Database
|
| 4618 |
dpurdie |
455 |
# The {files}{file} may be either an array or a hash XMLin appears to
|
|
|
456 |
# make some decision as to which it will be, and I can't control it
|
| 4550 |
dpurdie |
457 |
#
|
| 4618 |
dpurdie |
458 |
# When it does happen the hash key is the 'name' element
|
|
|
459 |
#
|
|
|
460 |
if (ref($xml->{files}{file}) eq 'HASH')
|
|
|
461 |
{
|
|
|
462 |
Verbose("Convert file hash to an array");
|
|
|
463 |
my @nowArray;
|
|
|
464 |
foreach my $name ( keys %{$xml->{files}{file}})
|
|
|
465 |
{
|
|
|
466 |
my $entry = $xml->{files}{file}{$name};
|
|
|
467 |
$entry->{name} = $name;
|
|
|
468 |
push @nowArray, $entry;
|
|
|
469 |
}
|
|
|
470 |
$xml->{files}{file} = \@nowArray
|
|
|
471 |
}
|
|
|
472 |
Error("Sanity Check Failure. File Section not an ARRAY") unless(ref($xml->{files}{file}) eq 'ARRAY');
|
|
|
473 |
|
|
|
474 |
#
|
|
|
475 |
# Release Manager Database will barf if there are duplicate entries
|
|
|
476 |
# Maintain a hash of items processed, and only process each once
|
|
|
477 |
#
|
|
|
478 |
my %fullNameSeen;
|
|
|
479 |
|
| 4550 |
dpurdie |
480 |
$updateRmFilesData = "";
|
|
|
481 |
foreach my $entry (@{$xml->{files}{file}})
|
|
|
482 |
{
|
|
|
483 |
#
|
| 4619 |
dpurdie |
484 |
# Ignore 'merge' entries
|
|
|
485 |
#
|
|
|
486 |
next if ((exists $entry->{type}) && ($entry->{type} eq 'merge'));
|
|
|
487 |
#
|
| 4550 |
dpurdie |
488 |
# Clean up the data
|
|
|
489 |
#
|
|
|
490 |
my $fname = $entry->{name} || '';
|
|
|
491 |
my $fpath = $entry->{path} || '';
|
|
|
492 |
my $fsize = $entry->{size} || 0;
|
|
|
493 |
my $fmd5 = $entry->{md5sum} || '';
|
|
|
494 |
$fpath =~ s~/$~~ unless $fname;
|
|
|
495 |
|
| 4618 |
dpurdie |
496 |
unless( $fullNameSeen{$fpath}{$fname} )
|
|
|
497 |
{
|
|
|
498 |
$fullNameSeen{$fpath}{$fname} = 1;
|
| 4550 |
dpurdie |
499 |
|
| 4618 |
dpurdie |
500 |
#
|
|
|
501 |
# Create SQL fragment for the insert
|
|
|
502 |
#
|
|
|
503 |
$eCount++;
|
|
|
504 |
my $entry = " INTO release_manager.release_components ( pv_id, file_name, file_path, byte_size, crc_cksum, crc_modcrc ) " .
|
|
|
505 |
" VALUES ( $opt_pvid, '$fname', '$fpath',$fsize , '$fmd5', '')";
|
|
|
506 |
$updateRmFilesData .= $entry;
|
|
|
507 |
|
|
|
508 |
# The size of the aggregation is key to performance
|
|
|
509 |
# Too big is as bad as too small
|
|
|
510 |
if (length($updateRmFilesData) > 10000)
|
|
|
511 |
{
|
|
|
512 |
updateRmFilesInsert();
|
|
|
513 |
}
|
|
|
514 |
}
|
|
|
515 |
else
|
| 4550 |
dpurdie |
516 |
{
|
| 4618 |
dpurdie |
517 |
Warning("Multiple file entries for: $fpath $fname");
|
| 4550 |
dpurdie |
518 |
}
|
|
|
519 |
}
|
|
|
520 |
updateRmFilesInsert();
|
|
|
521 |
Verbose ("Inserted $eCount entries into Release_Components");
|
|
|
522 |
}
|
|
|
523 |
|
| 4455 |
dpurdie |
524 |
#-------------------------------------------------------------------------------
|
| 4550 |
dpurdie |
525 |
# Function : updateRmFilesInsert
|
|
|
526 |
#
|
|
|
527 |
# Description : Insert entries using the partial SQL statement
|
|
|
528 |
# Must be called when the partial SQL buffer get large
|
|
|
529 |
# as well as at the end to fluch any outstanding inserts
|
|
|
530 |
#
|
|
|
531 |
# Inputs :
|
|
|
532 |
#
|
|
|
533 |
# Returns :
|
|
|
534 |
#
|
|
|
535 |
sub updateRmFilesInsert
|
|
|
536 |
{
|
|
|
537 |
if (length($updateRmFilesData) > 0)
|
|
|
538 |
{
|
|
|
539 |
executeRmQuery(
|
|
|
540 |
'updateRmFilesInsert',
|
|
|
541 |
'INSERT ALL' .$updateRmFilesData . ' SELECT 1 FROM DUAL'
|
|
|
542 |
);
|
|
|
543 |
|
|
|
544 |
$updateRmFilesData = "";
|
|
|
545 |
}
|
|
|
546 |
}
|
|
|
547 |
#-------------------------------------------------------------------------------
|
|
|
548 |
# Function : updateRmFilesDelete
|
|
|
549 |
#
|
|
|
550 |
# Description : Delete ALL entires in the 'release_components' table associated
|
|
|
551 |
# with the current pvid
|
|
|
552 |
#
|
|
|
553 |
# Needs to be done before new entries are added.
|
|
|
554 |
#
|
|
|
555 |
# Inputs :
|
|
|
556 |
#
|
|
|
557 |
# Returns :
|
|
|
558 |
#
|
|
|
559 |
sub updateRmFilesDelete
|
|
|
560 |
{
|
|
|
561 |
executeRmQuery(
|
|
|
562 |
'updateRmFilesDelete',
|
| 4612 |
dpurdie |
563 |
'delete from release_manager.release_components where pv_id=' . $opt_pvid
|
| 4550 |
dpurdie |
564 |
);
|
|
|
565 |
}
|
|
|
566 |
|
|
|
567 |
#-------------------------------------------------------------------------------
|
|
|
568 |
# Function : updateRmNoteInfo
|
|
|
569 |
#
|
|
|
570 |
# Description : Insert Release Note Info into the Release Manager Database
|
|
|
571 |
# This has the side effect that RM will see the Release Note
|
|
|
572 |
# as being fully generated.
|
|
|
573 |
#
|
|
|
574 |
# Inputs :
|
|
|
575 |
#
|
|
|
576 |
# Returns :
|
|
|
577 |
#
|
|
|
578 |
sub updateRmNoteInfo
|
|
|
579 |
{
|
|
|
580 |
#
|
|
|
581 |
# Determine the path to the Release Note in a form that is suitable for the Release Manager
|
|
|
582 |
# Database. This expects: /dpkg_archive/PkgName/PkgVer/doc/pkgFileName
|
|
|
583 |
#
|
|
|
584 |
my $rnPath = join('/', '', 'dpkg_archive', $opt_pname, $opt_pversion, 'doc', $opt_outname);
|
|
|
585 |
Verbose("RN_INFO:", $rnPath);
|
|
|
586 |
|
|
|
587 |
# Into the database
|
|
|
588 |
executeRmQuery (
|
|
|
589 |
'updateRmNoteInfo',
|
|
|
590 |
'update release_manager.package_versions set release_notes_info=\'' . $rnPath . '\' where pv_id=' . $opt_pvid
|
|
|
591 |
);
|
|
|
592 |
}
|
|
|
593 |
|
|
|
594 |
#-------------------------------------------------------------------------------
|
|
|
595 |
# Function : executeRmQuery
|
|
|
596 |
#
|
|
|
597 |
# Description : Execute a simple RM query. One that does not expect any return data
|
|
|
598 |
#
|
|
|
599 |
# Inputs : $fname - OprName, for error reporting
|
|
|
600 |
# $m_sqlstr - SQL String
|
|
|
601 |
#
|
|
|
602 |
# Returns : Will exit on error
|
|
|
603 |
#
|
|
|
604 |
sub executeRmQuery
|
|
|
605 |
{
|
|
|
606 |
my ($fname, $m_sqlstr) = @_;
|
|
|
607 |
|
|
|
608 |
#
|
|
|
609 |
# Connect to the Database - once
|
|
|
610 |
#
|
|
|
611 |
connectRM(\$RM_DB, 0) unless $RM_DB;
|
|
|
612 |
|
| 4552 |
dpurdie |
613 |
Verbose2('ExecuteQuery:', $fname);
|
| 4550 |
dpurdie |
614 |
#
|
|
|
615 |
# Create the full SQL statement
|
|
|
616 |
#
|
|
|
617 |
my $sth = $RM_DB->prepare($m_sqlstr);
|
|
|
618 |
if ( defined($sth) )
|
|
|
619 |
{
|
|
|
620 |
if ( $sth->execute() )
|
|
|
621 |
{
|
|
|
622 |
$sth->finish();
|
|
|
623 |
}
|
|
|
624 |
else
|
|
|
625 |
{
|
|
|
626 |
Error("$fname: Execute failure: $m_sqlstr", $sth->errstr() );
|
|
|
627 |
}
|
|
|
628 |
}
|
|
|
629 |
else
|
|
|
630 |
{
|
|
|
631 |
Error("$fname: Prepare failure");
|
|
|
632 |
}
|
|
|
633 |
}
|
|
|
634 |
|
|
|
635 |
|
|
|
636 |
#-------------------------------------------------------------------------------
|
| 4455 |
dpurdie |
637 |
# Documentation
|
|
|
638 |
#
|
|
|
639 |
|
|
|
640 |
=pod
|
|
|
641 |
|
|
|
642 |
=for htmltoc SYSUTIL::
|
|
|
643 |
|
|
|
644 |
=head1 NAME
|
|
|
645 |
|
| 4550 |
dpurdie |
646 |
jats_gen_releasenote - Generate a Release Note
|
| 4455 |
dpurdie |
647 |
|
|
|
648 |
=head1 SYNOPSIS
|
|
|
649 |
|
| 4550 |
dpurdie |
650 |
jats jats_gen_releasenote [options]
|
| 4455 |
dpurdie |
651 |
|
|
|
652 |
Options:
|
|
|
653 |
-help - Brief help message
|
|
|
654 |
-help -help - Detailed help message
|
|
|
655 |
-man - Full documentation
|
|
|
656 |
-verbose - Display additional progress messages
|
|
|
657 |
-outfile=name - [Optional] Name of the output XML file
|
| 4468 |
dpurdie |
658 |
-archive=name - [Optional] Name package archive
|
|
|
659 |
-releasenote=path - Path to the Release Note Data
|
| 4550 |
dpurdie |
660 |
-UpdateRmFiles - Update the Files list in Release Manager
|
| 4455 |
dpurdie |
661 |
|
|
|
662 |
|
|
|
663 |
=head1 OPTIONS
|
|
|
664 |
|
|
|
665 |
=over 8
|
|
|
666 |
|
|
|
667 |
=item B<-help>
|
|
|
668 |
|
|
|
669 |
Print a brief help message and exits.
|
|
|
670 |
|
|
|
671 |
=item B<-help -help>
|
|
|
672 |
|
|
|
673 |
Print a detailed help message with an explanation for each option.
|
|
|
674 |
|
|
|
675 |
=item B<-man>
|
|
|
676 |
|
|
|
677 |
Prints the manual page and exits.
|
|
|
678 |
|
|
|
679 |
=item B<-pvid=nn>
|
|
|
680 |
|
|
|
681 |
This option provides identifies the PackageVersion to be processed.
|
|
|
682 |
|
|
|
683 |
This option is mandatory.
|
|
|
684 |
|
|
|
685 |
=item B<-outfile=name>
|
|
|
686 |
|
|
|
687 |
This option specifies the output file name.
|
|
|
688 |
|
|
|
689 |
If not provided by the user the output filename will be created in the current directory
|
|
|
690 |
and it will be named after the package name and package version.
|
|
|
691 |
|
|
|
692 |
If the filename does not end in .xml, then .xml will be appended to the file name.
|
|
|
693 |
|
| 4550 |
dpurdie |
694 |
=item B<-UpdateRmFiles>
|
|
|
695 |
|
|
|
696 |
This option will case the utility to ppdate the Files list in Release Manager.
|
|
|
697 |
|
| 4619 |
dpurdie |
698 |
The existing file list will be replaced by the one within the package.
|
| 4550 |
dpurdie |
699 |
|
|
|
700 |
Note: Write Access to Release Manager is required.
|
|
|
701 |
|
| 4455 |
dpurdie |
702 |
=back
|
|
|
703 |
|
|
|
704 |
=head1 DESCRIPTION
|
|
|
705 |
|
|
|
706 |
This utility program is used to extract sufficient information from Release Manager and other
|
|
|
707 |
associated databases so that a Release Note can be created.
|
|
|
708 |
|
|
|
709 |
The extracted data is stored in an XML format. The intent is that XSLT will be used to create
|
|
|
710 |
an HTML based release note.
|
|
|
711 |
|
|
|
712 |
|
|
|
713 |
=head1 EXAMPLE
|
|
|
714 |
|
| 4619 |
dpurdie |
715 |
=head2 jats jats_gen_releasenote -releasenote=/tmp/myreleasenote.xml
|
| 4455 |
dpurdie |
716 |
|
| 4619 |
dpurdie |
717 |
This will process release note data in the specified XML file.
|
| 4455 |
dpurdie |
718 |
|
|
|
719 |
=cut
|