Subversion Repositories DevTools

Rev

Rev 4419 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4417 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
4417 dpurdie 3
#
4
# Module name   : jats_deploy_builder.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
7
# Environment(s): jats
8
#
9
# Description   : Extract Data from RM in order to generate a deployment
10
#                 structure
11
#
12
#                 Creates a directory structure and maintain symlinks
13
#
14
# Usage:        See POD
15
#
16
#......................................................................#
17
 
18
require 5.008_002;
19
use strict;
20
use warnings;
21
 
22
use Pod::Usage;
23
use Getopt::Long;
24
use POSIX qw(strftime);
25
use File::Path;
26
use File::Basename;
27
 
28
use JatsError;
29
use JatsSystem;
30
use Getopt::Long;
31
use Pod::Usage;
32
use JatsRmApi;
33
use ArrayHashUtils;
34
use DBI;
35
use JatsEnv;
36
use FileUtils;
37
 
38
my $VERSION = "1.0.0";
39
our $GBE_DPKG;
40
our $GBE_UNIX;
41
 
42
my $RM_DB;
43
my $opt_verbose = 0;
44
my $opt_help = 0;
45
my $opt_manual;
46
my $opt_outdir = 'tmp';
47
my $opt_outdirFin;
48
my $opt_outdirTmp;
4419 dpurdie 49
my $opt_flat = 1;
4417 dpurdie 50
my $opt_quiet;
4419 dpurdie 51
my $opt_deepDebs = 0;
52
my $opt_dpkg_archive;
53
my $opt_relativeLinks = 1;
4417 dpurdie 54
 
55
#
56
#   Data Items
57
#
58
my $startTime = strftime("%F %T", localtime);
59
my $progName = basename($0);
60
my @DeployData;
61
my %data;
62
 
63
#-------------------------------------------------------------------------------
64
# Function        : Main Entry
65
#
66
# Description     :
67
#
68
# Inputs          :
69
#
70
# Returns         :
71
#
72
{
73
    my $result = GetOptions (
4419 dpurdie 74
                    "help+"             => \$opt_help,          # flag, multiple use allowed
75
                    "manual"            => \$opt_manual,        # flag
76
                    "verbose:+"         => \$opt_verbose,       # flag
77
                    "quiet:+"           => \$opt_quiet,         # flag
78
                    "outdir:s"          => \$opt_outdir,        # String
79
                    "dpkg_archive:s"    => \$opt_dpkg_archive,  # String
80
                    "flat!"             => \$opt_flat,          # flag
81
                    "relativelinks!"    => \$opt_relativeLinks, # flag
82
                    "deepDebian!"       => \$opt_deepDebs,      # flag
4417 dpurdie 83
                    );
84
 
85
    #
86
    #   Process help and manual options
87
    #
88
    pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
89
    pod2usage(-verbose => 1)  if ($opt_help == 2 );
90
    pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
91
 
92
    ErrorConfig( 'name'    =>'DplyBuild', 
93
                 'verbose' => $opt_verbose,
94
                 'quiet'   => $opt_quiet);
95
 
96
    #
97
    #   Sanity Check
98
    #
99
    EnvImport('GBE_DPKG');
100
    EnvImport('GBE_UNIX');
101
 
102
    Error("This program does not run under Windows","Windows cannot create Symbolic Links")
103
        unless ($GBE_UNIX);
104
 
105
    #
4419 dpurdie 106
    #   Validate the path to dpkg_archive
107
    #
108
    if ($opt_dpkg_archive)
109
    {
110
        Error("dpkg_archive is not a directory") 
111
            unless -d $opt_dpkg_archive;
112
        $GBE_DPKG = $opt_dpkg_archive;
113
    }
114
 
115
 
116
    #
4417 dpurdie 117
    #   Check that the parent of the base directory exists
118
    #   Check that the CWD is not within the target directory 
119
    #   If the output directory exists - check they we created it
120
    #       Try to prevent users from kill entire directory trees
121
    #
122
    InitFileUtils();
123
    my $pdir = FullPath( catdir($opt_outdir, '..') );
4419 dpurdie 124
    my $udir = StripDir($opt_outdir);
4417 dpurdie 125
    Error ("Cannot create deployment sets in non existent directory","Parent directory must exist", $pdir) 
126
        unless(-d $pdir);
127
 
128
    my $rdir = RelPath( FullPath($opt_outdir));
129
    Error ("Cannot create deployment sets in a parent of the current directory")
130
        if ($rdir eq '..' || $rdir eq '.' || $rdir =~ m~/\.\.$~);
131
 
132
    if (-d $opt_outdir)
133
    {
134
        Error("Cannot create deployment sets into a directory not created by this utility", catdir($opt_outdir,'.deploy_builder'))
135
            unless (-f catdir($opt_outdir,'.deploy_builder'));
136
    }
137
 
138
    #
4419 dpurdie 139
    #   Convert the user-provided base directory into a real path - one that does
140
    #   not contain any symlinks. Need a physical path to correctly calculate relative
141
    #   paths.
142
    #
143
    my $realPath = Realpath($pdir);
144
    $opt_outdir = catdir($realPath, $udir);
145
 
146
    #
4417 dpurdie 147
    #   Set up paths for a build and swap
148
    #       $opt_outdirFin - The final output directory
149
    #       $opt_outdir    - Working (tmp) output directory
150
    #       $opt_outdirTmp - Temp output. Used in renaming
151
    #
152
    $opt_outdirFin = $opt_outdir;
153
    $opt_outdir = join('.', $opt_outdir, 'tmp' );
154
    $opt_outdirTmp = join('.', $opt_outdir, 'tmp' ); 
155
 
156
    if (-d $opt_outdir && ! -f catdir($opt_outdir, '.deploy_builder')) {
157
        Error("Working directory not created by this utility", $opt_outdir)
158
    }
159
 
160
    if (-d $opt_outdirTmp && ! -f catdir($opt_outdirTmp, '.deploy_builder')) {
161
        Error("Temp directory not created by this utility", $opt_outdirTmp)
162
    }
163
 
164
    # Cleanout working directories
165
    #   We have verified the we created them
166
    #
167
    RmDirTree($opt_outdirTmp);
168
    RmDirTree($opt_outdir);
169
 
170
    #
171
    #   Do the body of the work
172
    #
173
    GetPkgInfo();
174
    createDirectories();
175
    createReports();
176
#DebugDumpData("data", \%data);
177
 
178
    #
179
    #   Swap in new directory structure
180
    #   Try to do it as fast as possible
181
    #       Rename the existing directory
182
    #       Rename the working directory
183
    #       Then delete what we need to delete
184
    #
185
    rename($opt_outdirFin,$opt_outdirTmp) if (-d $opt_outdirFin);
186
    rename($opt_outdir, $opt_outdirFin);
187
    RmDirTree($opt_outdir);
188
    RmDirTree($opt_outdirTmp);
189
 
190
    #
191
    #   All done
192
    #
193
    exit 0;
194
}
195
 
196
#-------------------------------------------------------------------------------
197
# Function        : populateHash 
198
#
199
# Description     : Put an array of data items into a hash
200
#                   Clean white space from the data
201
#
202
# Inputs          : pHash           - ref to output hash
203
#                   pRow            - Ref to the row data 
204
#                   pItems          - Ref to an hash array of entry names
205
 
206
# Returns         : pHash
207
#
208
sub populateHash
209
{
210
    my ($pHash, $pRow, $pItems) = @_;
211
 
212
    foreach my $item ( @{$pItems} ) {
213
        my $data = shift @{$pRow};
214
        if (defined $data)
215
        {
216
            $data =~ s~^\s+~~;
217
            $data =~ s~\s+$~~;
218
            $pHash->{$item} = $data;
219
        }
220
    }
221
    return $pHash;
222
}
223
 
224
#-------------------------------------------------------------------------------
225
# Function        : performSqlQueryCallback 
226
#
227
# Description     : Perform a general Sql query and invoke a user function for
228
#                   each row of results
229
#
230
# Inputs          : $fname                  - Name of query for error reporting
231
#                   $m_sqlstr               - Query string
232
#                   $f_process              - Function called for each row in the result
233
#                                             Use closure to have callback modify other data
234
#
235
# Returns         : Number of rows found
236
#
237
sub performSqlQueryCallback
238
{
239
    my ($fname, $m_sqlstr, $f_process ) = @_;
240
    my $found = 0;
241
 
242
    connectRM(\$RM_DB) unless $RM_DB;
243
 
244
    $m_sqlstr =~ s~\s+~ ~g;
245
    Verbose3("SQL:", $m_sqlstr);
246
    my $sth = $RM_DB->prepare($m_sqlstr);
247
    if ( defined($sth) )
248
    {
249
        if ( $sth->execute( ) )
250
        {
251
            if ( $sth->rows )
252
            {
253
                while ( my @row = $sth->fetchrow_array )
254
                {
255
                    $found++;
256
                    &$f_process(\@row);
257
                }
258
            }
259
            $sth->finish();
260
        }
261
        else
262
        {
263
            Error("$fname:Execute failure: $m_sqlstr", $sth->errstr() );
264
        }
265
    }
266
    else
267
    {
268
        Error("$fname:Prepare failure" );
269
    }
270
 
271
    unless ( $found )
272
    {
273
        Warning("$fname:No data found");
274
    }
275
    return $found;
276
}
277
 
278
#-------------------------------------------------------------------------------
279
# Function        : populateArrayFromSql 
280
#
281
# Description     : Issue an SQL query and push the results into an array of hashes
282
#                   where each row from the query is a hash and the entire result is an 
283
#                   array 
284
#
285
# Inputs          :     name                - For error reporting
286
#                       pArray              - Ref to the output array
287
#                       sql                 - Sql to process
288
#                       pItems              - Array of tems to extract
289
#                                             Must match the SQL SELECT arguments
290
#                                             Item names starting with '-' do not end up in the
291
#                                             generated XML
292
# Returns         : 
293
#
294
sub populateArrayFromSql
295
{
296
    my ($fname, $pArray, $m_sqlstr, $pItems) = @_;
297
 
298
    performSqlQueryCallback($fname, 
299
                            $m_sqlstr, 
300
                            sub { 
301
                                my ($pRow) = @_;
302
                                Verbose3("$fname:" . join(',',@$pRow));
303
                                my %entry;
304
                                push @{$pArray}, populateHash( \%entry, $pRow, $pItems);
305
                                }
306
                            );
307
#DebugDumpData("populateArrayFromSql", $pArray);
308
}
309
 
310
#-------------------------------------------------------------------------------
311
# Function        : GetPkgInfo  
312
#
313
# Description     : Get Basic Package Information    
314
#
315
# Inputs          : pHash               - Ref to Hash to populate 
316
#
317
# Returns         : 
318
#
319
sub GetPkgInfo
320
{
321
    my ($pHash) = @_;
322
    my $fname = 'GetPkgInfo';
323
 
324
    #
325
    #   Now extract the package infromation
326
    #
327
    my @items = qw(pkgName version pvid rtagid projName releaseName official );
328
    my $m_sqlstr =  "select pkg.pkg_name, pv.pkg_version, pv.pv_id, rt.rtag_id, prj.proj_name, rt.rtag_name, rt.official".
329
                    " from release_manager.package_versions pv,".
330
                    "      release_manager.packages pkg,".
331
                    "      release_manager.release_content rc,".
332
                    "      release_manager.release_tags rt,".
333
                    "      release_manager.projects prj".
334
                    " where pkg.pkg_id = pv.pkg_id".
335
                    " and prj.proj_id = rt.proj_id".
336
                    " and pv.is_deployable = 'Y' and pv.dlocked = 'Y'".
337
                    " and rc.pv_id = pv.pv_id".
338
                    " and rt.rtag_id = rc.rtag_id".
339
                    " and rt.official not in ( 'Y', 'A' )";
340
 
341
    populateArrayFromSql( $fname, \@DeployData, $m_sqlstr, \@items );
342
 
343
#    DebugDumpData("$fname", \@DeployData);
344
}
345
 
346
#-------------------------------------------------------------------------------
347
# Function        : cleanName 
348
#
349
# Description     : Create a 'nice' file/directory name
350
#                       Remove / and \
351
#                       Remove known Swedish characeters
352
#                       Remove mumtiple _
353
#
354
# Inputs          : $arg            - Unclean element
355
#
356
# Returns         : Clean Element
357
#
358
sub cleanName
359
{
360
    my ($arg) = @_;
4419 dpurdie 361
    $arg =~ s~[/\\]~-~g;
4417 dpurdie 362
    $arg =~ tr~åÅäÄöÖéÉ~aAaAoOeE~s;
363
    $arg =~ tr~_~~s;
4419 dpurdie 364
    $arg =~ tr~-~~s;
4417 dpurdie 365
 
366
    return $arg;
367
}
368
 
369
#-------------------------------------------------------------------------------
370
# Function        : createDirectories 
371
#
372
# Description     : Given a (global) data structure - create the output
373
#                   directory structure
374
#
375
# Inputs          : 
376
#
377
# Returns         : 
378
#
379
my %seen;
380
sub createDirectories
381
{
382
    #
383
    #   Delete the existing directory tree
384
    #
385
    mkpath($opt_outdir);
386
    TouchFile(catdir($opt_outdir, '.deploy_builder'));
387
 
388
    foreach my $entry ( @DeployData) {
389
#        print("$entry->{pkgName} $entry->{version}\n");
390
 
391
        # Clean up names
392
        my $projName = cleanName($entry->{projName});
393
        my $releaseName = cleanName($entry->{releaseName});
394
 
395
        #
396
        #   Create a hash with ProjectName:ReleaseName:PackageName:PackageVersion
397
        #
398
        $data{$projName}{$releaseName}{$entry->{pkgName}}{$entry->{version}}{'noDpkg'} = 1;
399
 
400
        #
401
        #   Determine source files
402
        #
403
        my $pkgDir = catdir($GBE_DPKG, $entry->{pkgName}, $entry->{version});
404
        if ( -d $pkgDir)
405
        {
406
            delete $data{$projName}{$releaseName}{$entry->{pkgName}}{$entry->{version}}{'noDpkg'};
407
 
408
#            print("$pkgDir\n");
409
            #
410
            #   Most Deployable package export build artifacts in the root directory
411
            #   They are installers after all
412
            #   The exception are debian packages
413
            #       Assume that they will be in bin/XXXX/*.deb
414
            #
415
            opendir (my $dh, $pkgDir) || Error ("Cannot open $pkgDir: $!");
416
            while ( $_ = readdir $dh)
417
            {
418
                next if(m~^\.~);
419
                next if(m~^built.~);
420
                next if(m~^descpkg~);
421
 
422
                my $fname = catdir($pkgDir, $_);
4419 dpurdie 423
                scanDebian($fname,$projName,$releaseName,$entry->{pkgName},$entry->{version}) 
424
                    if (m~^bin$~ && $opt_deepDebs);
4417 dpurdie 425
 
426
                next if( -d $fname );
427
 
428
                #
429
                #   Scan for allowed file types
430
                #       Defined as regexps
431
                #
432
                my @allowedExtensions = qw( \.pkg.gz$ \.exe$ \.msi$ \.deb$ ^IzPack-.*\.jar$ );
433
                my $allowed;
434
                foreach my $ext ( @allowedExtensions) {
4419 dpurdie 435
                    if ( m~$ext~i)
4417 dpurdie 436
                    {
437
                        $allowed = $ext;
438
                        last;
439
                    }
440
                }
4419 dpurdie 441
 
442
                #
443
                #   Specifically exclude some files
444
                #
445
                if ($allowed)
446
                {
447
                    foreach my $name ( qw(^setup\.exe$ ^setup\.msi$)) {
448
                        if ( m~$name~i)
449
                        {
450
                            $allowed = 0;
451
                            last;
452
                        }
453
                    }
454
                }
4417 dpurdie 455
 
456
                if ($allowed)
457
                {
458
                    addDeployedFile($_, $fname,$projName,$releaseName,$entry->{pkgName},$entry->{version});
459
                }
460
                else
461
                {
462
                    IgnoreFile($_, $fname,$projName,$releaseName,$entry->{pkgName},$entry->{version});
463
                }
464
            }
465
            closedir $dh;
466
        }
467
        else
468
        {
469
            # Warn about missing packages once
470
            unless (exists ($seen{$entry->{pkgName}}{$entry->{version}})) {
471
                $seen{$entry->{pkgName}}{$entry->{version}}++;
472
                Warning("Package Not found: $entry->{pkgName}, $entry->{version}");
473
            }
474
        }
475
    }
476
}
477
 
478
#-------------------------------------------------------------------------------
479
# Function        : addDeployedFile 
480
#
481
# Description     : Add the specified file to the deployed area
482
#
483
# Inputs          : $name
484
#                   $target
485
#                   $projName
486
#                   $releaseName
487
#                   $pkgName
488
#                   $version 
489
#
490
# Returns         : 
491
#
492
sub addDeployedFile
493
{
494
    my ($name, $target, $projName, $releaseName, $pkgName, $version) = @_;
495
    my $tdir;
496
 
497
    push @{$data{$projName}{$releaseName}{$pkgName}{$version}{files}}, $target;
498
    Verbose("deploy: $target");
499
 
500
    #
501
    #   Create a flat directory structure
502
    #       Project/Release/Files ...
503
    #
504
    if ($opt_flat) {
505
        $tdir = catdir($opt_outdir,$projName,$releaseName);
506
    } else {
507
        $tdir = catdir($opt_outdir,$projName,$releaseName,$pkgName,$version );
508
    }
509
    mkpath($tdir);
4419 dpurdie 510
 
511
    # Convert Absolute path to relative path
512
    if ($opt_relativeLinks) {
513
 
514
        my $base = $target;
515
        $target = RelPath( $target, AbsPath($tdir));
516
        my $relPathTest = catdir($tdir, $target);
517
        Error ("Relative path calculation error",
518
               "Possible case. One of the elements of the output path is a symlink",
519
               $base, AbsPath($tdir), $target, $relPathTest) 
520
            unless -f $relPathTest;
521
    }
522
 
4417 dpurdie 523
    my $linkDone = eval{ symlink( $target, catdir($tdir,$name)); 1};
524
    Error ("Target file system does not appear to support symlinks") 
525
        unless $linkDone;
526
#    print("$_\n");
527
}
528
 
529
sub IgnoreFile
530
{
531
    my ($name, $target, $projName, $releaseName, $pkgName, $version) = @_;
532
    Warning("Ignore: $target");
533
 
534
    push @{$data{$projName}{$releaseName}{$pkgName}{$version}{ignored}}, $target;
535
}
536
 
537
 
538
#-------------------------------------------------------------------------------
539
# Function        : scanDebian 
540
#
541
# Description     : Scan for debian packages
542
#                   Assumes that $target is the 'bin' directory
543
#
544
#                   Will only transfer files from one of 'P' or the 'D' directory
545
#                   cannot transfer from both as the generated debian packages will
546
#                   have the same name
547
#
548
# Inputs          : $target
549
#                   $projName
550
#                   $releaseName
551
#                   $pkgName
552
#                   $version 
553
#
554
# Returns         : 
555
#
556
sub scanDebian
557
{
558
    my ($target, $projName, $releaseName, $pkgName, $version) = @_;
559
    my %binTargetType;
560
    my %binTargets;
561
 
562
    #
563
    #   Locate directorues under bin
564
    #   Build up a hash splitting out the P and D
565
    #
566
    opendir (my $dh, $target) || Error ("Cannot open $target: $!");
567
    while ($_ = readdir $dh)
568
    {
569
        next if(m~^\.~);
570
        next unless (m~(.*)([PD])$~);
571
        my $platform = $1;
572
        my $type = $2;
573
 
574
        my $binDir = catdir($target, $_);
575
        if (-d $binDir)
576
        {
577
            unless(exists $binTargetType{$platform}{P})
578
            {
579
                $binTargets{$platform} = $binDir;
580
                $binTargetType{$platform}{$type} = 1; 
581
            }
582
        }
583
    }
584
    closedir $dh;
585
 
586
    foreach my $binDir (values(%binTargets))
587
    {
588
        opendir (my $dh, $binDir) || Error ("Cannot open $binDir: $!");
589
        while ($_ = readdir $dh)
590
        {
591
            next if(m~^\.~);
592
            next unless (m~\.deb$~);
593
            my $debFile = catdir($binDir, $_);
594
            addDeployedFile($_,$debFile,$projName, $releaseName, $pkgName, $version);
595
        }
596
        closedir $dh;
597
    }
598
}
599
 
600
#-------------------------------------------------------------------------------
601
# Function        : createReports 
602
#
603
# Description     : Add a report into each Release directory to describe the
604
#                   success and failure of the deployment
605
#
606
# Inputs          : 
607
#
608
# Returns         : 
609
#
610
sub createReports
611
{
612
    my $printHdr;
613
    my $ofile;
614
    foreach my $projName ( sort keys %data) {
615
        foreach my $releaseName ( sort keys %{$data{$projName}}) {
616
            $printHdr = 0;
617
            my $odir = catdir($opt_outdir,$projName,$releaseName);
618
            if (-d $odir)
619
            {
620
                $ofile = catdir($odir, 'build_report.txt');
621
            }
622
            else
623
            {
624
                $ofile = catdir($opt_outdir, join('-',$projName,$releaseName,'build_report.txt'));
625
                $printHdr = 1;
626
            }
627
            open (my $oh , '>', $ofile  ) || Warning("Cannot open $ofile. $!");
628
            print $oh ("Project: $projName\n");
629
            print $oh ("Release: $releaseName\n");
630
            print $oh ("Created: $startTime\n");
631
            print $oh ("Created by: $progName\n");
632
            print $oh ("This project has not deployed any files\n") if $printHdr;
633
 
634
            $printHdr = 0;
635
            foreach my $pkgName (sort keys %{$data{$projName}{$releaseName}}) {
636
                foreach my $version (sort keys %{$data{$projName}{$releaseName}{$pkgName}}) {
637
                    next unless $data{$projName}{$releaseName}{$pkgName}{$version}{noDpkg};
638
                        print $oh ("\nThe following packages do not exist in dpkg_archive\n") unless $printHdr;
639
                        $printHdr = 1;
640
                        print $oh ("    $pkgName, $version\n");
641
                }
642
            }
643
 
644
            $printHdr = 0;
645
            foreach my $pkgName (sort keys %{$data{$projName}{$releaseName}}) {
646
                foreach my $version (sort keys %{$data{$projName}{$releaseName}{$pkgName}}) {
647
                    next if $data{$projName}{$releaseName}{$pkgName}{$version}{noDpkg};
648
                    next if $data{$projName}{$releaseName}{$pkgName}{$version}{files};
649
                    print $oh ("\nThe following packages do contribute any files\n") unless $printHdr;
650
                    $printHdr = 1;
651
                    print $oh ("    $pkgName, $version\n");
652
                }
653
            }
654
 
655
            foreach my $pkgName (sort keys %{$data{$projName}{$releaseName}}) {
656
                foreach my $version (sort keys %{$data{$projName}{$releaseName}{$pkgName}}) {
657
                    next unless $data{$projName}{$releaseName}{$pkgName}{$version}{ignored};
658
                    print $oh ("\nIgnored Files from Package: $pkgName, $version\n");
4419 dpurdie 659
                    foreach my $ifile (sort @{$data{$projName}{$releaseName}{$pkgName}{$version}{ignored}}) {
660
                        $ifile =~ s~$GBE_DPKG/~~;
4417 dpurdie 661
                        print $oh ("    $ifile\n");
662
                    }
663
                }
664
            }
4419 dpurdie 665
 
666
            print $oh ("\nFile List:\n");
667
            foreach my $pkgName (sort keys %{$data{$projName}{$releaseName}}) {
668
                foreach my $version (sort keys %{$data{$projName}{$releaseName}{$pkgName}}) {
669
                    next unless $data{$projName}{$releaseName}{$pkgName}{$version}{files};
670
                    print $oh ("$pkgName, $version\n");
671
                    foreach my $tfile (sort @{$data{$projName}{$releaseName}{$pkgName}{$version}{files}}) {
672
                        $tfile =~ s~$GBE_DPKG/~~;
673
                        print $oh ("    $tfile\n");
674
                    }
675
                }
676
            }
677
 
678
 
4417 dpurdie 679
        close $oh;
680
        }
681
    }
682
}
683
 
684
#-------------------------------------------------------------------------------
685
#   Documentation
686
#
687
 
688
=pod
689
 
690
=for htmltoc    SYSUTIL::
691
 
692
=head1 NAME
693
 
694
jats_deploy_builder - Build Deployment package sets
695
 
696
=head1 SYNOPSIS
697
 
698
 jats jats_deploy_builder [options]
699
 
700
 Options:
701
    -help              - Brief help message
702
    -help -help        - Detailed help message
703
    -man               - Full documentation
704
    -verbose[=n]       - Display additional progress messages
705
    -quiet[=n]         - Supress output
706
    -[no]flat          - Control output structure. Default noflat
4419 dpurdie 707
    -[no]deepDebian    - Dig debian packages from BIN directories
708
    -[no]relativeLinks - Create Relative or Absolute symlinks
709
    -dpkg_archive=path - Path the dpkg_archive
710
    -outdir=name       - Root of the output directory
4417 dpurdie 711
 
712
 
713
=head1 OPTIONS
714
 
715
=over 8
716
 
717
=item B<-help>
718
 
719
Print a brief help message and exits.
720
 
721
=item B<-help -help>
722
 
723
Print a detailed help message with an explanation for each option.
724
 
725
=item B<-man>
726
 
727
Prints the manual page and exits.
728
 
729
=item B<-quiet[=n]>
730
 
731
This option suppresses normal output. It is intended to allow the program to be run
732
within a 'cron' job. Only errors will generate output to be mailed to some user.
733
 
734
Use a value of 3 to supress warnings.
735
 
736
=item B<-[no]flat>
737
 
738
Control the output directory format. The default is noflat.
739
 
740
The flat structure places all the files in one directory under the 'release' directory.
741
 
742
The noflat structure creates package-name/package-version subdirectories 
743
under the 'release' directory.
744
 
4419 dpurdie 745
=item B<-[no]deepDebian>
746
 
747
Dig debian packages from BIN directories. The default is to assume the correct deployable 
748
package format - with all deployable packages in the root of the package
749
 
750
=item B<-[no]relativeLinks>
751
 
752
This option control the type of link created between the deployed file set and dpkg_archive.
753
The default operation is to create relative symlinks.
754
 
755
=item B<-dpkg_archive=path>
756
 
757
This option specifies the path to dpkg_archive; where packages will be found. If provided 
758
this value will be used otherwise it will be taken from the environment variable GBE_DPKG.
759
 
4417 dpurdie 760
=item B<-outdir=name>
761
 
762
This option specifies the root of the output directory tree created by this tool.
763
 
764
If the directory exists it may be deleted. The entire directory subtree is in the 
765
domain of this application.
766
 
767
If not provided then the program will use a directory of 'tmp' within the users current
768
woking directory.
769
 
770
=back
771
 
772
=head1 DESCRIPTION
773
 
774
This utility program is create and maintain a set of deployed packages for all active releases
775
defined within the Release Manager Database.
776
 
777
The tool is intended to facilitate the continuous deployment process by maintaining
778
a collection or depeloyed packages. See 'update_release' utility for other operations.
779
 
780
The utility will:
781
 
782
=over 4
783
 
784
=item * 
785
 
786
Locate all active releases in the Release Manager database
787
 
788
It will ignore closed and archived releases.
789
 
790
=item * 
791
 
792
Locate all released packages that are marked as 'deployable'
793
 
794
=item * 
795
 
796
Create a directory structure 
797
 
798
The directory structure is of the form: 'Project Name/Release Name'.
799
 
800
If the 'noflat' mode has been selected, then the structure under the 'release' 
801
directory will also contain the package-name/package-version.
802
 
803
=item *
804
 
805
Transfer deployable artifacts (see below) from each package into the release subdirectory.
806
 
807
The utilty will create symbolic links to the actual packages within dpkg_archive. 
808
 
809
=item *
810
 
811
Create a 'build_report.txt' file for each release processed. 
812
 
813
If processing actually created and populated a 'release' directory, then the report will
814
be in the 'release' directory, otherwise it will be created in the base of the target 
815
directory and will be prefixed with the Project and Release name.
816
 
817
The report details:
818
 
819
=over 4
820
 
821
=item * 
822
 
823
Date Time that the package set was created
824
 
825
=item * 
826
 
827
Packages that did not contribute any files to the output
828
 
829
=item * 
830
 
831
Packages that do not exist in dpkg_archive
832
 
833
=item * 
834
 
835
Ignored files
836
 
837
=back
838
 
839
=back
840
 
841
=head2 Deployable Artifacts
842
 
843
The utilty will only process files that it considers to be depoyable. These are:
844
 
845
=over 4
846
 
847
=item * 
848
 
849
Suitable files in the root of the package
850
 
851
These are:
852
 
853
=over 4
854
 
855
=item * 
856
 
857
Solaris Packages: *.pkg.gz
858
 
859
=item * 
860
 
861
Windows executable installers: *.exe
862
 
863
=item * 
864
 
865
Windows installers: *.msi
866
 
867
=item * 
868
 
869
Debian Packages: *.deb
870
 
871
=item * 
872
 
873
IzPack Pqackages: IzPack-*.jar
874
 
875
=back
876
 
877
The concept is that only these files are deployable.
878
 
879
=item * 
880
 
4419 dpurdie 881
If the -deepDebian option is given, then Debian packages found within subdirectores 
882
of the 'bin' directory will be located.
4417 dpurdie 883
 
884
Debian packages that are to be deployed should be built to follow the deployable
885
convention. Unfortunately many have not been. This tool attampts to cater for this bad
886
practice. It will examine all directories with the 'bin' subdirectory and locate one 
887
of the production or debug builds. It will then transfer debians packages from the 
888
found directory. Preference is given to production versions.
889
 
890
This process is required as the debug and production versions have the same name.
891
 
892
=back
893
 
894
=head1 EXAMPLE
895
 
4419 dpurdie 896
=head2 jats deploy_builder -outdir=/export/devl/releases/current
4417 dpurdie 897
 
898
This will mainatin the package sets in the '/export/devl/releases/current' directory.
899
 
900
=cut