Subversion Repositories DevTools

Rev

Rev 4468 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4468 Rev 4546
Line 30... Line 30...
30
use Getopt::Long;
30
use Getopt::Long;
31
use XML::Simple;
31
use XML::Simple;
32
use File::Path;
32
use File::Path;
33
use File::Copy;
33
use File::Copy;
34
use XML::Simple;
34
use XML::Simple;
-
 
35
use Digest::MD5;
-
 
36
use File::Find;
35
 
37
 
36
use JatsError;
38
use JatsError;
37
use JatsSystem;
39
use JatsSystem;
38
use Getopt::Long;
40
use Getopt::Long;
39
use Pod::Usage;
41
use Pod::Usage;
Line 52... Line 54...
52
my $opt_release_note;
54
my $opt_release_note;
53
my $opt_pvid;
55
my $opt_pvid;
54
my $opt_outname;
56
my $opt_outname;
55
 
57
 
56
#   Global vars
58
#   Global vars
-
 
59
our $GBE_HOSTNAME;
57
our $GBE_TOOLS;
60
our $GBE_TOOLS;
58
my $DPKG_ROOT;
61
my $DPKG_ROOT;
59
my $DPKG_DOC;
62
my $DPKG_DOC;
60
my $JATS_RN;
63
my $JATS_RN;
61
 
64
 
Line 102... Line 105...
102
    ErrorConfig( 'name'    =>'GenRn', 'verbose' => $opt_verbose );
105
    ErrorConfig( 'name'    =>'GenRn', 'verbose' => $opt_verbose );
103
 
106
 
104
    #
107
    #
105
    #   Needed EnvVars
108
    #   Needed EnvVars
106
    #
109
    #
-
 
110
    EnvImport ('GBE_HOSTNAME');
107
    EnvImport ('GBE_TOOLS');
111
    EnvImport ('GBE_TOOLS');
108
    $JATS_RN = catdir($GBE_TOOLS, 'RELEASENOTES');
112
    $JATS_RN = catdir($GBE_TOOLS, 'RELEASENOTES');
109
    Error("Release Note tools not found", $JATS_RN)
113
    Error("Release Note tools not found", $JATS_RN)
110
        unless (-d $JATS_RN);
114
        unless (-d $JATS_RN);
111
 
115
 
Line 138... Line 142...
138
 
142
 
139
    #
143
    #
140
    #   Locate the target package
144
    #   Locate the target package
141
    #
145
    #
142
    $DPKG_ROOT = catdir($DPKG_ROOT, $opt_pname, $opt_pversion);
146
    $DPKG_ROOT = catdir($DPKG_ROOT, $opt_pname, $opt_pversion);
143
    Verbose ("Package Path: $DPKG_ROOT" );
147
    Verbose ("Package Path: ", DisplayPath($DPKG_ROOT) );
144
    Error ("Package not found in archive", $DPKG_ROOT) unless -d $DPKG_ROOT;
148
    Error ("Package not found in archive", $DPKG_ROOT) unless -d $DPKG_ROOT;
145
 
149
 
146
    #
150
    #
147
    #   Locate the release note data file
151
    #   Locate the release note data file
148
    #   This was created as a prerequisite to the build
152
    #   This was created as a prerequisite to the build
Line 151... Line 155...
151
    my @filesList;
155
    my @filesList;
152
    foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {
156
    foreach my $item ( glob(catdir($DPKG_ROOT, 'built.files.*.xml'))) {
153
        $item =~ s~\\~/~g;
157
        $item =~ s~\\~/~g;
154
        push @filesList, $item;
158
        push @filesList, $item;
155
    }
159
    }
-
 
160
    unless (scalar @filesList > 0)
-
 
161
    {
-
 
162
        #
-
 
163
        #   No filelist found in the package
-
 
164
        #   This may occur for packages that did not go though the build system
-
 
165
        #   Create a package-list
-
 
166
        #
-
 
167
        my $item = generateFileList();
-
 
168
        $item =~ s~\\~/~g;
-
 
169
        push @filesList, $item;
-
 
170
    }
156
    Error("No file list found within the package") unless (scalar @filesList > 0);
171
    Error("No file list found within the package") unless (scalar @filesList > 0);
157
 
172
 
158
    #
173
    #
159
    #   Generate the name of the release note
174
    #   Generate the name of the release note
160
    #       RELEASE_NOTES_PVID_PKGNAME_CLEANV.html
175
    #       RELEASE_NOTES_PVID_PKGNAME_CLEANV.html
Line 207... Line 222...
207
    }
222
    }
208
 
223
 
209
    #
224
    #
210
    #   All done
225
    #   All done
211
    #
226
    #
-
 
227
    Verbose ("Release Note:", DisplayPath(catdir($DPKG_DOC, $opt_outname)));
212
    exit 0;
228
    exit 0;
213
}
229
}
214
 
230
 
215
#-------------------------------------------------------------------------------
231
#-------------------------------------------------------------------------------
216
# Function        : processReleaseNote 
232
# Function        : processReleaseNote 
217
#
233
#
218
# Description     : 
234
# Description     : Extract essential information from the Release Note Data
219
#
235
#
220
# Inputs          : 
236
# Inputs          : 
221
#
237
#
222
# Returns         : 
238
# Returns         : Populates global variables 
223
#
239
#
224
sub processReleaseNote
240
sub processReleaseNote
225
{
241
{
226
    my $xml = XMLin($opt_release_note);
242
    my $xml = XMLin($opt_release_note);
227
 
243
 
Line 237... Line 253...
237
    Verbose("Package Name: $opt_pname") ;
253
    Verbose("Package Name: $opt_pname") ;
238
    Verbose("Package Version: $opt_pversion") ;
254
    Verbose("Package Version: $opt_pversion") ;
239
    Verbose("Package Pvid: $opt_pvid") ;
255
    Verbose("Package Pvid: $opt_pvid") ;
240
}
256
}
241
 
257
 
-
 
258
#-------------------------------------------------------------------------------
-
 
259
# Function        : generateFileList
-
 
260
#                   generateFileListProc 
-
 
261
#
-
 
262
# Description     : A fileList has not been found in the target package
-
 
263
#                   Perhaps the package was not created by the build system
-
 
264
#                   
-
 
265
#                   Generate a fileList        
-
 
266
#
-
 
267
# Inputs          : None
-
 
268
#
-
 
269
# Returns         : Path to the generated file list
-
 
270
#
-
 
271
my @generateFileListData;
-
 
272
my $baseLength;
-
 
273
sub generateFileList
-
 
274
{
-
 
275
    my $outXmlFile;
-
 
276
    Verbose("Generate internal filelist - none found in package");
-
 
277
 
-
 
278
    #
-
 
279
    #   Scan the package and process each file
-
 
280
    #
-
 
281
    $baseLength = length($DPKG_ROOT);
-
 
282
    File::Find::find( \&generateFileListProc, $DPKG_ROOT );
-
 
283
 
-
 
284
    #
-
 
285
    #   Write out XML of the Generated file list
-
 
286
    #
-
 
287
    my $data;
-
 
288
    $data->{file} = \@generateFileListData;
-
 
289
 
-
 
290
    #
-
 
291
    #   Write out sections of XML
-
 
292
    #       Want control over the output order
-
 
293
    #       Use lots of attributes and only elements for arrays
-
 
294
    #       Save as one attribute per line - for readability
-
 
295
    #
-
 
296
    $outXmlFile = catdir($DPKG_ROOT,"built.files.$GBE_HOSTNAME.xml");
-
 
297
 
-
 
298
    Verbose2('Meta File', $outXmlFile);
-
 
299
    my $xs = XML::Simple->new( NoAttr =>0, AttrIndent => 1 );
-
 
300
 
-
 
301
    open (my $XML, '>', $outXmlFile) || Error ("Cannot create output file: $outXmlFile", $!);
-
 
302
    $xs->XMLout($data, 
-
 
303
                'RootName' => 'files', 
-
 
304
                'XMLDecl'  => '<?xml version="1.0" encoding="UTF-8"?>',
-
 
305
                'OutputFile' => $XML);
-
 
306
    close $XML;
-
 
307
 
-
 
308
    return $outXmlFile;
-
 
309
}
-
 
310
 
-
 
311
sub generateFileListProc
-
 
312
{
-
 
313
    my %data;
-
 
314
    my $md5sum;
-
 
315
    my $source = $File::Find::name;
-
 
316
    my $type = 'dir';
-
 
317
 
-
 
318
    my $target = substr($source, $baseLength);
-
 
319
    $target =~ s~^/~~;
-
 
320
    $target =~ s~/$~~;
-
 
321
    Verbose2("GenFileList: $source, $target");
-
 
322
    return if (length ($target) == 0);
-
 
323
 
-
 
324
    if (-l $source)
-
 
325
    {
-
 
326
        $type = 'link';
-
 
327
    }
-
 
328
    elsif ( -f $source)
-
 
329
    {
-
 
330
        $type = 'file';
-
 
331
        Verbose2("Calculate MD5 Digest: $source");
-
 
332
        open(my $fh , $source) or Error ("Can't open '$source': $!");
-
 
333
        binmode $fh, ':crlf';
-
 
334
        $md5sum = Digest::MD5->new->addfile($fh)->hexdigest;
-
 
335
        close $fh;
-
 
336
    }
-
 
337
 
-
 
338
 
-
 
339
    if (-d $source)
-
 
340
    {
-
 
341
        $data{path} = $target;
-
 
342
    }
-
 
343
    else
-
 
344
    {
-
 
345
        $data{path} = StripFileExt($target);
-
 
346
        $data{name} = StripDir($target);
-
 
347
        if (defined $md5sum)
-
 
348
        {
-
 
349
            $data{size} = (stat($source))[7];
-
 
350
            $data{md5sum} = $md5sum;
-
 
351
        }
-
 
352
    }
-
 
353
 
-
 
354
    $data{fullname} = $target;
-
 
355
    $data{type} = $type;
-
 
356
    $data{machtype} = 'unknown';
-
 
357
    $data{host} = $GBE_HOSTNAME;
-
 
358
 
-
 
359
    # Put a nice '/' on the end of the patch elements
-
 
360
    $data{path} .= '/'
-
 
361
        if ( exists ($data{path}) && length($data{path}) > 0);
-
 
362
 
-
 
363
    push @generateFileListData, \%data;
-
 
364
}
-
 
365
 
242
 
366
 
243
#-------------------------------------------------------------------------------
367
#-------------------------------------------------------------------------------
244
#   Documentation
368
#   Documentation
245
#
369
#
246
 
370