Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
1530 dpurdie 1
#==============================================================================
2
# **** Source Information ****
3
#
4
# deploylib_pm_FileName  $RCSfile: deploylib.pm,v $ ($Source: /export/repository/cvs/core/devl/TOOLS/deploylib.pm,v $)
5
# deploylib_pm_Version,  $Revision: 1.17 $
6
# deploylib_pm_DateTime, $Date: 2002/08/01 05:54:58 $
7
#
8
# Program Name        : deploylib.pm
9
#
10
# Program Type        : Perl Module (.pm)
11
#
12
# Original Author(s)  : V.Chatzimichail(vasilic)
13
#
14
# Description / Purpose:
15
#      Deploylib is a set of high-level functions written in Perl (for portability) 
16
#      that allow a user to quickly setup a deployment configuration and produce a 
17
#      deliverable package.
18
#
19
#==============================================================================
20
 
21
 
22
#------------------------------------------------------------------------------
23
# Package definition
24
#------------------------------------------------------------------------------
25
package deploylib;
26
 
27
#------------------------------------------------------------------------------
28
# Pragmas
29
#------------------------------------------------------------------------------
30
require 5.005;
31
use strict;
32
use Getopt::Std;
33
use File::Copy;
34
use File::Find;
35
use File::Basename;
36
use File::Path;
37
use Cwd;
38
use Carp;
39
use DBI;
40
use LWP::UserAgent;
41
use DeployUtils::Logger;
42
use DeployUtils::BuildFile;
43
use DeployUtils::RmPkgInfo;
44
use Exporter();
45
use ArrayHashUtils;
46
 
47
#-------------------------------------------------------------------------------
48
#   Export variables and function into the users name space
49
#-------------------------------------------------------------------------------
50
our @ISA    = qw(Exporter);
51
our @EXPORT = qw(
52
                    &Init
53
                    &setPkgDescription
54
                    &setPkgName
55
                    &setErgAfcBaseDir
56
                    &setPkgOverview
57
                    &addInstallshieldFiles
58
                    &installAllDpkgArchivePkgFiles
59
                    &installAllDpkgArchivePkgFiles2
60
                    &installAllDpkgArchiveDevcdFiles
61
                    &installAllDpkgArchiveJspFiles
62
                    &installAllDpkgArchiveFiles
63
                    &installAllDpkgArchiveAcHtmlFiles
64
                    &installAllDpkgArchiveInfoFilesFiles
65
                    &installAllDpkgArchiveSqlFiles
66
                    &installAllDpkgArchiveWarFiles
67
                    &installAllDpkgArchiveJarFiles
68
                    &installAllDpkgArchiveEtcFiles
69
                    &installAllDpkgArchiveScriptsFiles
70
                    &installAllDpkgArchiveIncludeFiles
71
                    &installAllDpkgArchiveDocFiles
72
                    &installDpkgArchiveFile
73
                    &installDpkgArchiveAcHtmlFile
74
                    &installDpkgArchiveRptFile
75
                    &installDpkgArchiveRoxFile
76
                    &installDpkgArchiveDatFile
77
                    &installDpkgArchiveThxFile
78
                    &installDpkgArchiveMugFile
79
                    &installDpkgArchiveInfoFilesFile
80
                    &installDpkgArchiveSqlFile
81
                    &installDpkgArchiveWarFile
82
                    &installDpkgArchiveJarFile
83
                    &installDpkgArchiveSarFile
84
                    &installDpkgArchiveEtcFile
85
                    &installDpkgArchiveScriptsFile
86
                    &installDpkgArchiveIncludeFile
87
                    &installDpkgArchiveDocFile
88
                    &installDpkgArchiveBinFile
89
                    &installDpkgArchiveLibFile
90
                    &installPkgAddConfigFile
91
                    &installPkgAddSystemClassFile
92
                    &updatePrototypeFileAddItem
93
                    &updatePrototypeFileAddItem2
94
                    &addPath2Prototype
95
                    &createAfcRcScriptLink
96
                    &createAfcRcScriptLink2
97
                    &installAllDpkgArchiveBinFiles
98
                    &CreateTargetDirStructure
99
                    &createPatch
100
                    &createPackage
101
                    &createPrototypeFile
102
                    &addPatchInfo2ProtoTypeFile
103
                    &addPkgInfoClasses
104
                    &addPkgInfoField
105
                    &updatePrototypeFileItemClass
106
                    &useReplaceClass
107
                    &setReplaceClassFiles
108
                    &createPkginfoFile
109
                    &updatePrototypeFileItemOwner
110
                    &chmod
111
                    &chmodRecursive
112
                    &chmodDir
113
                    &chmodFile
114
                    &createSymbolicLink
115
                    &createPrototypeFile2
116
                    &installDeployFile
117
                    &createDpkgArchive
118
                    &generateHtmlReleaseNote
119
                    &generateInternalHtmlReleaseNote
120
                    &generateIShieldIncludeFile
121
                    &createPerlSvcWin32
122
                    &createPerlAppWin32
123
                    &convertFile
124
 
125
                    &getErgAfcBaseDir
126
                    &getGenericNameNoVersionForLib
127
                    &getGenericNameForLib
128
 
129
                    %TargetDstDirStructure
130
                    %LocalSrcDirStructure
131
                    %BuildPkgArchive
132
                    $MachType
133
                    $TargetHomeDir
134
                    $TargetBaseDir
135
 
136
                    $PkgName
137
 
138
                );
139
 
140
#------------------------------------------------------------------------------
141
# Constants global/local to this package
142
#------------------------------------------------------------------------------
143
use vars qw ( $opt_n $opt_v $opt_r $opt_t $opt_m $opt_d $opt_p $opt_o $opt_k $opt_g );
144
 
145
my ($VENDOR_DESC)            = "ERG Transit Systems Ltd";
146
my ($CATEGORY_DESC)          = "application";
147
my ($ERGAFC_BASEDIR)         = "/afc";
148
my ($MAXINST)                = "1000";
149
my ($PROJECT_ACRONYM_LENGTH) = 3;
150
my ($PKG_OVERVIEW)           = "To Be Defined.";
151
 
152
my (@PATCH_INFO_FILES) = qw (
153
    checkinstall 
154
    copyright 
155
    patch_checkinstall 
156
    patch_postinstall 
157
    i.none 
158
    postinstall 
159
    preinstall 
160
) ;
161
 
162
my (@PATCH_UTIL_FILES) = qw ( backoutpatch installpatch );
163
 
164
my (@PKG_UTIL_FILES) = qw ( requestlib.sh );
165
 
166
my (@PKG_ISHIELD_FILES)   = qw ( ishieldlib.rul ishieldlib.h );
167
 
168
my (@PKG_ISHIELD_IMG_FILES) = qw ( 
169
   islib_pane.bmp
170
   islib_splash.bmp
171
   islib_topicon.bmp
172
);
173
 
174
 
175
my (@PATCH_ISHIELD_FILES) = qw ( 
176
    postinstall.rul
177
    preinstall.rul 
178
    postremove.rul 
179
    preremove.rul 
180
);
181
 
182
my ($PKG_ISHIELD_DEF_FILE) = "pkgdef.h";
183
my ($PKG_ISHIELD_DIR)      = "";
184
 
185
my ($PKG_UTIL_DIR)   = "";
186
my ($PATCH_UTIL_DIR) = "";
187
 
188
 
189
my ($m_UID)  = "";
190
my ($m_GID)  = "";
191
my ($m_MASK) = "";
192
 
193
 
194
#------------------------------------------------------------------------------
195
# Variables global/local to this package
196
#------------------------------------------------------------------------------
197
our $InterfaceDir       = "";
198
 
199
our $DpkgBinDir         = "";
200
our %DpkgBinDirList     = ();
201
our $DpkgLibDir         = "";
202
our %DpkgLibDirList     = ();
203
our $DpkgScriptsDir     = "";
204
our $DpkgEtcDir         = "";
205
our $DpkgJarDir         = "";
206
our $DpkgSarDir         = "";
207
our $DpkgWarDir         = "";
208
our $DpkgSqlDir         = "";
209
our $DpkgInfoFilesDir   = "";
210
our $DpkgPkgDir         = "";
211
our $DpkgJspDir         = "";
212
our $DpkgRoxDir         = "";
213
our $DpkgRptDir         = "";
214
our $DpkgAcHtmlDir      = "";
215
our $DpkgIncludeDir     = "";
216
our $DpkgDevcdDir       = "";
217
our $DpkgDatDir         = "";
218
our $DpkgThxDir         = "";
219
our $DpkgMugDir         = "";
220
our $DpkgDocDir         = "";
221
 
222
our @LibCheckList       = ();
223
 
224
our $CurrentDir         = "";
225
our $RootDir            = "";
226
our $BuildType          = "";
227
our $MachType           = "";
228
our $Platform           = "";
229
our $Product            = "";
230
our $Target             = "";
231
our $SrcDir             = "";
232
our $PkgDir             = "";
233
our $ReleaseDir         = "";
234
our $Username           = "";
235
 
236
our $PkgBaseDir         = "";
237
our $PkgInfoFileName    = "pkginfo";
238
our $PkgInfoFile        = "";
239
our $ProtoTypeFileName  = "prototype";
240
our $ProtoTypeFile      = "";
241
 
242
our $PkgPatchName       = "";
243
our $PkgPatchID         = "";
244
our $PkgPatchNum        = "";
245
our $PkgPatchReadme     = "";
246
our $PkgPatchTmpDir     = "";
247
 
248
our $PkgVersion         = "";
249
our $PkgVersionStr      = "";
250
our $PkgVersionUser     = "";
251
our $PkgName            = "";
252
our $PkgBuildNum        = "";
253
our $PkgOutputFile      = "";
254
our $PkgReleaseNote     = "";
255
our $PkgLabel           = "";
256
our $PkgDesc            = "";
257
our $PkgNameLong        = "";
258
our $PkgInfoClasses     = "none";
259
 
260
our $PkgPreviousVersionStr = "";
261
our $TargetBaseDir      = "";
262
our $TargetHomeDir      = "";
263
 
264
our $SandBoxName        = "";
265
our $ProjectAcronym     = "";
266
 
267
our $TmpGlobalVariable  = ""; # used to pass variables into PERL find functions
268
 
269
our %TargetDstDirStructure = ();
270
our %LocalSrcDirStructure  = ();
271
 
272
our $BuildFileInfo       = "";
273
# This was removed to add the use of the Buildfile.pm module, but this hash is needed 
274
# because the deployfiles use it for library version numbers in the file lists.
275
# So it is left here and is a simply copy of the hash from buildfile pm
276
our %BuildPkgArchive     = ();
277
 
278
our $RmPkgDetails        = undef;
279
our $RmPvPkgDetails      = undef;
280
 
281
 
282
#------------------------------------------------------------------------------
283
# Initialization actions
284
#------------------------------------------------------------------------------
285
 
286
 
287
#------------------------------------------------------------------------------
288
# Package Interface Subroutines
289
#
290
# The following functions are used by the Makefile.pl scripts.  Programmers
291
# call the following functions to set up the basic requirements that the
292
# automated make system requires.
293
#------------------------------------------------------------------------------
294
 
295
 
296
#------------------------------------------------------------------------------
297
sub Init
298
#
299
# Description:
300
#       Tests Environment Variables, it also checks the required command line 
301
#       variables.
302
#
303
# Inputs:
304
#       Command line.
305
#
306
# Returns:
307
#  1
308
#
309
# Globals:
310
#  $makelib::RootDir
311
#
312
# Notes:
313
#  -
314
#
315
# Todo:
316
#  -
317
#------------------------------------------------------------------------------
318
{
319
 
320
    # first we deal with the command line values we expect, these include:
321
    #  	GBE_ROOT                                                       (-r)
322
    #  	Package Name                                                   (-n)
323
    #  	Package Home Directory (relative to the ERGAFC_BASEDIR)        (-d)
324
    #  	Package Version                                                (-v)
325
    #  	Build Type                                                     (-t)
326
    #  	Patch Number                                                   (-p)
327
    #  	Previous (old) version number                                  (-o)
328
    #  	Platform                                                       (-m)
329
    # 	Product (optional)                                             (-k)
330
    #  	Machine Type (optional)                                        (-g)
331
 
332
    setLogLevel($ENV{DEPLOYLIB_DEBUG}) if ( defined($ENV{DEPLOYLIB_DEBUG}) && $ENV{DEPLOYLIB_DEBUG} >= 1 && $ENV{DEPLOYLIB_DEBUG} <= 5);
333
 
334
    $CurrentDir = cwd;
335
 
336
    my ($i);
337
    Getopt::Std::getopts ('v:n:r:t:m:d:p:o:k:g:');
338
    if ( $opt_n )
339
    {
340
        $PkgName      = $opt_n;
341
    }
342
    else
343
    {
344
        LogError("Package Name not supplied!");
345
    }
346
 
347
    if ( $opt_r )
348
    {
349
        # lets change to root dir and get fully qualified path from cwd and return back
350
        chdir($opt_r);
351
        $RootDir = cwd;
352
        chdir($CurrentDir);
353
 
354
        $SandBoxName      = File::Basename::basename($RootDir);
355
    }
356
    else
357
    {
358
        LogError("GBE_ROOT not supplied!");
359
    }
360
 
361
    if ( $opt_t )
362
    {
363
        $BuildType = $opt_t;
364
    }
365
    else
366
    {
367
        LogError("GBE_TYPE not supplied!");
368
    }
369
 
370
    #
371
    #   Target machine type ( Underlying machine type in a Product Family)
372
    #   If not provided, the assume that its the same as the platform (compat)
373
    #
374
    $opt_g = $opt_m unless ( $opt_g );
375
    if ( $opt_g )
376
    {
377
        $Target = $opt_g;
378
        if ( $Target =~ /^SOLARIS/ )
379
        {
380
            $MachType = 'sparc';
381
        }
382
        elsif ( $Target =~ /^WCE/ )
383
        {
384
            $MachType = 'WinCE';
385
        }
386
        elsif ( $Target =~ /^WIN32/ )
387
        {
388
            $MachType = 'win32';
389
        }
390
        else
391
        {
392
            LogError("Unknown target [$opt_g] supplied!");
393
        }
394
    }
395
 
396
    #
397
    #   Platform
398
    #   This is the full product name in a product family.
399
    #
400
    if ( $opt_m )
401
    {
402
        $Platform = $opt_m;
403
    }
404
    else
405
    {
406
        LogError("Platform not supplied!");
407
    }
408
 
409
    #
410
    #   Setup Product
411
    #   If not defined then use the platform
412
    #
413
    $Product = $opt_k ? $opt_k : $Platform;
414
 
415
    if ( $opt_d )
416
    {
417
        $TargetBaseDir = $opt_d;
418
    }
419
    else
420
    {
421
        LogError("Package base directory not supplied!");
422
    }
423
 
424
    if ( $opt_p )
425
    {
426
        my $pNum = sprintf("%02s", $opt_p);
427
        if ( "$pNum" =~ m/^[0-9][0-9]$/ )
428
        {
429
            $PkgPatchNum = $pNum;
430
        }
431
        else
432
        {
433
            LogError("-p command line arg [$opt_p] has invalid format,\n" .
434
                     "required format is an integer value.");
435
        }
436
    }
437
 
438
    if ($opt_v)
439
    {
440
        if( "$opt_v" =~ m/^[0-9]*\.[0-9]*\.[0-9]*-[0-9]*\.[a-z][a-z][a-z]$/ ) # N.N.N-N.ppp
441
        {
442
            my ($s1, $s2) = split (/-/, $opt_v);
443
            my ($s1a, $s1b, $s1c) = split (/\./, $s1);
444
            my ($s2a, $s2b) = split (/\./, $s2);
445
 
446
            $PkgVersionStr = sprintf("%02s%02s%02s", $s1a,$s1b,$s1c);
447
            $PkgVersion  = "$s1";
448
            $PkgBuildNum = "$s2a";
449
 
450
            if ( length("$s2b") == $PROJECT_ACRONYM_LENGTH )
451
            {
452
                $ProjectAcronym   = $s2b;
453
            }
454
            else
455
            {
456
                LogError("-v command line arg [$opt_v] has invalid format, " .
457
                         "required format is N.N.N-B.ppp where N is an integer and ppp is the project acronym.\n" .
458
                         "Check propject acronym.");
459
            }
460
        }
461
        elsif( "$opt_v" =~ m/^[0-9]*\.[0-9]*\.[0-9]*\.[a-z][a-z][a-z]$/ ) # N.N.N.ppp 
462
        {
463
            my ($tmpVar) = $opt_v;
464
            $tmpVar =~ s/^([0-9]*)\.([0-9]*)\.([0-9]*)\.([a-z][a-z][a-z])$/$1,$2,$3,$4/g;
465
            my ($s1, $s2, $s3, $s4) = split (/,/, $tmpVar);
466
 
467
            $PkgVersionStr = sprintf("%02s%02s%02s", $s1,$s2,$s3);
468
            $PkgVersion  = "$s1\.$s2\.$s3";
469
            $PkgBuildNum = "1";
470
 
471
            if ( length("$s4") == $PROJECT_ACRONYM_LENGTH )
472
            {
473
                $ProjectAcronym   = $s4;
474
            }
475
            else
476
            {
477
                LogError("-v command line arg [$opt_v] has invalid format, " .
478
                         "required format is N.N.N.ppp where N is an integers and ppp is the project acronym.\n" .
479
                         "Check propject acronym.");
480
            }
481
        }
482
        else
483
        {
484
            LogError("-v command line arg [$opt_v] has invalid format, " .
485
                     "possible formats include:\n\n" .
486
                     "\tN.N.N-B.ppp where N and B are integers and ppp is the project acronym,\n" .
487
                     "\tN.N.N.ppp where N is an integer and ppp is the project acronym, B=0.\n");
488
        }
489
 
490
        $PkgVersionUser  = $opt_v;
491
    }
492
    else
493
    {
494
        LogError("Package Version not supplied!");
495
    }
496
 
497
 
498
    # lets check to see if we have a previous version 
499
    if ($opt_o)
500
    {
501
        $PkgPreviousVersionStr = $opt_o;
502
    }
503
 
504
 
505
    # lets define where we get our stuff from
506
    #
507
    if ( $ERGAFC_BASEDIR =~ m|/$| )
508
    {
509
        $TargetHomeDir= "$ERGAFC_BASEDIR$TargetBaseDir"; 
510
    }
511
    else
512
    {
513
        $TargetHomeDir= "$ERGAFC_BASEDIR/$TargetBaseDir"; 
514
    }
515
    $PkgDir       = "$RootDir/pkg";
516
    $SrcDir       = "$RootDir/src"; 
517
    $InterfaceDir = "$RootDir/interface";
518
    $ReleaseDir   = "$RootDir/build/deploy";
519
 
520
    $PKG_UTIL_DIR   = "$InterfaceDir/deployfiles";
521
    $PATCH_UTIL_DIR = $PKG_UTIL_DIR;
522
    #
523
    #   InstallShield files are provided via a package
524
    #   Ensure that a suitable package has been provided
525
    #
526
    if ( ! -d  $PKG_UTIL_DIR )
527
    {
528
        LogError('-x', "No deployment support files found");
529
        LogError(      "These MUST be provided by a dependant package in build.pl");
530
    }
531
 
532
    $Username     = getlogin || getpwuid($<);
533
 
534
 
535
    if ( "$BuildType" eq "D" )
536
    {
537
        $PkgBaseDir = "$PkgDir/debug"; 
538
    }
539
    else
540
    {
541
        $PkgBaseDir = "$PkgDir/prod"; 
542
    }
543
 
544
    $PkgInfoFile   = "$PkgBaseDir/$PkgInfoFileName";
545
    $ProtoTypeFile = "$PkgBaseDir/$ProtoTypeFileName";
546
 
547
    $DpkgScriptsDir = "$InterfaceDir/scripts";
548
 
549
 
550
    $DpkgEtcDir     = "$InterfaceDir/etc";
551
    $DpkgJarDir     = "$InterfaceDir/jar";
552
    $DpkgSarDir     = "$InterfaceDir/sar";
553
    $DpkgWarDir     = "$InterfaceDir/war";
554
    $DpkgSqlDir     = "$InterfaceDir/sql";
555
 
556
    $DpkgInfoFilesDir = "$InterfaceDir/infofiles";
557
    $DpkgPkgDir       = "$InterfaceDir/pkg";
558
    $DpkgJspDir       = "$InterfaceDir/jsp";
559
    $DpkgRoxDir       = "$InterfaceDir/rox";
560
    $DpkgRptDir       = "$InterfaceDir/rpt";
561
    $DpkgAcHtmlDir    = "$InterfaceDir/achtml";
562
    $DpkgIncludeDir   = "$InterfaceDir/include";
563
    $DpkgDevcdDir     = "$InterfaceDir/devcd";
564
    $DpkgDatDir       = "$InterfaceDir/dat";
565
    $DpkgThxDir       = "$InterfaceDir/thx";
566
    $DpkgMugDir       = "$InterfaceDir/mug";
567
    $DpkgDocDir       = "$InterfaceDir/doc";
568
 
569
 
570
    $DpkgLibDir     = "$InterfaceDir";
571
    $DpkgBinDir     = "$InterfaceDir";
572
 
573
 
574
    #   Define where we might find our artifacts
575
    #   The search order is: Platform, Product, Target, MachineType
576
    #
577
    #   Only add the directory to the list if it actually exists
578
    #   This will speed up searching later.
579
    #
580
    #   Create multiple search paths
581
    #       One for an exaustive search
582
    #       Others for selective searchs
583
    #
1609 dpurdie 584
    #   NOTE: "${Platform}_${MachType}" is a work around for SOLARIS_sparc.
585
    #         Should really use the version 2.x.x technique and read in the
586
    #         build.cfg file
1530 dpurdie 587
    #
1609 dpurdie 588
    foreach my $part ( $Platform, $Product, $Target, "${Platform}_${MachType}" , $MachType )
1530 dpurdie 589
    {
590
        next unless ( $part );
591
        foreach my $subdir ( "lib." . "$part",
592
                             "lib." . "$part" . "$BuildType",
593
                             "lib/lib." . "$part" . "$BuildType",
594
                             "lib/$part" . "$BuildType",
595
                             "lib/$part" )
596
        {
597
            if ( -d "$DpkgLibDir/$subdir" )
598
            {
599
                UniquePush( \@{$DpkgLibDirList{_ALL_}}, $subdir);
600
                UniquePush( \@{$DpkgLibDirList{$part}}, $subdir);
601
            }
602
        }
603
    }
604
 
1609 dpurdie 605
    foreach my $part ( $Platform, $Product, $Target, "${Platform}_${MachType}" , $MachType )
1530 dpurdie 606
    {
607
        next unless ( $part );
608
        foreach my $subdir ( "bin." . "$part" . "$BuildType",
609
                             "bin." . "$part",
610
                             "bin/bin." . "$part" . "$BuildType",
611
                             "bin/" . "$part" . "$BuildType",
612
                             "bin/" . uc($part) . "$BuildType",
613
                             "bin/$part",
614
 
615
                             "bin." . "$part" . "P",
616
                             "bin/bin." . "$part" . "P",
617
                             "bin/" . "$part" . "P",
618
                             "bin/" . uc($part) . "P" )
619
        {
620
            if ( -d "$DpkgBinDir/$subdir" )
621
            {
622
                UniquePush( \@{$DpkgBinDirList{_ALL_}}, $subdir);
623
                UniquePush( \@{$DpkgBinDirList{$part}}, $subdir);
624
            }
625
        }
626
 
627
    }
628
 
629
    LogNorm("------------------------------------------------------------");
630
 
631
 
632
    # lets generate the patch id if we are building a patch
633
    #
634
    if ( "x$PkgPatchNum" ne "x" )
635
    {
636
        LogNorm("This is a PATCH build...");
637
 
638
        $PkgPatchName = uc ($PkgName);
639
 
640
 
641
        my ($_tmpStr) = sprintf("%s%s", $PkgPatchName, 
642
                                        $PkgVersionStr);
643
 
644
 
645
        $PkgPatchID     = "$_tmpStr" . "-" . "$PkgPatchNum"; 
646
        $PkgPatchReadme = "$PkgBaseDir" . "/README." . "$PkgPatchID"; 
647
        $PkgPatchTmpDir = "$PkgBaseDir/tmp";
648
 
649
        $PkgReleaseNote = "$PkgBaseDir" . "/$PkgPatchName" . 
650
                                                                "$PkgVersionStr\_" . 
651
                                                                "$PkgPatchNum\_" . 
652
                                                                "$ProjectAcronym\_" . 
653
                                                                "$Platform"; 
654
 
655
        $PkgLabel = uc ($ProjectAcronym) . "_" .
656
                               $PkgPatchName . "_" .
657
                               $PkgVersionStr . 
658
                               "_P" . $PkgPatchNum;  
659
 
660
 
661
        # lets define what our output package name shall be
662
        #
663
        $PkgOutputFile = "na"; 
664
    }
665
    else
666
    {
667
        LogNorm("This is a normal RELEASE build...");
668
        $PkgReleaseNote = "$PkgBaseDir" . "/" .
669
                                                                "$PkgName" . "-" . 
670
                                                                "$PkgVersion" . "." .
671
                                                                "$ProjectAcronym" . "-" .
672
                                                                "$Platform";
673
 
674
        $PkgLabel = uc ($ProjectAcronym) . "_" .
675
                               uc ($PkgName) . "_" .
676
                               "R_" .
677
                               "$PkgVersionStr";  
678
 
679
 
680
        # lets define what our output package name shall be
681
        #
682
        $PkgOutputFile = "$PkgName" . "-" . 
683
                         "$PkgVersion" . "." .
684
                         "$ProjectAcronym" . "-" .
685
                         "$Platform" . "-" .
686
                         "$BuildType\.pkg";
687
    }
688
 
689
 
690
    # lets load all our build dependencies
691
    #
692
    $BuildFileInfo = DeployUtils::BuildFile->new("$RootDir/build.pl");
693
    # Now lets make a copy into %BuildPkgArchive
694
    %BuildPkgArchive = $BuildFileInfo->getDpkgArchiveHash();
695
 
696
    LogNorm("------------------------------------------------------------");
697
 
698
 
699
    # lets just show what we have determined.
700
    #
701
    LogNorm("Current environment definitions (Increase Debug Level to see all definitions)...");
702
 
703
    LogInfo("DeployFiles      =[$PKG_UTIL_DIR]");
704
 
705
    LogNorm("PkgName          =[$PkgName]");
706
    LogNorm("PkgVersionUser   =[$PkgVersionUser]");
707
 
708
    LogNorm("PkgVersion       =[$PkgVersion]");
709
    LogNorm("PkgVersionStr    =[$PkgVersionStr]");
710
 
711
    LogNorm("PkgBuildNum      =[$PkgBuildNum]");
712
 
713
    if ( "x$PkgPatchID" ne "x" )
714
    {
715
        LogNorm("PkgPatchName     =[$PkgPatchName]");
716
        LogNorm("PkgPatchNum      =[$PkgPatchNum]");
717
        LogNorm("PkgPatchID       =[$PkgPatchID]");
718
        LogNorm("PkgPatchTmpDir   =[$PkgPatchTmpDir]");
719
    }
720
 
721
    LogNorm("PkgReleaseNote   =[$PkgReleaseNote]");
722
    LogNorm("PkgLabel         =[$PkgLabel]");
723
 
724
    LogNorm("PkgPreviousVersionStr=[$PkgPreviousVersionStr]");
725
 
726
    LogNorm("ProjectAcronym   =[$ProjectAcronym]");
727
    LogNorm("BuildType        =[$BuildType]");
728
    LogNorm("MachType         =[$MachType]");
729
    LogNorm("Platform         =[$Platform]");
730
    LogNorm("Product          =[$Product]");
731
    LogNorm("Target           =[$Target]");
732
 
733
    LogNorm("CurrentDir       =[$CurrentDir]");
734
    LogNorm("RootDir          =[$RootDir]");
735
    LogNorm("SandBoxName      =[$SandBoxName]");
736
    LogNorm("Username         =[$Username]");
737
 
738
    LogNorm("TargetBaseDir    =[$TargetBaseDir]");
739
    LogNorm("TargetHomeDir    =[$TargetHomeDir]");
740
 
741
    LogNorm("PkgBaseDir       =[$PkgBaseDir]");
742
    LogNorm("SrcDir           =[$SrcDir]");
743
    LogNorm("PkgDir           =[$PkgDir]");
744
    LogNorm("ReleaseDir       =[$ReleaseDir]");
745
 
746
    LogInfo("InterfaceDir     =[$InterfaceDir]");
747
    LogInfo("DpkgScriptsDir   =[$DpkgScriptsDir]");
748
    LogInfo("DpkgBinDir(s)    =[");
749
    foreach $i (@{$DpkgBinDirList{'_ALL_'}})
750
    {
751
        LogInfo("                   $DpkgBinDir/$i");
752
    }
753
    LogInfo("                  ]");
754
 
755
 
756
    LogInfo("DpkgLibDir(s)    =[");
757
    foreach $i (@{$DpkgLibDirList{'_ALL_'}})
758
    {
759
        LogInfo("                   $DpkgLibDir/$i");
760
    }
761
    LogInfo("                  ]");
762
 
763
 
764
    LogInfo("DpkgEtcDir       =[$DpkgEtcDir]");
765
    LogInfo("DpkgJarDir       =[$DpkgJarDir]");
766
    LogInfo("DpkgSarDir       =[$DpkgSarDir]");
767
    LogInfo("DpkgWarDir       =[$DpkgWarDir]");
768
    LogInfo("DpkgSqlDir       =[$DpkgSqlDir]");
769
    LogInfo("DpkgJspDir       =[$DpkgJspDir]");
770
    LogInfo("DpkgRoxDir       =[$DpkgRoxDir]");
771
    LogInfo("DpkgRptDir       =[$DpkgRptDir]");
772
    LogInfo("DpkgAcHtmlDir    =[$DpkgAcHtmlDir]");
773
    LogInfo("DpkgIncludeDir   =[$DpkgIncludeDir]");
774
    LogInfo("DpkgDevcdDir     =[$DpkgDevcdDir]");
775
    LogInfo("DpkgDatDir       =[$DpkgDatDir]");
776
    LogInfo("DpkgThxDir       =[$DpkgThxDir]");
777
    LogInfo("DpkgMugDir       =[$DpkgMugDir]");
778
    LogInfo("DpkgDocDir       =[$DpkgDocDir]");
779
 
780
    LogInfo("DpkgInfoFilesDir =[$DpkgInfoFilesDir]");
781
    LogInfo("DpkgPkgDir       =[$DpkgPkgDir]");
782
 
783
    LogInfo("PkgInfoFile      =[$PkgInfoFile]");
784
    LogInfo("ProtoTypeFile    =[$ProtoTypeFile]");
785
 
786
    foreach $i ( $BuildFileInfo->getDpkgArchiveList() )
787
    {
788
        my $moduleInfo = $BuildFileInfo->getDpkgArchiveInfo($i);
789
 
790
        LogInfo(  "Build Dependency =" .
791
                  "[$moduleInfo->{type}] " .
792
                  "[$i] " .
793
                  "[$moduleInfo->{version}] " .
794
                  "[$moduleInfo->{proj}]");
795
    }
796
 
797
    if ( "$MachType" eq "sparc" )
798
    {
799
        LogNorm("PkgOutputFile    =[$PkgOutputFile]");
800
    }
801
 
802
    LogNorm("PkgOverview      =[$PKG_OVERVIEW]");
803
 
804
 
805
    # Lets evaluate TargetDstDirStructure to expand any vars
806
    foreach $i ( keys %TargetDstDirStructure )
807
    {
808
        if ( $TargetDstDirStructure{$i} =~ /\$/ )
809
        {
810
            LogDebug("-n", "Expanding TargetDstDirStructure [$TargetDstDirStructure{$i}] to ");
811
            $TargetDstDirStructure{$i} = eval "sprintf " . qq/"$TargetDstDirStructure{$i}"/;
812
            print("[$TargetDstDirStructure{$i}]\n");
813
        }
814
    }
815
 
816
    # lets check waht we can before proceeding.
817
    #
818
    ValidateLocalSrcDirStructure();
819
 
820
    # Everything went ok lets begin by creating some dirs...
821
    #
822
    CreateTargetDirStructure();
823
 
824
    # lets get some details for our package
825
    getRmDetails();
826
 
827
    # done
828
    return 1;
829
}
830
 
831
 
832
#------------------------------------------------------------------------------
833
sub setPkgDescription
834
#
835
# Description:
836
#       This sub-routine is used to set the Package DESC field
837
#       from within the deployfile.
838
#
839
#------------------------------------------------------------------------------
840
{
841
    # correct number of parameters?
842
    if ( ($#_+1) != 1 )
843
    {
844
        LogError("Incorrect number of params passed to " .
845
                  "setPkgDescription() function. " .
846
                  "Check deploy config.");
847
    }
848
    my ($lpkgDesc) = shift;
849
 
850
    # we use what was defined in deployfile if
851
    # the RM details are not available
852
    if ( ! defined($RmPkgDetails) )
853
    {
854
        $PkgDesc = $lpkgDesc;
855
    }
856
    else
857
    {
858
        # let's use the details if we have them
859
        if ( $RmPkgDetails->foundDetails() )
860
        {
861
            # we have RM details, we will only use them
862
            # if nothing is locally defined,
863
            # (ie locally defined details takes precedence)
864
            if ( "x$lpkgDesc" eq "x" )
865
            {
866
                $PkgDesc = $RmPkgDetails->pv_description();
867
            }
868
            else
869
            {
870
                $PkgDesc = $lpkgDesc;
871
            }
872
        }
873
        else
874
        {
875
            $PkgDesc = $lpkgDesc;
876
        }
877
    }
878
 
879
    # done
880
    return 1;
881
}
882
 
883
#------------------------------------------------------------------------------
884
sub setPkgName
885
#
886
# Description:
887
#       This sub-routine is used to set the Package NAME field
888
#       from within the deployfile.
889
#
890
#------------------------------------------------------------------------------
891
{
892
    # correct number of parameters?
893
    if ( ($#_+1) != 1 )
894
    {
895
        LogError("Incorrect number of params passed to " .
896
                  "setPkgName() function. " .
897
                  "Check deploy config.");
898
    }
899
    $PkgNameLong = shift;
900
 
901
    # done
902
    return 1;
903
}
904
 
905
 
906
#------------------------------------------------------------------------------
907
sub setErgAfcBaseDir
908
#
909
# Description:
910
#       This sub-routine is used to reset the ERG AFC base dir global variable
911
#       from within the deployfile.
912
#
913
#------------------------------------------------------------------------------
914
{
915
    # if TargetBaseDir is empty then init has not been called yet so we can set 
916
    # base dir, if however it is not null then init has been called and setting
917
    # base dir after init causes problems in some cases.
918
    if ( $TargetBaseDir ne "" )
919
    {
920
        LogError("setErgAfcBaseDir() cannot be called after Init(), place before Init() in deployfile.pl");
921
    }
922
 
923
    # correct number of parameters?
924
    if ( ($#_+1) != 1 )
925
    {
926
        LogError("Incorrect number of params passed to " .
927
                  "setErgBaseDir() function. " .
928
                  "Check deploy config.");
929
    }
930
 
931
    my ($newDir) = @_;
932
    $ERGAFC_BASEDIR = "$newDir";
933
 
934
    return 1;
935
}
936
 
937
 
938
 
939
#------------------------------------------------------------------------------
940
sub getErgAfcBaseDir
941
#
942
# Description:
943
#       This sub-routine is used to get the ERG AFC base dir global variable
944
#       to be used within the deployfile.
945
#
946
#------------------------------------------------------------------------------
947
{
948
    # correct number of parameters?
949
    if ( ($#_+1) != 0 )
950
    {
951
        LogError("Incorrect number of params passed to " .
952
                  "getErgBaseDir() function. " .
953
                  "Check deploy config.");
954
    }
955
 
956
    return "$ERGAFC_BASEDIR";
957
}
958
 
959
 
960
#------------------------------------------------------------------------------
961
sub setPkgOverview
962
#
963
# Description:
964
#       This sub-routine is used to reset the package overview that
965
#       is used to build the package from within the deployfile.
966
#
967
#------------------------------------------------------------------------------
968
{
969
    # correct number of parameters?
970
    if ( ($#_+1) != 1 )
971
    {
972
        LogError("Incorrect number of params passed to " .
973
                  "setPkgOverview() function. " .
974
                  "Check deploy config.");
975
    }
976
 
977
    my ($mStr) = @_;
978
    $PKG_OVERVIEW = "$mStr";
979
 
980
    return 1;
981
}
982
 
983
 
984
#------------------------------------------------------------------------------
985
sub getPkgOverview
986
#
987
# Description:
988
#       This sub-routine is used to get the package overview string global variable
989
#       to be used within the deployfile.
990
#
991
#------------------------------------------------------------------------------
992
{
993
    # correct number of parameters?
994
    if ( ($#_+1) != 0 )
995
    {
996
        LogError("Incorrect number of params passed to " .
997
                  "getPkgOverview() function. " .
998
                  "Check deploy config.");
999
    }
1000
 
1001
    return "$PKG_OVERVIEW";
1002
}
1003
 
1004
 
1005
 
1006
#------------------------------------------------------------------------------
1007
sub addInstallshieldFiles
1008
#
1009
#    Description:
1010
#        This is called to add extra installshield files to the PKG_ISHIELD_FILES array.
1011
#        For each parameter it checks for the existense of arg.* in the PKG_UTIL_DIR
1012
#        and adds all found files to the array
1013
#        This must be called before init() is called.
1014
#
1015
#    INPUT:
1016
#        files to add
1017
#
1018
#    RETURN:
1019
#        nothing
1020
#
1021
#------------------------------------------------------------------------------
1022
{
1023
    my @files;
1024
 
1025
    # lets just check to see if we can execute this function on this machine.
1026
    if ( "$MachType" eq "sparc" )
1027
    {
1028
        LogInfo("addInstallshieldFiles() not supported on this machine type.");
1029
        return 1;
1030
    }
1031
 
1032
    foreach my $i ( @_ )
1033
    {
1034
        @files = glob("$PKG_UTIL_DIR/$i.*");
1035
        foreach my $j ( @files )
1036
        {
1037
            $j = basename($j);
1038
            LogNorm("Adding Installshield file $j");
1039
            push(@PKG_ISHIELD_FILES, $j);
1040
        }
1041
    }
1042
    return 1;
1043
}   # addInstallshieldFiles
1044
 
1045
 
1046
 
1047
#------------------------------------------------------------------------------
1048
sub removeBuildTypeFromItemName
1049
#
1050
#    Description:
1051
#        This sub-routine is used to remove the buildtype from the item name.
1052
#        i.e. debug files will be tagged with *D.* 
1053
#             prod  file will be tagged with *P.*
1054
#
1055
#    INPUT:
1056
#        item name
1057
#
1058
#    RETURN:
1059
#        new item name.
1060
#
1061
#------------------------------------------------------------------------------
1062
{
1063
    my ($file) = @_;
1064
 
1065
    my ($nfile) = $file;
1066
    $nfile =~ s/D\.|P\./\./;
1067
    return "$nfile";
1068
}
1069
 
1070
 
1071
 
1072
#------------------------------------------------------------------------------
1073
sub installAllDpkgArchivePkgFiles
1074
#
1075
# Description:
1076
#       This sub-routine is used to install all infofiles files from the
1077
#       dpkg_archive into the defined install area.
1078
#
1079
#       It assumes based on the build type where the src files will be located.
1080
#
1081
#       If it has any problems it will log an error and stop processing.
1082
#
1083
#       Source directory: $DpkgPkgDir       (interface/pkg)
1084
#       Target directory: $PkgBaseDir       (output/pkg/[debug|prod]
1085
#
1086
#------------------------------------------------------------------------------
1087
{
1088
    #
1089
    #   Use the (now) more general function installAllDpkgArchivePkgFiles2
1090
    #   with spacial parameters to mimic the original function
1091
    #
1092
    #   Copy all from the 'pkg' directory to the PkgBaseDir
1093
    #
1094
    installAllDpkgArchivePkgFiles2 ( "--Dstdir=$PkgBaseDir", '--Srcdir=pkg', @_ );
1095
    return 1;
1096
}
1097
 
1098
 
1099
#------------------------------------------------------------------------------
1100
sub installAllDpkgArchivePkgFiles2
1101
#
1102
# Description:
1103
#       This sub-routine is used to install all pkg files from the
1104
#       dpkg_archive into the defined install area.
1105
#
1106
#       Simlar to installAllDpkgArchivePkgFiles, but the target directory
1107
#       is specified by the user.
1108
#
1109
#       It assumes based on the build type where the src files will be located.
1110
#
1111
#       If it has any problems it will log an error and stop processing.
1112
#
1113
# Inputs          : targetTag       - Target directory      [Mandatory]
1114
#                   options         - Optional options
1115
#                                       --Srcdir=path       [default=pkg]
1116
#                                       --Dstdir=abs_path   [internal use]
1117
#                                       --NoRecurse
1118
#                                       --Recurse           [default]
1119
#                                       --Flatten
1120
#                                       --NoFlatten         [default]
1121
#                                       --FilterIn=xx
1122
#                                       --FilterInRE=xx     [default=.*]
1123
#                                       --FilterOut=xx
1124
#                                       --FilterOutRE=xx
1125
#
1126
# Notes:    --FilterIn=xxxx, --FilterOut=xxx
1127
#           xxx is a simple Shell style filter where:
1128
#               * means one or more charters        '*.EXE'
1129
#               ? means a single character          '*.?'
1130
#               [abc] means either a or b or c      'file.[ch]'
1131
#
1132
#           --FilterInRE=xxx, --FilterOutRE=xxx
1133
#           xxx is a Regular Expression. There are harder to use but very
1134
#           powerful. ie '.*\.EXE$'
1135
#
1136
#           The 'In' filters are applied before the 'Out' filters.
1137
#
1138
#           If no 'In' filters are specified then all files will be included.
1139
#
1140
#           The filter rules are applied to the path below the Srcdir, and, for
1141
#           the purposes of the filter the path starts with a '/'.
1142
#
1143
#------------------------------------------------------------------------------
1144
{
1145
    my $src_base_dir;
1146
    my $recurse = 1;
1147
    my @dir_tree_exclude;
1148
    my @dir_tree_include;
1149
    my $flatten = 0;
1150
    my $dstDir;
1151
 
1152
    LogNorm("Installing all Prepared pkg files...");
1153
 
1154
    #
1155
    #   Process the arguments and extract parameters and options
1156
    #
1157
    foreach ( @_ )
1158
    {
1159
        if ( m/^--Srcdir=(.*)/ ) {
1160
            LogError("installAllDpkgArchivePkgFiles2: Multiple --Srcdir not allowed")
1161
                if ( $src_base_dir );
1162
            $src_base_dir = "$InterfaceDir/$1";
1163
 
1164
        } elsif ( /^--Dstdir=(.*)/ ) {
1165
            LogError("installAllDpkgArchivePkgFiles2: Multiple target directories not allowed")
1166
                if ( $dstDir );
1167
            $dstDir = $1;
1168
 
1169
        } elsif ( m/^--NoRecurse/ ) {
1170
            $recurse = 0;
1171
 
1172
        } elsif ( m/^--Recurse/ ) {
1173
            $recurse = 1;
1174
 
1175
        } elsif ( /^--FilterOut=(.*)/ ) {
1176
            push @dir_tree_exclude, glob2pat($1);
1177
 
1178
        } elsif ( /^--FilterOutRE=(.*)/ ) {
1179
            push @dir_tree_exclude, $1;
1180
 
1181
        } elsif ( /^--FilterIn=(.*)/ ) {
1182
            push @dir_tree_include, glob2pat($1);
1183
 
1184
        } elsif ( /^--FilterInRE=(.*)/ ) {
1185
            push @dir_tree_include, $1;
1186
 
1187
        } elsif ( /^--Flatten/ ) {
1188
            $flatten = 1;
1189
 
1190
        } elsif ( /^--NoFlatten/ ) {
1191
            $flatten = 0;
1192
 
1193
        } elsif ( m/^--/ ) {
1194
            LogError("installAllDpkgArchivePkgFiles2: Unknown option: $_")
1195
 
1196
        } else {
1197
            LogError("installAllDpkgArchivePkgFiles2: Multiple target directories not allowed")
1198
                if ( $dstDir );
1199
 
1200
            #   Convert the symbolic target directory name into a real path
1201
 
1202
            $dstDir = getTargetDstDirValue($_, "A");
1203
        }
1204
    }
1205
 
1206
    #
1207
    #   Ensure that we have a valid source directory
1208
    #   Data taken from the 'pkg' directory unless otherwise specified by the user
1209
    #
1210
    $src_base_dir = $DpkgPkgDir unless $src_base_dir;
1211
    LogError("installAllDpkgArchivePkgFiles2: Package directory not found: $src_base_dir")
1212
        unless ( -d $src_base_dir );
1213
 
1214
    #
1215
    #   Ensure that the user has specified a target directory
1216
    #
1217
    LogError("installAllDpkgArchivePkgFiles2: No target directories specified")
1218
        unless ( $dstDir );
1219
 
1220
    #
1221
    #   Build up a list of files to copy
1222
    #   Creating a list allows:
1223
    #       Simplified coding
1224
    #       Flattening and testing of the flattening
1225
    #
1226
    my @elements = ExpandDirTree( $src_base_dir, \@dir_tree_exclude, \@dir_tree_include, $recurse );
1227
 
1228
    #
1229
    #   Perform the file copy
1230
    #   This copy will NOT create empty directories, but it will create needed
1231
    #   directories on the fly.
1232
    #
1233
    foreach  my $sfile ( @elements )
1234
    {
1235
 
1236
        #
1237
        #   Split into directory and file as we may need to make the directory
1238
        #   since the copy operation will not
1239
        #
1240
        my $dir;                                # Target directory
1241
        my $tfile;                              # Target path
1242
       (my $fname = $sfile )=~ s~^.*/+~~;        # Filename(only)
1243
 
1244
        unless ( $flatten )
1245
        {
1246
            $sfile =~ m~^(.*/)~;
1247
            $dir = "$dstDir/$1";
1248
            $tfile = $sfile;
1249
        }
1250
        else
1251
        {
1252
            $dir = $dstDir;
1253
            $tfile = $fname;
1254
        }
1255
 
1256
        #
1257
        #   Ensure the target directory is present
1258
        #
1259
        unless ( -d $dir )
1260
        {
1261
            LogInfo ( "mkdir $dir");
1262
            mkpath ( $dir, 0, 0775);
1263
        }
1264
 
1265
        #
1266
        #   Copy the file
1267
        #   Ensure that the target file does not already exist
1268
        #   This is most likely to occur when flattening the directory structure
1269
        #
1270
        my $m_sfile = "$src_base_dir$sfile";
1271
        my $m_tfile = "$dstDir/$tfile";
1272
 
1273
        if ( -f $m_tfile  )
1274
        {
1275
            LogError("Failed to copy file [$m_sfile] to [$m_tfile]: File already exists");
1276
        }
1277
 
1278
        if( File::Copy::copy("$m_sfile", "$m_tfile") )
1279
        {
1280
            LogNorm("Copied [$fname] to [$m_tfile] ...");
1281
        }
1282
        else
1283
        {
1284
            LogError("Failed to copy file [$m_sfile] to [$m_tfile]: $!");
1285
        }
1286
    }
1287
 
1288
    return 1;
1289
}
1290
 
1291
#-------------------------------------------------------------------------------
1292
# Function        : glob2pat
1293
#
1294
# Description     : Convert four shell wildcard characters into their equivalent
1295
#                   regular expression; all other characters are quoted to
1296
#                   render them literals.
1297
#
1298
# Inputs          : Shell style wildcard pattern
1299
#
1300
# Returns         : Perl RE
1301
#
1302
 
1303
sub glob2pat
1304
{
1305
    my $globstr = shift;
1306
    $globstr =~ s~^/~~;
1307
    my %patmap = (
1308
        '*' => '[^/]*',
1309
        '?' => '[^/]',
1310
        '[' => '[',
1311
        ']' => ']',
1312
    );
1313
    $globstr =~ s{(.)} { $patmap{$1} || "\Q$1" }ge;
1314
    return '/' . $globstr . '$';
1315
}
1316
 
1317
#-------------------------------------------------------------------------------
1318
# Function        : ExpandDirTree
1319
#
1320
# Description     : Search a directory tree and return a list of files
1321
#                   that match the inclusion and exclusion filter
1322
#
1323
#                   The include filter is applied before the exclusuion filter
1324
#
1325
# Inputs          : $dir        - Directory to process
1326
#                   $exclude    - Ref to a List of regexps of files to exclude
1327
#                   $include    - Ref to a List of regexps of files to include
1328
#                   $recurse    - True: recurse subdirs
1329
#
1330
# Returns         : A list of files
1331
#
1332
my @ExpandDirTree_list;             # Must be global to avoid closure problems
1333
my $ExpandDirTree_len;
1334
 
1335
sub ExpandDirTree
1336
{
1337
    my( $dir, $exclude, $include, $recurse ) = @_;
1338
 
1339
    #
1340
    #   Clean up the user dir. Remove any trailing / as we will be adding it back
1341
    #
1342
    #
1343
    $dir =~ s~/*$~~g;
1344
 
1345
    #
1346
    #   Init recursion information
1347
    #   Needed to avoid closure interactions
1348
    #
1349
 
1350
    @ExpandDirTree_list = ();
1351
    $ExpandDirTree_len = length( $dir );
1352
 
1353
    #
1354
    #   Create a list of candidate files
1355
    #   If we are recursing the subtree, then this is a little harder
1356
    #   If we are not recursing then we can't simply glob the directory as
1357
    #   not all files are processed.
1358
    #
1359
    #   Will end up with a list of files that
1360
    #       1) Start with a '/'
1361
    #       2) Are rooted as $dir, but don't include $dir
1362
    #
1363
    if ( $recurse )
1364
    {
1365
        sub find_file_wanted
1366
        {
1367
            return if ( -d $_ );
1368
            my $file = $File::Find::name;
1369
            push @ExpandDirTree_list, substr($file, $ExpandDirTree_len );
1370
        }
1371
 
1372
        #
1373
        #       Under Unix we need to follow symbolic links, but Perl's
1374
        #       Find:find does not work with -follow under windows if the source
1375
        #       path contains a drive letter.
1376
        #
1377
        #       Solution. Only use follow under non-windows systems.
1378
        #                 Works as Windows does not have symlinks (yet).
1379
        #
1380
        my $follow_opt =  ! ( "$MachType" eq "win32" || "$MachType" eq "WinCE" );
1381
 
1382
        File::Find::find( {wanted => \&find_file_wanted, follow_fast => $follow_opt }, $dir);
1383
    }
1384
    else
1385
    {
1386
        local *DIR ;
1387
        opendir DIR, $dir || die ("Cannot open $dir");
1388
        foreach ( readdir( DIR ) )
1389
        {
1390
            next if /^\Q.\E$/;
1391
            next if /^\Q..\E$/;
1392
            next if ( -d "$dir/$_" );
1393
            push @ExpandDirTree_list, '/' . $_;
1394
 
1395
        }
1396
        closedir DIR;
1397
    }
1398
 
1399
    #
1400
    #   If filtering is not present then return the entire file list
1401
    #
1402
    return @ExpandDirTree_list
1403
        unless ( @$include || @$exclude );
1404
 
1405
    #
1406
    #   Filtering is present
1407
    #   Apply the filterin rules and then the filter out rules
1408
    #   If no filter-in rules, then assume that all files are allowed in and
1409
    #   simply apply the filter-out rules.
1410
    #
1411
    my @patsin  = map { qr/$_/ } @{$include};
1412
    my @patsout = map { qr/$_/ } @{$exclude};
1413
    my @result;
1414
 
1415
#    map { print "Include:$_\n"; } @{$include};
1416
#    map { print "Exclude:$_\n"; } @{$exclude};
1417
 
1418
 
1419
    file:
1420
    foreach my $file ( @ExpandDirTree_list )
1421
    {
1422
        if ( @$include )
1423
        {
1424
            my $in = 0;
1425
            for my $pat (@patsin)
1426
            {
1427
                if ( $file =~ /$pat/ )
1428
                {
1429
                    $in = 1;
1430
                    last;
1431
                }
1432
            }
1433
#print "------- Not included $file\n" unless $in;
1434
            next unless ( $in );
1435
        }
1436
 
1437
        for my $pat (@patsout)
1438
        {
1439
#print "------- REJECT $file :: $pat \n" if ( $file =~ /$pat/ );
1440
            next file if ( $file =~ /$pat/ );
1441
        }
1442
 
1443
        push @result, $file;
1444
    }
1445
 
1446
    return @result;
1447
}
1448
 
1449
#------------------------------------------------------------------------------
1450
sub installAllDpkgArchiveDevcdFiles
1451
#
1452
# Description:
1453
#       This sub-routine is used to install all devcd files from the
1454
#       dpkg_archive into the defined install area.
1455
#
1456
#       It assumes based on the build type where the src files will be located.
1457
#
1458
#       If it has any problems it will log an error and stop processing.
1459
#
1460
#       Source directory: $DpkgDevcdDir       (interface/devcd)
1461
#       Target directory: Symbolic Directory
1462
#
1463
# Inputs: None
1464
#
1465
#------------------------------------------------------------------------------
1466
{
1467
    # correct number of parameters?
1468
    if ( ($#_+1) != 1 )
1469
    {
1470
        LogError("Incorrect number of params passed to " .
1471
                  "installAllDpkgArchiveDevcdFiles() function. " .
1472
                  "Check deploy config.");
1473
    }
1474
 
1475
    LogNorm("Installing all Prepared Day 0 devcd files...");
1476
 
1477
 
1478
    my ($targetTag) = @_;
1479
 
1480
    # lets check to see if the target tag exists
1481
    # if does not the process with log an error.
1482
    #
1483
    my ($targetValue) = getTargetDstDirValue($targetTag, "R");
1484
 
1485
 
1486
    # ok we have a valid dst value we now need to get a hold of all the 
1487
    # lib scripts files.
1488
    #
1489
    if ( "$MachType" eq "win32" || "$MachType" eq "WinCE" )
1490
    {
1491
        $TmpGlobalVariable = $targetValue; 
1492
        File::Find::find( \&pkgFindDevcd, "$DpkgDevcdDir");
1493
    }
1494
    else
1495
    {
1496
        my ($i);
1497
        my(@FindRes) = `find $DpkgDevcdDir -follow`;
1498
        my ($m_sfile);
1499
        my ($tmp_DstDir) = "$PkgBaseDir/$targetValue";
1500
        my ($tmp_SrcDir) = "$DpkgDevcdDir";
1501
        foreach $i (@FindRes)
1502
        {
1503
 
1504
            chomp($i);
1505
            my($base)= File::Basename::basename($i);
1506
 
1507
            if ( $base eq "devcd" )
1508
            {
1509
                next;
1510
            }
1511
 
1512
            my ($tmp_dItem) = $i;
1513
            $tmp_dItem =~ s/$tmp_SrcDir/$tmp_DstDir/;
1514
 
1515
            if ( -d "$i")
1516
            {
1517
                # we have a directory
1518
                if ( ! -d "$tmp_dItem" )
1519
                {
1520
                    mkpath ( "$tmp_dItem", 0, 0775);
1521
                    LogInfo ( "mkdir $tmp_dItem");
1522
                }
1523
            }
1524
            else
1525
            {
1526
                if(File::Copy::copy("$i", "$tmp_dItem"))
1527
                {
1528
                    LogNorm("Copied [$base] to [$tmp_dItem] ...");
1529
                }
1530
                else
1531
                {
1532
                    LogError("Failed to copy pkg file [$tmp_dItem] to [$i]: $!");
1533
                }
1534
            }
1535
        }
1536
    }
1537
 
1538
    return 1;
1539
}
1540
 
1541
 
1542
#------------------------------------------------------------------------------
1543
sub pkgFindDevcd
1544
#
1545
#    Description:
1546
#        This subroutine is used to locate all associated devcd files in 
1547
#        a pre-defined dpkg_archive.
1548
#
1549
#   Trick: Will not copy a file/directory called 'devcd'
1550
#          Not too sure why. May be an attempt to prevent empty devcd directories
1551
#          If you know better, then correct this comment.
1552
#------------------------------------------------------------------------------
1553
{
1554
    my($item)= "$File::Find::name";
1555
    my($base)= File::Basename::basename($item);
1556
 
1557
    if ( $base eq "devcd" )
1558
    {
1559
        return 1;
1560
    }
1561
 
1562
    my ($tmp_dItem) = $item;
1563
    my ($tmp_DstDir) = "$PkgBaseDir/$TmpGlobalVariable";
1564
    my ($tmp_SrcDir) = "$DpkgDevcdDir";
1565
    $tmp_dItem =~ s/$tmp_SrcDir/$tmp_DstDir/;
1566
 
1567
    # we need to determine what type of item we are dealing with file we are dealing with
1568
    if ( -d "$item")
1569
    {
1570
        # we have a directory
1571
        if ( ! -d "$tmp_dItem" )
1572
        {
1573
            mkpath ( "$tmp_dItem", 0, 0775);
1574
            LogInfo ( "mkdir $tmp_dItem");
1575
        }
1576
    }
1577
    else
1578
    {
1579
        if(File::Copy::copy("$item", "$tmp_dItem"))
1580
        {
1581
            LogNorm("Copied [$base] to [$tmp_dItem] ...");
1582
        }
1583
        else
1584
        {
1585
            LogError("Failed to copy pkg file [$tmp_dItem] to [$item]: $!"); 
1586
        }
1587
    }
1588
}
1589
 
1590
#------------------------------------------------------------------------------
1591
sub installAllDpkgArchiveFiles
1592
#
1593
# Description:
1594
#       This sub-routine is used to install all files from the
1595
#       dpkg_archive into the defined install area.
1596
#
1597
#       It assumes based on the build type where the src files will be located.
1598
#
1599
#       If it has any problems it will log an error and stop processing.
1600
#
1601
# Inputs:   $targetType         - Internal tag to specify source file
1602
#           $targetTag          - Users tag for destination
1603
#
1604
#
1605
#------------------------------------------------------------------------------
1606
{
1607
    # correct number of parameters?
1608
    if ( ($#_+1) != 2 )
1609
    {
1610
        LogError("Incorrect number of params passed to " .
1611
                  "installAllDpkgArchiveFiles() function. " .
1612
                  "Check deploy config.");
1613
    }
1614
 
1615
    my ($targetType, $targetTag) = @_;
1616
 
1617
    # lets check to see if the target tag exists
1618
    # if does not the process with log an error.
1619
    #
1620
    my $targetValue;
1621
    if ( $targetTag eq "--NoTag" )
1622
    {
1623
        $targetValue = "$PkgBaseDir/$TargetBaseDir";
1624
    }
1625
    else
1626
    {
1627
       $targetValue = getTargetDstDirValue($targetTag, "A");
1628
    }
1629
 
1630
    # ok we have a valid dst value we now need to get a hold of all the 
1631
    # lib scripts files.
1632
    #
1633
    local *DIR;
1634
    my $src_dir;
1635
 
1636
    if    ( "$targetType" eq "jar" )        { $src_dir = $DpkgJarDir; }
1637
    elsif ( "$targetType" eq "sar" )        { $src_dir = $DpkgSarDir; }
1638
    elsif ( "$targetType" eq "include" )    { $src_dir = $DpkgIncludeDir; }
1639
    elsif ( "$targetType" eq "war" )        { $src_dir = $DpkgWarDir; }
1640
    elsif ( "$targetType" eq "infofiles" )  { $src_dir = $DpkgInfoFilesDir; }
1641
    elsif ( "$targetType" eq "sql" )        { $src_dir = $DpkgSqlDir; }
1642
    elsif ( "$targetType" eq "etc" )        { $src_dir = $DpkgEtcDir; }
1643
    elsif ( "$targetType" eq "scripts" )    { $src_dir = $DpkgScriptsDir; }
1644
    elsif ( "$targetType" eq "rox" )        { $src_dir = $DpkgRoxDir; }
1645
    elsif ( "$targetType" eq "rpt" )        { $src_dir = $DpkgRptDir; }
1646
    elsif ( "$targetType" eq "doc" )        { $src_dir = $DpkgDocDir; }
1647
    elsif ( "$targetType" eq "jsp" )        { $src_dir = $DpkgJspDir; }
1648
#    elsif ( "$targetType" eq "achtml" )     { $src_dir = $DpkgAcHtmlDir; }
1649
    else  {
1650
        LogError("installAllDpkgArchiveFiles() passed unknown target type [$targetType].");
1651
    }
1652
 
1653
    opendir(DIR, $src_dir) or
1654
            LogError("can't opendir $src_dir: $!");
1655
 
1656
 
1657
    # lets process what we have found
1658
    #
1659
    my ($file);
1660
    while (defined($file = readdir(DIR))) 
1661
    {
1662
        if ( $file !~ /^.$/  && 
1663
             $file !~ /^..$/ ) 
1664
        {
1665
            my ($m_fLoc) = "$src_dir/$file";
1666
 
1667
            if(File::Copy::copy("$m_fLoc", "$targetValue"))
1668
            {
1669
                LogNorm("Copied [$targetType] item [$file] to [$targetValue] ...");
1670
            }
1671
            else
1672
            {
1673
                LogError("Failed to copy [$targetType] item [$m_fLoc]: $!"); 
1674
            }
1675
        }
1676
    }
1677
 
1678
    closedir(DIR);
1679
    return 1;
1680
}
1681
 
1682
 
1683
#------------------------------------------------------------------------------
1684
sub installAllDpkgArchiveAcHtmlFiles
1685
#
1686
# Description:
1687
#       This sub-routine is used to install all achtml files from the
1688
#       dpkg_archive into the defined install area.
1689
#
1690
#       It assumes based on the build type where the src files will be located.
1691
#
1692
#       If it has any problems it will log an error and stop processing.
1693
#
1694
#
1695
# Ugly trick:
1696
#       This function tags a $$targetType argument which is used in constructing
1697
#       the source directory path. ie: InterfaceDir/achtml/$targetType
1698
#
1699
#       Could provide as an option to installAllDpkgArchiveFiles and re-use that
1700
#       function
1701
#
1702
#------------------------------------------------------------------------------
1703
{
1704
    # correct number of parameters?
1705
    if ( ($#_+1) != 2 )
1706
    {
1707
        LogError("Incorrect number of params passed to " .
1708
                  "installAllDpkgArchiveAcHtmlFiles() function. " .
1709
                  "Check deploy config.");
1710
    }
1711
    my ($targetType, $targetTag) = @_;
1712
 
1713
    # lets check to see if the target tag exists
1714
    # if does not the process with log an error.
1715
    #
1716
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
1717
 
1718
    # lets check to see if the source type dir actually exists
1719
    #
1720
    my($m_sDirLoc)  = "$DpkgAcHtmlDir/$targetType";
1721
    if( ! -d "$m_sDirLoc" )
1722
    {
1723
        LogError("Failed to locate [$targetType] AcHtml dir [$m_sDirLoc].");
1724
    }
1725
 
1726
    # know everything exists so lets do the biz.
1727
    #
1728
    # now we need to copy all the files.
1729
    #
1730
    local *DIR;
1731
    opendir(DIR, $m_sDirLoc) or 
1732
        LogError("can't opendir $m_sDirLoc: $!");
1733
 
1734
    my ($m_fLoc) = "";
1735
    my ($file) = "";
1736
    while (defined($file = readdir(DIR)))
1737
    {
1738
        if ( $file !~ /^.$/  &&
1739
             $file !~ /^..$/ )
1740
        {
1741
            $m_fLoc = "$m_sDirLoc/$file";
1742
            if(File::Copy::copy("$m_fLoc", "$targetValue"))
1743
            {
1744
                LogNorm("Copied AcHtml [$targetType] item [$file] to [$targetValue] ...");
1745
            }
1746
            else
1747
            {
1748
                LogError("Failed to copy AcHtml [$targetType] item [$m_fLoc]: $!");
1749
            }
1750
        }
1751
    }
1752
 
1753
    closedir(DIR);
1754
    return 1;
1755
}
1756
 
1757
 
1758
#------------------------------------------------------------------------------
1759
sub installAllDpkgArchiveInfoFilesFiles
1760
#
1761
# Description:
1762
#       This sub-routine is used to install all infofiles files from the
1763
#       dpkg_archive into the defined install area.
1764
#
1765
#       It assumes based on the build type where the src files will be located.
1766
#
1767
#       If it has any problems it will log an error and stop processing.
1768
#
1769
#------------------------------------------------------------------------------
1770
{
1771
    # correct number of parameters?
1772
    if ( ($#_+1) != 1 )
1773
    {
1774
        LogError("Incorrect number of params passed to " .
1775
                  "installAllDpkgArchiveInfoFilesFiles() function. " .
1776
                  "Check deploy config.");
1777
    }
1778
 
1779
    my ($targetTag) = @_;
1780
 
1781
    # lets check to see if the target tag exists
1782
    # if does not the process with log an error.
1783
    #
1784
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
1785
 
1786
 
1787
    # for now lets call the generic funtion to move all items
1788
    # in the associated dpkg_archive dir.
1789
    #
1790
    installAllDpkgArchiveFiles("infofiles", $targetTag);
1791
 
1792
    return 1;
1793
}
1794
 
1795
 
1796
 
1797
#------------------------------------------------------------------------------
1798
sub installAllDpkgArchiveSqlFiles
1799
#
1800
# Description:
1801
#       This sub-routine is used to install all sql files from the
1802
#       dpkg_archive into the defined install area.
1803
#
1804
#       It assumes based on the build type where the src files will be located.
1805
#
1806
#       If it has any problems it will log an error and stop processing.
1807
#
1808
#------------------------------------------------------------------------------
1809
{
1810
    # correct number of parameters?
1811
    if ( ($#_+1) != 1 )
1812
    {
1813
        LogError("Incorrect number of params passed to " .
1814
                  "installAllDpkgArchiveSqlFiles() function. " .
1815
                  "Check deploy config.");
1816
    }
1817
 
1818
    my ($targetTag) = @_;
1819
 
1820
    # lets check to see if the target tag exists
1821
    # if does not the process with log an error.
1822
    #
1823
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
1824
 
1825
 
1826
    # for now lets call the generic funtion to move all items
1827
    # in the associated dpkg_archive dir.
1828
    #
1829
    installAllDpkgArchiveFiles("sql", $targetTag);
1830
 
1831
    return 1;
1832
}
1833
 
1834
 
1835
#------------------------------------------------------------------------------
1836
sub installAllDpkgArchiveWarFiles
1837
#
1838
# Description:
1839
#       This sub-routine is used to install all war files from the
1840
#       dpkg_archive into the defined install area.
1841
#
1842
#       It assumes based on the build type where the src files will be located.
1843
#
1844
#       If it has any problems it will log an error and stop processing.
1845
#
1846
#------------------------------------------------------------------------------
1847
{
1848
    # correct number of parameters?
1849
    if ( ($#_+1) != 1 )
1850
    {
1851
        LogError("Incorrect number of params passed to " .
1852
                  "installAllDpkgArchiveWarFiles() function. " .
1853
                  "Check deploy config.");
1854
    }
1855
 
1856
    my ($targetTag) = @_;
1857
 
1858
    # lets check to see if the target tag exists
1859
    # if does not the process with log an error.
1860
    #
1861
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
1862
 
1863
 
1864
    # for now lets call the generic funtion to move all items
1865
    # in the associated dpkg_archive dir.
1866
    #
1867
    installAllDpkgArchiveFiles("war", $targetTag);
1868
 
1869
    return 1;
1870
}
1871
 
1872
 
1873
#------------------------------------------------------------------------------
1874
sub installAllDpkgArchiveJarFiles
1875
#
1876
# Description:
1877
#       This sub-routine is used to install all jar files from the
1878
#       dpkg_archive into the defined install area.
1879
#
1880
#       It assumes based on the build type where the src files will be located.
1881
#
1882
#       If it has any problems it will log an error and stop processing.
1883
#
1884
#------------------------------------------------------------------------------
1885
{
1886
    # correct number of parameters?
1887
    if ( ($#_+1) != 1 )
1888
    {
1889
        LogError("Incorrect number of params passed to " .
1890
                  "installAllDpkgArchiveJarFiles() function. " .
1891
                  "Check deploy config.");
1892
    }
1893
 
1894
    my ($targetTag) = @_;
1895
 
1896
    # lets check to see if the target tag exists
1897
    # if does not the process with log an error.
1898
    #
1899
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
1900
 
1901
 
1902
    # for now lets call the generic funtion to move all items
1903
    # in the associated dpkg_archive dir.
1904
    #
1905
    installAllDpkgArchiveFiles("jar", $targetTag);
1906
 
1907
    return 1;
1908
}
1909
 
1910
 
1911
#------------------------------------------------------------------------------
1912
sub installAllDpkgArchiveEtcFiles
1913
#
1914
# Description:
1915
#       This sub-routine is used to install all etc files from the
1916
#       dpkg_archive into the defined install area.
1917
#
1918
#       It assumes based on the build type where the src files will be located.
1919
#
1920
#       If it has any problems it will log an error and stop processing.
1921
#
1922
#------------------------------------------------------------------------------
1923
{
1924
    # correct number of parameters?
1925
    if ( ($#_+1) != 1 )
1926
    {
1927
        LogError("Incorrect number of params passed to " .
1928
                  "installAllDpkgArchiveEtcFiles() function. " .
1929
                  "Check deploy config.");
1930
    }
1931
 
1932
    my ($targetTag) = @_;
1933
 
1934
    # lets check to see if the target tag exists
1935
    # if does not the process with log an error.
1936
    #
1937
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
1938
 
1939
 
1940
    # for now lets call the generic funtion to move all items
1941
    # in the associated dpkg_archive dir.
1942
    #
1943
    installAllDpkgArchiveFiles("etc", $targetTag);
1944
 
1945
    return 1;
1946
}
1947
 
1948
 
1949
#------------------------------------------------------------------------------
1950
sub installAllDpkgArchiveScriptsFiles
1951
#
1952
# Description:
1953
#       This sub-routine is used to install all scripts files from the
1954
#       dpkg_archive into the defined install area.
1955
#
1956
#       It assumes based on the build type where the src files will be located.
1957
#
1958
#       If it has any problems it will log an error and stop processing.
1959
#
1960
#------------------------------------------------------------------------------
1961
{
1962
    # correct number of parameters?
1963
    if ( ($#_+1) != 1 )
1964
    {
1965
        LogError("Incorrect number of params passed to " .
1966
                  "installAllDpkgArchiveScriptsFiles() function. " .
1967
                  "Check deploy config.");
1968
    }
1969
 
1970
    my ($targetTag) = @_;
1971
 
1972
    # lets check to see if the target tag exists
1973
    # if does not the process with log an error.
1974
    #
1975
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
1976
 
1977
 
1978
    # for now lets call the generic funtion to move all items
1979
    # in the associated dpkg_archive dir.
1980
    #
1981
    installAllDpkgArchiveFiles("scripts", $targetTag);
1982
 
1983
    return 1;
1984
}
1985
 
1986
 
1987
#------------------------------------------------------------------------------
1988
sub installAllDpkgArchiveIncludeFiles
1989
#
1990
# Description:
1991
#       This sub-routine is used to install all include files from the
1992
#       dpkg_archive into the defined install area.
1993
#
1994
#       It assumes based on the build type where the src files will be located.
1995
#
1996
#       If it has any problems it will log an error and stop processing.
1997
#
1998
#------------------------------------------------------------------------------
1999
{
2000
    # correct number of parameters?
2001
    if ( ($#_+1) != 1 )
2002
    {
2003
        LogError("Incorrect number of params passed to " .
2004
                  "installAllDpkgArchiveIncludeFiles() function. " .
2005
                  "Check deploy config.");
2006
    }
2007
 
2008
    my ($targetTag) = @_;
2009
 
2010
    # lets check to see if the target tag exists
2011
    # if does not the process with log an error.
2012
    #
2013
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2014
 
2015
 
2016
    # for now lets call the generic funtion to move all items
2017
    # in the associated dpkg_archive dir.
2018
    #
2019
    installAllDpkgArchiveFiles("include", $targetTag);
2020
 
2021
    return 1;
2022
}
2023
 
2024
 
2025
#------------------------------------------------------------------------------
2026
sub installAllDpkgArchiveDocFiles
2027
#
2028
# Description:
2029
#       This sub-routine is used to install all include files from the
2030
#       dpkg_archive into the defined install area.
2031
#
2032
#       It assumes based on the build type where the src files will be located.
2033
#
2034
#       If it has any problems it will log an error and stop processing.
2035
#
2036
#------------------------------------------------------------------------------
2037
{
2038
    # correct number of parameters?
2039
    if ( ($#_+1) != 1 )
2040
    {
2041
        LogError("Incorrect number of params passed to " .
2042
                  "installAllDpkgArchiveIncludeFiles() function. " .
2043
                  "Check deploy config.");
2044
    }
2045
 
2046
    my ($targetTag) = @_;
2047
 
2048
    # lets check to see if the target tag exists
2049
    # if does not the process with log an error.
2050
    #
2051
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2052
 
2053
 
2054
    # for now lets call the generic funtion to move all items
2055
    # in the associated dpkg_archive dir.
2056
    #
2057
    installAllDpkgArchiveFiles("doc", $targetTag);
2058
 
2059
    return 1;
2060
}
2061
 
2062
#------------------------------------------------------------------------------
2063
sub installAllDpkgArchiveJspFiles
2064
#
2065
# Description:
2066
#       This sub-routine is used to install all jsp associated files from the
2067
#       dpkg_archive into the defined install area.
2068
#
2069
#       It assumes based on the build type where the src files will be located.
2070
#
2071
#       If it has any problems it will log an error and stop processing.
2072
#
2073
#   Source directory: $DpkgJspDir
2074
#   Target directory: $TargetBaseDir
2075
#
2076
#------------------------------------------------------------------------------
2077
{
2078
    # correct number of parameters?
2079
    if ( ($#_+1) != 0 )
2080
    {
2081
        LogError("Incorrect number of params passed to " .
2082
                  "installAllDpkgArchiveJspFiles() function. " .
2083
                  "Check deploy config.");
2084
    }
2085
 
2086
    return installAllDpkgArchiveFiles ('jsp', '--NoTag');
2087
}
2088
 
2089
 
2090
#------------------------------------------------------------------------------
2091
sub installDpkgArchiveFile
2092
#
2093
# Description:
2094
#       This sub-routine is used to install a file of a particular type
2095
#       from the dpkg_archive into the supplied install dir. 
2096
#
2097
#       It assumes based on the build type where the file will be located.
2098
#
2099
#       If it fails to find the file it will report an error and terminates
2100
#       processing.
2101
#
2102
# Inputs:   $targetType         - Type of target ( provides source directory)
2103
#           $sfile              - Source file name, within source directory
2104
#           $targetTag          - Symbolic target dir
2105
#
2106
#
2107
# Note: This function will copy a single file
2108
#
2109
#------------------------------------------------------------------------------
2110
{
2111
    # correct number of parameters?
2112
    if ( ($#_+1) != 3 )
2113
    {
2114
        LogError("Incorrect number of params passed to " .
2115
                  "installDpkgArchiveFile() function. " .
2116
                  "Check deploy config.");
2117
    }
2118
 
2119
    my ($targetType, $sfile, $targetTag) = @_;
2120
 
2121
    # lets check to see if the target tag exists
2122
    # if does not the process with log an error.
2123
    #
2124
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2125
 
2126
 
2127
    # lets define the absolute location of the file
2128
    #
2129
    my ($m_dstFileLocation) = "$targetValue/$sfile";
2130
    my ($m_srcFileLocation) = "";
2131
 
2132
    if    ( "$targetType" eq "jar" )        { $m_srcFileLocation = "$DpkgJarDir/$sfile"; }
2133
    elsif ( "$targetType" eq "sar" )        { $m_srcFileLocation = "$DpkgSarDir/$sfile"; }
2134
    elsif ( "$targetType" eq "include" )    { $m_srcFileLocation = "$DpkgIncludeDir/$sfile"; }
2135
    elsif ( "$targetType" eq "war" )        { $m_srcFileLocation = "$DpkgWarDir/$sfile"; }
2136
    elsif ( "$targetType" eq "infofiles" )  { $m_srcFileLocation = "$DpkgInfoFilesDir/$sfile"; }
2137
    elsif ( "$targetType" eq "sql" )        { $m_srcFileLocation = "$DpkgSqlDir/$sfile"; }
2138
    elsif ( "$targetType" eq "etc" )        { $m_srcFileLocation = "$DpkgEtcDir/$sfile"; }
2139
    elsif ( "$targetType" eq "scripts" )    { $m_srcFileLocation = "$DpkgScriptsDir/$sfile";  }
2140
    elsif ( "$targetType" eq "rox" )        { $m_srcFileLocation = "$DpkgRoxDir/$sfile";  }
2141
    elsif ( "$targetType" eq "dat" )        { $m_srcFileLocation = "$DpkgDatDir/$sfile";  }
2142
    elsif ( "$targetType" eq "thx" )        { $m_srcFileLocation = "$DpkgThxDir/$sfile";  }
2143
    elsif ( "$targetType" eq "mug" )        { $m_srcFileLocation = "$DpkgMugDir/$sfile";  }
2144
    elsif ( "$targetType" eq "rpt" )        { $m_srcFileLocation = "$DpkgRptDir/$sfile";  }
2145
    elsif ( "$targetType" eq "doc" )        { $m_srcFileLocation = "$DpkgDocDir/$sfile";  }
2146
    else  {
2147
        LogError("installDpkgArchiveFile() passed unknown target type [$targetType].");
2148
    }
2149
 
2150
 
2151
    # we will check to see if the file exists.
2152
    #
2153
    if ( -f "$m_srcFileLocation" )
2154
    {
2155
        # now we need to copy the file. 
2156
        if(File::Copy::copy("$m_srcFileLocation", "$m_dstFileLocation"))
2157
        {
2158
            LogNorm("Copied [$targetType] item [$sfile] to [$m_dstFileLocation] ...");
2159
        }
2160
        else
2161
        {
2162
            LogError("Failed to copy [$targetType] item [$sfile]: $!"); 
2163
        }
2164
    }
2165
    else
2166
    {
2167
        LogError("Dpkg_archive [$targetType] item [$sfile] does not exist.");
2168
    }
2169
 
2170
    return 1;
2171
}
2172
 
2173
 
2174
#------------------------------------------------------------------------------
2175
sub installDpkgArchiveAcHtmlFile
2176
#
2177
# Description:
2178
#       This sub-routine is used to install a achtml file from the
2179
#       dpkg_archive into the supplied install dir. 
2180
#
2181
#       It assumes based on the build type where the file will be located.
2182
#
2183
#       If it fails to find the file it will report an error and terminates
2184
#       processing.
2185
#
2186
# Ugly trick:
2187
#       This function tags a $$targetType argument which is used in constructing
2188
#       the source directory path. ie: InterfaceDir/achtml/$targetType
2189
#
2190
#       Could provide as an option to installDpkgArchiveFile and re-use that
2191
#       function
2192
#------------------------------------------------------------------------------
2193
{
2194
    # correct number of parameters?
2195
    if ( ($#_+1) != 3 )
2196
    {
2197
        LogError("Incorrect number of params passed to " .
2198
                  "installDpkgArchiveAcHtmlFile() function. " .
2199
                  "Check deploy config.");
2200
    }
2201
    my ($targetType, $sfile, $targetTag) = @_;
2202
 
2203
    # lets check to see if the source type and file actually exist
2204
    #
2205
    my($m_sDirLoc)  = "$DpkgAcHtmlDir/$targetType";
2206
    if( ! -d "$m_sDirLoc" )
2207
    {
2208
        LogError("Failed to locate [$targetType] AcHtml dir [$m_sDirLoc].");
2209
    }
2210
 
2211
    # lets check to see if the file exists
2212
    #
2213
    my($m_sFileLoc) = "$DpkgAcHtmlDir/$targetType/$sfile";
2214
    if( ! -f "$m_sFileLoc" )
2215
    {
2216
        LogError("Failed to locate [$targetType] AcHtml file [$m_sFileLoc].");
2217
    }
2218
 
2219
    # lets check to see if the target tag exists
2220
    # if does not the process with log an error.
2221
    #
2222
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2223
 
2224
    # know everything exists so lets do the biz.
2225
    #
2226
    # now we need to copy the file.
2227
    if(File::Copy::copy("$m_sFileLoc", "$targetValue"))
2228
    {
2229
        LogNorm("Copied [$targetType] AcHtml item [$sfile] to [$targetValue] ...");
2230
    }
2231
    else
2232
    {
2233
        LogError("Failed to copy [$targetType] AcHtml item [$sfile]: $!");
2234
    }
2235
 
2236
    return 1;
2237
}
2238
 
2239
 
2240
#------------------------------------------------------------------------------
2241
sub installDpkgArchiveRptFile
2242
#
2243
# Description:
2244
#       This sub-routine is used to install a rpt file from the
2245
#       dpkg_archive into the supplied install dir. 
2246
#
2247
#       It assumes based on the build type where the file will be located.
2248
#
2249
#       If it fails to find the file it will report an error and terminates
2250
#       processing.
2251
#
2252
#------------------------------------------------------------------------------
2253
{
2254
    # correct number of parameters?
2255
    if ( ($#_+1) != 2 )
2256
    {
2257
        LogError("Incorrect number of params passed to " .
2258
                  "installDpkgArchiveRptFile() function. " .
2259
                  "Check deploy config.");
2260
    }
2261
 
2262
    my ($sfile, $targetTag) = @_;
2263
 
2264
    # lets check to see if the target tag exists
2265
    # if does not the process with log an error.
2266
    #
2267
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2268
 
2269
 
2270
    # for now lets call the generic funtion to move all items
2271
    # in the associated dpkg_archive dir.
2272
    #
2273
    installDpkgArchiveFile("rpt", $sfile, $targetTag);
2274
 
2275
    return 1;
2276
}
2277
 
2278
 
2279
#------------------------------------------------------------------------------
2280
sub installDpkgArchiveRoxFile
2281
#
2282
# Description:
2283
#       This sub-routine is used to install a rox file from the
2284
#       dpkg_archive into the supplied install dir. 
2285
#
2286
#       It assumes based on the build type where the file will be located.
2287
#
2288
#       If it fails to find the file it will report an error and terminates
2289
#       processing.
2290
#
2291
#------------------------------------------------------------------------------
2292
{
2293
    # correct number of parameters?
2294
    if ( ($#_+1) != 2 )
2295
    {
2296
        LogError("Incorrect number of params passed to " .
2297
                  "installDpkgArchiveRoxFile() function. " .
2298
                  "Check deploy config.");
2299
    }
2300
 
2301
    my ($sfile, $targetTag) = @_;
2302
 
2303
    # lets check to see if the target tag exists
2304
    # if does not the process with log an error.
2305
    #
2306
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2307
 
2308
 
2309
    # for now lets call the generic funtion to move all items
2310
    # in the associated dpkg_archive dir.
2311
    #
2312
    installDpkgArchiveFile("rox", $sfile, $targetTag);
2313
 
2314
    return 1;
2315
}
2316
 
2317
 
2318
#------------------------------------------------------------------------------
2319
sub installDpkgArchiveDatFile
2320
#
2321
# Description:
2322
#       This sub-routine is used to install a dat file from the
2323
#       dpkg_archive into the supplied install dir. 
2324
#
2325
#       It assumes based on the build type where the file will be located.
2326
#
2327
#       If it fails to find the file it will report an error and terminates
2328
#       processing.
2329
#
2330
#------------------------------------------------------------------------------
2331
{
2332
    # correct number of parameters?
2333
    if ( ($#_+1) != 2 )
2334
    {
2335
        LogError("Incorrect number of params passed to " .
2336
                  "installDpkgArchiveDatFile() function. " .
2337
                  "Check deploy config.");
2338
    }
2339
 
2340
    my ($sfile, $targetTag) = @_;
2341
 
2342
    # lets check to see if the target tag exists
2343
    # if does not the process with log an error.
2344
    #
2345
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2346
 
2347
 
2348
    # for now lets call the generic funtion to move all items
2349
    # in the associated dpkg_archive dir.
2350
    #
2351
    installDpkgArchiveFile("dat", $sfile, $targetTag);
2352
 
2353
    return 1;
2354
}
2355
 
2356
 
2357
#------------------------------------------------------------------------------
2358
sub installDpkgArchiveThxFile
2359
#
2360
# Description:
2361
#       This sub-routine is used to install a thx file from the
2362
#       dpkg_archive into the supplied install dir. 
2363
#
2364
#       It assumes based on the build type where the file will be located.
2365
#
2366
#       If it fails to find the file it will report an error and terminates
2367
#       processing.
2368
#
2369
#------------------------------------------------------------------------------
2370
{
2371
    # correct number of parameters?
2372
    if ( ($#_+1) != 2 )
2373
    {
2374
        LogError("Incorrect number of params passed to " .
2375
                  "installDpkgArchiveThxFile() function. " .
2376
                  "Check deploy config.");
2377
    }
2378
 
2379
    my ($sfile, $targetTag) = @_;
2380
 
2381
    # lets check to see if the target tag exists
2382
    # if does not the process with log an error.
2383
    #
2384
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2385
 
2386
 
2387
    # for now lets call the generic funtion to move all items
2388
    # in the associated dpkg_archive dir.
2389
    #
2390
    installDpkgArchiveFile("thx", $sfile, $targetTag);
2391
 
2392
    return 1;
2393
}
2394
 
2395
 
2396
#------------------------------------------------------------------------------
2397
sub installDpkgArchiveMugFile
2398
#
2399
# Description:
2400
#       This sub-routine is used to install a mug file from the
2401
#       dpkg_archive into the supplied install dir. 
2402
#
2403
#       It assumes based on the build type where the file will be located.
2404
#
2405
#       If it fails to find the file it will report an error and terminates
2406
#       processing.
2407
#
2408
#------------------------------------------------------------------------------
2409
{
2410
    # correct number of parameters?
2411
    if ( ($#_+1) != 2 )
2412
    {
2413
        LogError("Incorrect number of params passed to " .
2414
                  "installDpkgArchiveMugFile() function. " .
2415
                  "Check deploy config.");
2416
    }
2417
 
2418
    my ($sfile, $targetTag) = @_;
2419
 
2420
    # lets check to see if the target tag exists
2421
    # if does not the process with log an error.
2422
    #
2423
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2424
 
2425
 
2426
    # for now lets call the generic funtion to move all items
2427
    # in the associated dpkg_archive dir.
2428
    #
2429
    installDpkgArchiveFile("mug", $sfile, $targetTag);
2430
 
2431
    return 1;
2432
}
2433
 
2434
 
2435
#------------------------------------------------------------------------------
2436
sub installDpkgArchiveInfoFilesFile
2437
#
2438
# Description:
2439
#       This sub-routine is used to install a infofiles file from the
2440
#       dpkg_archive into the supplied install dir. 
2441
#
2442
#       It assumes based on the build type where the file will be located.
2443
#
2444
#       If it fails to find the file it will report an error and terminates
2445
#       processing.
2446
#
2447
#------------------------------------------------------------------------------
2448
{
2449
    # correct number of parameters?
2450
    if ( ($#_+1) != 2 )
2451
    {
2452
        LogError("Incorrect number of params passed to " .
2453
                  "installDpkgArchiveInfoFilesFile() function. " .
2454
                  "Check deploy config.");
2455
    }
2456
 
2457
    my ($sfile, $targetTag) = @_;
2458
 
2459
    # lets check to see if the target tag exists
2460
    # if does not the process with log an error.
2461
    #
2462
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2463
 
2464
 
2465
    # for now lets call the generic funtion to move all items
2466
    # in the associated dpkg_archive dir.
2467
    #
2468
    installDpkgArchiveFile("infofiles", $sfile, $targetTag);
2469
 
2470
    return 1;
2471
}
2472
 
2473
 
2474
#------------------------------------------------------------------------------
2475
sub installDpkgArchiveSqlFile
2476
#
2477
# Description:
2478
#       This sub-routine is used to install a sql file from the
2479
#       dpkg_archive into the supplied install dir. 
2480
#
2481
#       It assumes based on the build type where the file will be located.
2482
#
2483
#       If it fails to find the file it will report an error and terminates
2484
#       processing.
2485
#
2486
#------------------------------------------------------------------------------
2487
{
2488
    # correct number of parameters?
2489
    if ( ($#_+1) != 2 )
2490
    {
2491
        LogError("Incorrect number of params passed to " .
2492
                  "installDpkgArchiveSqlFile() function. " .
2493
                  "Check deploy config.");
2494
    }
2495
 
2496
    my ($sfile, $targetTag) = @_;
2497
 
2498
    # lets check to see if the target tag exists
2499
    # if does not the process with log an error.
2500
    #
2501
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2502
 
2503
 
2504
    # for now lets call the generic funtion to move all items
2505
    # in the associated dpkg_archive dir.
2506
    #
2507
    installDpkgArchiveFile("sql", $sfile, $targetTag);
2508
 
2509
    return 1;
2510
}
2511
 
2512
 
2513
#------------------------------------------------------------------------------
2514
sub installDpkgArchiveWarFile
2515
#
2516
# Description:
2517
#       This sub-routine is used to install a war file from the
2518
#       dpkg_archive into the supplied install dir. 
2519
#
2520
#       It assumes based on the build type where the file will be located.
2521
#
2522
#       If it fails to find the file it will report an error and terminates
2523
#       processing.
2524
#
2525
#------------------------------------------------------------------------------
2526
{
2527
    # correct number of parameters?
2528
    if ( ($#_+1) != 2 )
2529
    {
2530
        LogError("Incorrect number of params passed to " .
2531
                  "installDpkgArchiveWarFile() function. " .
2532
                  "Check deploy config.");
2533
    }
2534
 
2535
    my ($sfile, $targetTag) = @_;
2536
 
2537
    # lets check to see if the target tag exists
2538
    # if does not the process with log an error.
2539
    #
2540
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2541
 
2542
 
2543
    # for now lets call the generic funtion to move all items
2544
    # in the associated dpkg_archive dir.
2545
    #
2546
    installDpkgArchiveFile("war", $sfile, $targetTag);
2547
 
2548
    return 1;
2549
}
2550
 
2551
 
2552
 
2553
#------------------------------------------------------------------------------
2554
sub installDpkgArchiveJarFile
2555
#
2556
# Description:
2557
#       This sub-routine is used to install a jar file from the
2558
#       dpkg_archive into the supplied install dir. 
2559
#
2560
#       It assumes based on the build type where the file will be located.
2561
#
2562
#       If it fails to find the file it will report an error and terminates
2563
#       processing.
2564
#
2565
#------------------------------------------------------------------------------
2566
{
2567
    # correct number of parameters?
2568
    if ( ($#_+1) != 2 )
2569
    {
2570
        LogError("Incorrect number of params passed to " .
2571
                  "installDpkgArchiveJarFile() function. " .
2572
                  "Check deploy config.");
2573
    }
2574
 
2575
    my ($sfile, $targetTag) = @_;
2576
 
2577
    # lets check to see if the target tag exists
2578
    # if does not the process with log an error.
2579
    #
2580
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2581
 
2582
 
2583
    # for now lets call the generic funtion to move all items
2584
    # in the associated dpkg_archive dir.
2585
    #
2586
    installDpkgArchiveFile("jar", $sfile, $targetTag);
2587
 
2588
    return 1;
2589
}
2590
 
2591
 
2592
 
2593
#------------------------------------------------------------------------------
2594
sub installDpkgArchiveSarFile
2595
#
2596
# Description:
2597
#       This sub-routine is used to install a sar file from the
2598
#       dpkg_archive into the supplied install dir. 
2599
#
2600
#       It assumes based on the build type where the file will be located.
2601
#
2602
#       If it fails to find the file it will report an error and terminates
2603
#       processing.
2604
#
2605
#------------------------------------------------------------------------------
2606
{
2607
    # correct number of parameters?
2608
    if ( ($#_+1) != 2 )
2609
    {
2610
        LogError("Incorrect number of params passed to " .
2611
                  "installDpkgArchiveSarFile() function. " .
2612
                  "Check deploy config.");
2613
    }
2614
 
2615
    my ($sfile, $targetTag) = @_;
2616
 
2617
    # lets check to see if the target tag exists
2618
    # if does not the process with log an error.
2619
    #
2620
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2621
 
2622
 
2623
    # for now lets call the generic funtion to move all items
2624
    # in the associated dpkg_archive dir.
2625
    #
2626
    installDpkgArchiveFile("sar", $sfile, $targetTag);
2627
 
2628
    return 1;
2629
}
2630
 
2631
 
2632
 
2633
 
2634
 
2635
#------------------------------------------------------------------------------
2636
sub installDpkgArchiveEtcFile
2637
#
2638
# Description:
2639
#       This sub-routine is used to install an etc file from the
2640
#       dpkg_archive into the supplied install dir. 
2641
#
2642
#       It assumes based on the build type where the file will be located.
2643
#
2644
#       If it fails to find the file it will report an error and terminates
2645
#       processing.
2646
#
2647
#------------------------------------------------------------------------------
2648
{
2649
    # correct number of parameters?
2650
    if ( ($#_+1) != 2 )
2651
    {
2652
        LogError("Incorrect number of params passed to " .
2653
                  "installDpkgArchiveEtcFile() function. " .
2654
                  "Check deploy config.");
2655
    }
2656
 
2657
    my ($sfile, $targetTag) = @_;
2658
 
2659
    # lets check to see if the target tag exists
2660
    # if does not the process with log an error.
2661
    #
2662
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2663
 
2664
 
2665
    # for now lets call the generic funtion to move all items
2666
    # in the associated dpkg_archive dir.
2667
    #
2668
    installDpkgArchiveFile("etc", $sfile, $targetTag);
2669
 
2670
    return 1;
2671
}
2672
 
2673
 
2674
#------------------------------------------------------------------------------
2675
sub installDpkgArchiveScriptsFile
2676
#
2677
# Description:
2678
#       This sub-routine is used to install a scripts file from the
2679
#       dpkg_archive into the supplied install dir. 
2680
#
2681
#       It assumes based on the build type where the file will be located.
2682
#
2683
#       If it fails to find the file it will report an error and terminates
2684
#       processing.
2685
#
2686
#------------------------------------------------------------------------------
2687
{
2688
    # correct number of parameters?
2689
    if ( ($#_+1) != 2 )
2690
    {
2691
        LogError("Incorrect number of params passed to " .
2692
                  "installDpkgArchiveScriptsFile() function. " .
2693
                  "Check deploy config.");
2694
    }
2695
 
2696
   my ($sfile, $targetTag) = @_;
2697
 
2698
    # lets check to see if the target tag exists
2699
    # if does not the process with log an error.
2700
    #
2701
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2702
 
2703
 
2704
    # for now lets call the generic funtion to move all items
2705
    # in the associated dpkg_archive dir.
2706
    #
2707
    installDpkgArchiveFile("scripts", $sfile, $targetTag);
2708
 
2709
    return 1;
2710
}
2711
 
2712
 
2713
 
2714
#------------------------------------------------------------------------------
2715
sub installDpkgArchiveIncludeFile
2716
#
2717
# Description:
2718
#       This sub-routine is used to install a include file from the
2719
#       dpkg_archive into the supplied install dir. 
2720
#
2721
#       It assumes based on the build type where the file will be located.
2722
#
2723
#       If it fails to find the file it will report an error and terminates
2724
#       processing.
2725
#
2726
#------------------------------------------------------------------------------
2727
{
2728
    # correct number of parameters?
2729
    if ( ($#_+1) != 2 )
2730
    {
2731
        LogError("Incorrect number of params passed to " .
2732
                  "installDpkgArchiveIncludeFile() function. " .
2733
                  "Check deploy config.");
2734
    }
2735
 
2736
   my ($sfile, $targetTag) = @_;
2737
 
2738
    # lets check to see if the target tag exists
2739
    # if does not the process with log an error.
2740
    #
2741
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2742
 
2743
 
2744
    # for now lets call the generic funtion to move all items
2745
    # in the associated dpkg_archive dir.
2746
    #
2747
    installDpkgArchiveFile("include", $sfile, $targetTag);
2748
 
2749
    return 1;
2750
}
2751
 
2752
 
2753
 
2754
#------------------------------------------------------------------------------
2755
sub installDpkgArchiveDocFile
2756
#
2757
# Description:
2758
#       This sub-routine is used to install a include file from the
2759
#       dpkg_archive into the supplied install dir. 
2760
#
2761
#       It assumes based on the build type where the file will be located.
2762
#
2763
#       If it fails to find the file it will report an error and terminates
2764
#       processing.
2765
#
2766
#------------------------------------------------------------------------------
2767
{
2768
    # correct number of parameters?
2769
    if ( ($#_+1) != 2 )
2770
    {
2771
        LogError("Incorrect number of params passed to " .
2772
                  "installDpkgArchiveDocFile() function. " .
2773
                  "Check deploy config.");
2774
    }
2775
 
2776
   my ($sfile, $targetTag) = @_;
2777
 
2778
    # lets check to see if the target tag exists
2779
    # if does not the process with log an error.
2780
    #
2781
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2782
 
2783
 
2784
    # for now lets call the generic funtion to move all items
2785
    # in the associated dpkg_archive dir.
2786
    #
2787
    installDpkgArchiveFile("doc", $sfile, $targetTag);
2788
 
2789
    return 1;
2790
}
2791
 
2792
 
2793
#------------------------------------------------------------------------------
2794
sub installDpkgArchiveBinFile
2795
#
2796
# Description:
2797
#       This sub-routine is used to install a binary file from the
2798
#       dpkg_archive into the supplied install dir. 
2799
#
2800
#       It assumes based on the build type where the file will be located.
2801
#
2802
#       If it fails to find the file it will report an error and terminates
2803
#       processing.
2804
#
2805
# Inputs          :     $sfile              - Name of source file
2806
#                                             or a reference to a list of files
2807
#                       $targetTag          - Symbolic name of target
2808
#                       Options             - Optional options
2809
#
2810
# Options:
2811
#                   --SelectFrom=xxxx       - Limits foile source selection
2812
#                                             By default all LIB sources are searched.
2813
#                                             The selector should be a Platform, Product
2814
#                                             ,Target or MachineType
2815
#
2816
#
2817
# Returns         :     Nothing of use
2818
#                       Will not return if the file is not found
2819
#
2820
#------------------------------------------------------------------------------
2821
{
2822
    my @args;
2823
    my $select = '_ALL_';
2824
 
2825
    #
2826
    #   Process parameters and extract options
2827
    #
2828
    foreach  ( @_ )
2829
    {
2830
        if ( m/^--SelectFrom=(.*)/ ) {
2831
            $select = $1;
2832
            LogError("installDpkgArchiveBinFile: Selector not known: $_")
2833
                unless ( defined $DpkgLibDirList{$select} );
2834
 
2835
        } elsif ( m/^--/ ) {
2836
            LogError('-x', "installDpkgArchiveBinFile: Unknown option ignored: $_")
2837
 
2838
        } else {
2839
            push @args, $_;
2840
        }
2841
    }
2842
 
2843
 
2844
    # correct number of parameters?
2845
    my ($fref, $targetTag) = @_;
2846
    if ( $#args != 1 )
2847
    {
2848
        LogError("Incorrect number of params passed to " .
2849
                  "installDpkgArchiveBinFile() function. " .
2850
                  "Check deploy config.");
2851
    }
2852
 
2853
    # lets check to see if the target tag exists
2854
    # if does not the process with log an error.
2855
    #
2856
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
2857
 
2858
    #
2859
    #   Process the file name
2860
    #   This will either be a scalar name, or a reference to an array of names
2861
    #   If the user has provided an array of names then expand the list
2862
    #
2863
    #   Convert $fref into an reference to a list
2864
    #
2865
    my @one_file;
2866
    unless ( ref ( $fref ) eq 'ARRAY' )
2867
    {
2868
        push @one_file, $fref;
2869
        $fref = \@one_file;
2870
    }
2871
 
2872
    foreach my $sfile ( @$fref )
2873
    {
2874
 
2875
        if ( "$MachType" eq "win32" )
2876
        {
2877
            # if the item does not have an .exe extention
2878
            # we shall add one for convience.
2879
            #
2880
            if ( $sfile !~ m/\.exe$/  &&
2881
                 $sfile !~ m/\.dll$/ )
2882
            {
2883
                $sfile = $sfile . ".exe";
2884
            }
2885
        }
2886
 
2887
 
2888
        my ($i);
2889
        my ($foundFileFlag) = "false";
2890
        my ($m_DpkgBinDir)  = "";
2891
        my ($m_srcFileLocation) = "";
2892
        my ($m_dstFileLocation) = "";
2893
        foreach $i (@{$DpkgBinDirList{$select}})
2894
        {
2895
            $m_DpkgBinDir = "$DpkgBinDir" . "/$i";
2896
            if ( ! -d "$m_DpkgBinDir" )
2897
            {
2898
                LogDebug("Directory [$m_DpkgBinDir] not found.");
2899
                next;
2900
            }
2901
 
2902
            # lets define the absolute location of the file
2903
            $m_srcFileLocation = "$m_DpkgBinDir/$sfile";
2904
            $m_dstFileLocation = "$targetValue/$sfile";
2905
 
2906
            # we will check to see if the file exists.
2907
            #
2908
            if ( -f "$m_srcFileLocation" )
2909
            {
2910
                # now we need to copy the file.
2911
                if(File::Copy::copy("$m_srcFileLocation", "$m_dstFileLocation"))
2912
                {
2913
                    LogNorm("Copied Bin [$sfile] to [$m_dstFileLocation] ...");
2914
                    $foundFileFlag = "true";
2915
 
2916
                    # no need to go further, we have found the file.
2917
                    #
2918
                    last;
2919
                }
2920
                else
2921
                {
2922
                    LogError("Failed to copy binary [$sfile]: $!");
2923
                }
2924
            }
2925
            # else we have not found the file yet!
2926
        }
2927
 
2928
        # if we do not find the file at all we need to inform
2929
        # the user.
2930
        #
2931
        if ( "$foundFileFlag" eq "false" )
2932
        {
2933
            LogError("Dpkg_archive bin file [$sfile] does not exist or is not in correct directory structure.");
2934
        }
2935
    }
2936
 
2937
    return 1;
2938
}
2939
 
2940
 
2941
#------------------------------------------------------------------------------
2942
sub installDpkgArchiveLibFile
2943
#
2944
# Description:
2945
#       This sub-routine is used to install a binary file from the
2946
#       dpkg_archive into the supplied install location dir.
2947
#
2948
#       It assumes based on the build type where the file will be located.
2949
#
2950
#       If it fails to find the file it will report an error and terminates
2951
#       processing.
2952
#
2953
#       Added optional 3rd parameter & if set to NoLinks then no generic named
2954
#       libs will be created
2955
#
2956
# Inputs          :     $sfile              - Name of source file
2957
#                                             or a reference to a list of files
2958
#                       $targetTag          - Symbolic name of target
2959
#                       $links              - Optional. 'nolinks' will supress generic named libs
2960
#                       Options             - Optional options
2961
#
2962
# Options:
2963
#                   --NoLink                - same as 3rd arg == noloiks
2964
#                   --Link                  - Default
2965
#                   --SelectFrom=xxxx       - Limits foile source selection
2966
#                                             By default all LIB sources are searched.
2967
#                                             The selector should be a Platform, Product
2968
#                                             ,Target or MachineType
2969
#
2970
#
2971
# Returns         :     Nothing of use
2972
#                       Will not return if the file is not found
2973
#
2974
#------------------------------------------------------------------------------
2975
{
2976
    my @args;
2977
    my $links = 1;
2978
    my $select = '_ALL_';
2979
 
2980
    #
2981
    #   Process parameters and extract options
2982
    #
2983
    foreach  ( @_ )
2984
    {
2985
        if ( m/^--NoLink/ ) {
2986
            $links = 0;
2987
 
2988
        } elsif ( m/^--Link/ ) {
2989
            $links = 1;
2990
 
2991
        } elsif ( m/^--SelectFrom=(.*)/ ) {
2992
            $select = $1;
2993
            LogError("installDpkgArchiveLibFile: Selector not known: $_")
2994
                unless ( defined $DpkgLibDirList{$select} );
2995
 
2996
        } elsif ( m/^--/ ) {
2997
            LogError('-x', "installDpkgArchiveLibFile: Unknown option ignored: $_")
2998
 
2999
        } else {
3000
            push @args, $_;
3001
        }
3002
    }
3003
 
3004
    #
3005
    #   Handle the optional 3rd argument
3006
    #
3007
    if ( $args[2] )
3008
    {
3009
        $links = $args[2] !~ m/nolink/i;
3010
        delete $args[2];
3011
    }
3012
 
3013
    # correct number of parameters?
3014
    my ($fref, $targetTag) = @_;
3015
    if ( $#args != 1 )
3016
    {
3017
        LogError("Incorrect number of params passed to " .
3018
                  "installDpkgArchiveLibFile() function. " .
3019
                  "Check deploy config.");
3020
    }
3021
 
3022
    #
3023
    # Check to see if the target tag exists
3024
    # If does not the process with log an error.
3025
    #
3026
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
3027
 
3028
    #
3029
    #   Process the file name
3030
    #   This will either be a scalar name, or a reference to an array of names
3031
    #   If the user has provided an array of names then expand the list
3032
    #
3033
    #   Convert $fref into an reference to a list
3034
    #
3035
    my @one_file;
3036
    unless ( ref ( $fref ) eq 'ARRAY' )
3037
    {
3038
        push @one_file, $fref;
3039
        $fref = \@one_file;
3040
    }
3041
 
3042
    foreach my $sfile ( @$fref )
3043
    {
3044
 
3045
 
3046
        # we exclude .dll files if this is a sparc build
3047
        #
3048
        if ( "$MachType" eq "sparc"  &&
3049
             $sfile =~ m/\.dll/
3050
           )
3051
        {
3052
            LogInfo("Excluding item [$sfile] from build, as we do not deliver dlls for this machine type [$MachType].");
3053
            return 1;
3054
        }
3055
 
3056
        # we exclude .so files if this is a win32 build
3057
        #
3058
        if ( "$MachType" eq "win32"  &&
3059
             $sfile =~ m/\.so/
3060
           )
3061
        {
3062
            LogInfo("Excluding item [$sfile] from build, as we do not deliver sosss for this machine type [$MachType].");
3063
            return 1;
3064
        }
3065
 
3066
        my ($libName) = $sfile;
3067
        if ( "$MachType" eq "sparc" )
3068
        {
3069
            $libName =~ s/\.so.*$//;
3070
        }
3071
 
3072
        # lets define the absolute location of the file
3073
        my ($m_srcFileLocation) = "";
3074
        my ($m_dstFileLocation) = "";
3075
        my ($m_DpkgLibDir) = "";
3076
 
3077
        my ($i);
3078
        my ($j);
3079
        my ($count);
3080
        my ($foundFileFlag) = "false";
3081
        my ($ExcludedFlag) = "false";
3082
 
3083
        #
3084
        #   Search all the 'lib' locations, or a specified subset
3085
        #
3086
        foreach $i (@{$DpkgLibDirList{$select}})
3087
        {
3088
 
3089
            $m_DpkgLibDir = "$DpkgLibDir" . "/$i";
3090
            if ( ! -d "$m_DpkgLibDir" )
3091
            {
3092
                LogDebug("Directory [$m_DpkgLibDir] not found.");
3093
                next;
3094
            }
3095
 
3096
            $m_srcFileLocation = "$m_DpkgLibDir/$sfile";
3097
            $m_dstFileLocation = "$targetValue/$sfile";
3098
 
3099
 
3100
            # we only want debug items in a debug build
3101
            #
3102
            if(excludeItemFromBuild($sfile))
3103
            {
3104
                LogInfo("Excluding item [$sfile] from build as not compatible with build type [$BuildType].");
3105
                $ExcludedFlag = "true";
3106
            }
3107
            else
3108
            {
3109
                # we need to ensure that only a single version/entry of the lib exists in the lib list
3110
                #
3111
                $count = 1;
3112
                foreach $j (@LibCheckList)
3113
                {
3114
                    if ( $j =~ m/^$libName$/ )
3115
                    {
3116
                        $count++;
3117
                    }
3118
 
3119
                    if ( $count > 1 )
3120
                    {
3121
                        LogError("Detected multiple references of lib [$libName] in lib list, check item [$sfile].");
3122
                    }
3123
                }
3124
 
3125
                # we will check to see if the file exists.
3126
                #
3127
                if ( -f "$m_srcFileLocation" )
3128
                {
3129
                    # now we need to copy the file.
3130
 
3131
                    # we also want to create a generically named copy
3132
                    # of the library
3133
                    #
3134
                    my ($gName)    = $sfile;
3135
                    my ($nVerName) = $sfile;
3136
                    $gName = removeBuildTypeFromItemName($sfile);
3137
                    $gName = removeVersionNumberFromItemName($gName);
3138
                    $nVerName = removeVersionNumberFromItemName($sfile);
3139
 
3140
                    if(File::Copy::copy("$m_srcFileLocation", "$m_dstFileLocation"))
3141
                    {
3142
                        LogNorm("Copied Lib [$sfile] to [$m_dstFileLocation] ...");
3143
                        $foundFileFlag = "true";
3144
 
3145
                        if ( $links && ( "x$PkgPatchID" eq "x" || "$MachType" eq "win32") )
3146
                        {
3147
                            # normal build or if we are building win32 we want generic names
3148
 
3149
                            # we want to create a copy of our target using
3150
                            # the generic name
3151
                            if ( $sfile ne $nVerName )
3152
                            {
3153
                                createGenericCopy("$sfile", "$m_srcFileLocation", "$nVerName", "$targetValue");
3154
                            }
3155
                            if ( $sfile ne $gName )
3156
                            {
3157
                                createGenericCopy("$sfile", "$m_srcFileLocation", "$gName",    "$targetValue");
3158
                            }
3159
                        }
3160
 
3161
 
3162
                        # lets add this lib to our check list for next time.
3163
                        #
3164
                        push @LibCheckList, $libName;
3165
 
3166
                        # no need to go further, implies we found the file!
3167
                        #
3168
                        last;
3169
                    }
3170
                    else
3171
                    {
3172
                        # here found the file but we had some trouble
3173
                        #
3174
                        LogError("Failed to copy lib [$m_srcFileLocation]: $!");
3175
                    }
3176
 
3177
                }
3178
                # else have not found the file yet!
3179
            }
3180
        }
3181
 
3182
        # if we do not find the file at all we need to inform
3183
        # the user.
3184
        #
3185
        if ( "$foundFileFlag" eq "false" && $ExcludedFlag eq "false" )
3186
        {
3187
            LogError("Dpkg_archive lib file [$sfile] does not exist or is not in correct directory structure.");
3188
        }
3189
    }
3190
 
3191
    return 1;
3192
}
3193
 
3194
 
3195
#------------------------------------------------------------------------------
3196
sub installPkgAddConfigFile
3197
#
3198
# Description:
3199
#       This sub-routine is used to install a package config file from a supplied
3200
#       source location to a predefined destination location that is based on
3201
#       the build type.
3202
#
3203
#       The sub routine also updates to the prototype file with an appropriate
3204
#       entry for the associated file.
3205
#
3206
#       If it has any problems it will log an error and stop processing.
3207
#
3208
#------------------------------------------------------------------------------
3209
{
3210
    # correct number of parameters?
3211
    if ( ($#_+1) != 3 )
3212
    {
3213
        LogError("Incorrect number of params passed to " .
3214
                  "installPkgAddConfigFile() function. " .
3215
                  "Check deploy config.");
3216
    }
3217
 
3218
    # lets just check to see if we can execute this function on
3219
    # this machine.
3220
    #
3221
    if ( "$MachType" ne "sparc" )
3222
    {
3223
        LogInfo("installPkgAddConfigFile() not supported on this machine type.");
3224
        return 1;
3225
    }
3226
 
3227
 
3228
    my ($sDirTag, $sfile, $tfile) = @_;
3229
 
3230
 
3231
    # we must have a filename.
3232
    #
3233
    if ( "x$sfile" eq "x" )
3234
    {
3235
        LogError("Source filename not supplied. Check deploy config.");
3236
    }
3237
 
3238
 
3239
    # lets check to see if the local src dir tag exists
3240
    # if does not the process with log an error.
3241
    #
3242
    my ($sDirValue) = getLocalDirValue("$sDirTag", "A");
3243
 
3244
 
3245
    # lets check to see if the source file exists
3246
    #
3247
    if ( ! -f "$sDirValue/$sfile" )
3248
    {
3249
        LogError("Failed to find local source file [$sDirValue/$sfile].");
3250
    }
3251
 
3252
    if ( ! -f "$ProtoTypeFile" )
3253
    {
3254
        LogError("Prototype file [$ProtoTypeFile] does not exist. " .
3255
                 "Ensure createPrototypeFile() function has been called before executing installPkgAddConfigFile() function. " .
3256
                 "Check deploy config.");
3257
    }
3258
 
3259
 
3260
    # lets determine which prototype file we are going to
3261
    # use
3262
    my ($dFileName);
3263
    $dFileName     = "$PkgBaseDir/$sfile";
3264
 
3265
    # lets copy the file
3266
    #
3267
    if(File::Copy::copy("$sDirValue/$sfile", "$dFileName"))
3268
    {
3269
        LogNorm("Copied [$sfile] to [$dFileName] ...");
3270
    }
3271
    else
3272
    {
3273
        LogError("Failed to copy local source file [$sDirValue/$sfile]: $!"); 
3274
    }
3275
 
3276
 
3277
    # now we need to update the prototype file
3278
    #
3279
    local *FILE;
3280
    open ( FILE, ">> $ProtoTypeFile") or
3281
        LogError("Failed to open file [$ProtoTypeFile].");
3282
    printf FILE ("i $tfile=$sfile\n");
3283
    close (FILE);
3284
 
3285
 
3286
    return 1;
3287
}
3288
 
3289
 
3290
#------------------------------------------------------------------------------
3291
sub installPkgAddSystemClassFile
3292
#
3293
# Description:
3294
#       This sub-routine is used to install a package system class file from a supplied
3295
#       source location to a predefined destination location the class type is also 
3296
#       supplied and must be sed, awk, build or preserve
3297
#
3298
#       The sub routine also updates to the prototype file with an appropriate
3299
#       entry for the associated file.
3300
#
3301
#       If it has any problems it will log an error and stop processing.
3302
#
3303
#------------------------------------------------------------------------------
3304
{
3305
    # correct number of parameters?
3306
    if ( ($#_+1) != 4 )
3307
    {
3308
        LogError("Incorrect number of params passed to " .
3309
                  "installPkgAddConfigFile() function. " .
3310
                  "Check deploy config.");
3311
    }
3312
 
3313
    # lets just check to see if we can execute this function on
3314
    # this machine.
3315
    #
3316
    if ( "$MachType" ne "sparc" )
3317
    {
3318
        LogInfo("installPkgAddConfigFile() not supported on this machine type.");
3319
        return 1;
3320
    }
3321
 
3322
 
3323
    my ($sDirTag, $sfile, $tfile, $class) = @_;
3324
 
3325
    if ( $class ne "sed" && $class ne "build" && $class ne "awk" && $class ne "preserve" )
3326
    {
3327
        LogError("Class Name for System Class File can only be one of sed, build, awk or preserve");
3328
    }
3329
 
3330
    # we must have a filename.
3331
    #
3332
    if ( "x$sfile" eq "x" )
3333
    {
3334
        LogError("Source filename not supplied. Check deploy config.");
3335
    }
3336
 
3337
 
3338
    # lets check to see if the local src dir tag exists
3339
    # if does not the process with log an error.
3340
    #
3341
    my ($sDirValue) = getLocalDirValue("$sDirTag", "A");
3342
 
3343
 
3344
    # lets check to see if the source file exists
3345
    #
3346
    if ( ! -f "$sDirValue/$sfile" )
3347
    {
3348
        LogError("Failed to find local source file [$sDirValue/$sfile].");
3349
    }
3350
 
3351
    if ( ! -f "$ProtoTypeFile" )
3352
    {
3353
        LogError("Prototype file [$ProtoTypeFile] does not exist. " .
3354
                 "Ensure createPrototypeFile() function has been called before executing installPkgAddConfigFile() function. " .
3355
                 "Check deploy config.");
3356
    }
3357
 
3358
 
3359
    # lets determine which prototype file we are going to
3360
    # use
3361
    my ($dFileName);
3362
    $dFileName     = "$PkgBaseDir/$sfile";
3363
 
3364
    # lets copy the file
3365
    #
3366
    if(File::Copy::copy("$sDirValue/$sfile", "$dFileName"))
3367
    {
3368
        LogNorm("Copied [$sfile] to [$dFileName] ...");
3369
    }
3370
    else
3371
    {
3372
        LogError("Failed to copy local source file [$sDirValue/$sfile]: $!"); 
3373
    }
3374
 
3375
 
3376
    # now we need to update the prototype file
3377
    #
3378
    local *FILE;
3379
    open ( FILE, ">> $ProtoTypeFile") or
3380
        LogError("Failed to open file [$ProtoTypeFile].");
3381
    printf FILE ("e $class $tfile=$sfile ? ? ?\n");
3382
    close (FILE);
3383
 
3384
 
3385
    return 1;
3386
}
3387
 
3388
 
3389
 
3390
#------------------------------------------------------------------------------
3391
sub updatePrototypeFileAddItem
3392
#
3393
# Description:
3394
#       This sub-routine is used to update the prototype file with an
3395
#       extra package add item. Here we pre-pend the ERGAFC_BASEDIR to the
3396
#       destination item.
3397
#
3398
#       The only item type we support at this stage are "s" and "f" types.
3399
#
3400
#       You also need to supply the source tag, destination tag, user id, group id 
3401
#       and permissions associated to this item.
3402
#
3403
#       If it has any problems it will log an error and stop processing.
3404
#
3405
#------------------------------------------------------------------------------
3406
{
3407
    # correct number of parameters?
3408
    if ( ($#_+1) != 6 )
3409
    {
3410
        LogError("Incorrect number of params passed to " .
3411
                  "updatePrototypeFileAddItem() function. " .
3412
                  "Check deploy config.");
3413
    }
3414
 
3415
 
3416
    # lets just check to see if we can execute this function on
3417
    # this machine.
3418
    #
3419
    if ( "$MachType" ne "sparc" )
3420
    {
3421
        LogInfo("updatePrototypeFileAddItem() not supported on this machine type.");
3422
        return 1;
3423
    }
3424
 
3425
    my ($sTag, $dTag, $perms, $uid, $gid, $type) = @_;
3426
 
3427
    # lets determine which prototype file we are going to
3428
    # use
3429
    my ($protoTypeFile);
3430
    $protoTypeFile = "$ProtoTypeFile";
3431
 
3432
 
3433
    # lets check the valid types
3434
    $type = uc($type);
3435
    if ( "$type" !~ /S/ )
3436
    {
3437
        LogError("Invalid type field supplied in updatePrototypeFileAddItem(). Check deploy config.");
3438
    }
3439
 
3440
    # now we need to update the prototype file
3441
    #
3442
    local *FILE;
3443
    open ( FILE, ">> $protoTypeFile") or
3444
        LogError("Failed to open file [$protoTypeFile].");
3445
 
3446
    my($m_Str)=""; 
3447
    if ( "$type" eq "S" )
3448
    {
3449
        $m_Str = "s none $sTag=$ERGAFC_BASEDIR/$dTag $perms $uid $gid";
3450
        LogNorm("Updated prototype file with entry [$m_Str]");
3451
    }
3452
    else
3453
    {
3454
        $m_Str = "f none $sTag=$ERGAFC_BASEDIR/$dTag $perms $uid $gid";
3455
        LogNorm("Updated prototype file with entry [$m_Str]");
3456
    }
3457
    printf FILE ("$m_Str\n");
3458
    close (FILE);
3459
 
3460
    return 1;
3461
}
3462
 
3463
 
3464
#------------------------------------------------------------------------------
3465
sub updatePrototypeFileAddItem2
3466
#
3467
# Description:
3468
#       This sub-routine is used to update the prototype file with an
3469
#       extra package add item. Here we do not pre-append the 
3470
#       ERGAFC_BASEDIR to the destination item.
3471
#
3472
#       The only item type we support at this stage are "s", "i" and "e" types.
3473
#
3474
#       You also need to supply the source tag, destination tag, user id, group id 
3475
#       and permissions associated to this item.
3476
#
3477
#       If it has any problems it will log an error and stop processing.
3478
#
3479
#------------------------------------------------------------------------------
3480
{
3481
    # correct number of parameters?
3482
    if ( ($#_+1) != 6 && ($#_+1) != 7 )
3483
    {
3484
        LogError("Incorrect number of params passed to " .
3485
                  "updatePrototypeFileAddItem2() function. " .
3486
                  "Check deploy config.");
3487
    }
3488
 
3489
 
3490
    # lets just check to see if we can execute this function on
3491
    # this machine.
3492
    #
3493
    if ( "$MachType" ne "sparc" )
3494
    {
3495
        LogInfo("updatePrototypeFileAddItem2() not supported on this machine type.");
3496
        return 1;
3497
    }
3498
 
3499
    # class must be last as it is optional
3500
    my ($sTag, $dTag, $perms, $uid, $gid, $type, $class) = @_;
3501
 
3502
    $class = "none" if ( ($#_+1) == 6 );
3503
 
3504
    # lets determine which prototype file we are going to
3505
    # use
3506
    my ($protoTypeFile);
3507
    $protoTypeFile = "$ProtoTypeFile";
3508
 
3509
    # lets check the valid types
3510
    $type = uc($type);
3511
    if ( "$type" !~ /S/ && "$type" !~ /I/ && "$type" !~ /E/ )
3512
    {
3513
        LogError("Invalid type field supplied in updatePrototypeFileAddItem2(). Check deploy config.");
3514
    }
3515
 
3516
    # now we need to update the prototype file
3517
    #
3518
    local *FILE;
3519
    open ( FILE, ">> $protoTypeFile") or
3520
        LogError("Failed to open file [$protoTypeFile].");
3521
 
3522
    my($m_Str)="";
3523
    if ( "$type" eq "S" )
3524
    {
3525
        $m_Str = "s $class $sTag=$dTag $perms $uid $gid";
3526
        LogNorm("Updated prototype file with entry [$m_Str]");
3527
    }
3528
    elsif ( "$type" eq "E" )
3529
    {
3530
        $m_Str = "e $class $sTag=$dTag $perms $uid $gid";
3531
        LogNorm("Updated prototype file with entry [$m_Str]");
3532
    }
3533
    else
3534
    {
3535
        $m_Str = "i $sTag=$dTag";
3536
        LogNorm("Updated prototype file with entry [$m_Str]");
3537
    }
3538
    printf FILE ("$m_Str\n");
3539
    close (FILE);
3540
 
3541
    return 1;
3542
}
3543
 
3544
 
3545
#------------------------------------------------------------------------------
3546
sub addPath2Prototype
3547
#
3548
# Description:
3549
#       This sub-routine is used to add directory entries to the prototype file
3550
#   to make sure the supplied path exists in the prototype file
3551
#
3552
#------------------------------------------------------------------------------
3553
{
3554
    # lets just check to see if we can execute this function on
3555
    # this machine.
3556
    #
3557
    if ( "$MachType" ne "sparc" )
3558
    {
3559
        LogInfo("addPath2Prototype() not supported on this machine type.");
3560
        return 1;
3561
    }
3562
 
3563
    # class must be last as it is optional
3564
    my ($path, $perms, $uid, $gid, $class) = @_;
3565
 
3566
    # set defaults if not supplied
3567
    $perms  = "?"       if ( ($#_+1) < 2 );
3568
    $uid    = "?"       if ( ($#_+1) < 3 );
3569
    $gid    = "?"       if ( ($#_+1) < 4 );
3570
    $class  = "none"    if ( ($#_+1) < 5 );
3571
 
3572
    LogNorm("addPathToPrototype adding path [$path $perms $uid $gid $class]");
3573
 
3574
    # lets determine which prototype file we are going to
3575
    # use
3576
    my ($protoTypeFile);
3577
    $protoTypeFile = "$ProtoTypeFile";
3578
 
3579
    # now we need to update the prototype file
3580
    #
3581
    local *FILE;
3582
    open ( FILE, "+<$protoTypeFile") or LogError("Failed to open file [$protoTypeFile].");
3583
 
3584
    # set up has of all paths to be added
3585
    my ( %pathDirs );
3586
    my ( $workPath );
3587
    my ( $i );
3588
 
3589
    $workPath = "/" if ( $path =~ s|^/|| );
3590
    foreach $i ( split("/" , $path) )
3591
    {
3592
        $workPath .= $i;
3593
        $pathDirs{$workPath} = 1;
3594
        $workPath .= "/";
3595
    }
3596
 
3597
    while ( <FILE> )
3598
    {
3599
        # lets get all the current dir entries and check for duplicates
3600
        #        class   path    mode    owner   group
3601
        if ( /^d ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*)/ )
3602
        {
3603
            # if this dir entry is defined in our paths to add we need to remove the entry
3604
            if ( defined($pathDirs{$2}) )
3605
            {
3606
                LogWarn("addPath2Prototype: Path [$2] already exists in prototype file");
3607
                delete($pathDirs{$2});
3608
            }
3609
        }
3610
    }
3611
 
3612
    my $protoLine;
3613
    # now we write the remaining dirs in the hash 
3614
    foreach $i ( sort keys(%pathDirs) )
3615
    {
3616
        $protoLine = sprintf("d %s %s %s %s %s", $class, $i, $perms, $uid, $gid);
3617
        LogInfo("addPath2Prototype: Adding Dir entry [$protoLine]");
3618
        printf FILE "$protoLine\n"; 
3619
    }
3620
 
3621
    close FILE;
3622
    return 1;
3623
}
3624
 
3625
 
3626
#------------------------------------------------------------------------------
3627
sub createAfcRcScriptLink
3628
#
3629
#    Description:
3630
#        This sub-routine is used to create links into /afc/rc.d for start & stop 
3631
#         scripts.
3632
#
3633
#    INPUT:
3634
#        Start prefix number (2 digit number)
3635
#        Stop prefix Number (2 digit Number)
3636
#        Full path to script to create link to.
3637
#
3638
#------------------------------------------------------------------------------
3639
{
3640
    # correct number of parameters?
3641
    if ( ($#_+1) != 3 )
3642
    {
3643
        LogError("Incorrect number of params passed to " .
3644
                  "createAfcRcScriptLink() function. " .
3645
                  "Check deploy config.");
3646
    }
3647
 
3648
 
3649
    # lets just check to see if we can execute this function on
3650
    # this machine.
3651
    #
3652
    if ( "$MachType" ne "sparc" )
3653
    {
3654
        LogInfo("createAfcRcScriptLink() not supported on this machine type.");
3655
        return 1;
3656
    }
3657
 
3658
    my ($startPrefix, $stopPrefix, $scriptPath) = @_;
3659
 
3660
    if ( $startPrefix ne "" )
3661
    {
3662
        updatePrototypeFileAddItem2(sprintf("/afc/rc.d/S%02d%s", $startPrefix, $PkgName), 
3663
                                    $scriptPath, "0755", "root", "other", "S");
3664
    }
3665
    if ( $stopPrefix ne "" )
3666
    {
3667
        updatePrototypeFileAddItem2(sprintf("/afc/rc.d/K%02d%s", $stopPrefix, $PkgName), 
3668
                                    $scriptPath, "0755", "root", "other", "S");        
3669
    }
3670
}
3671
 
3672
 
3673
#------------------------------------------------------------------------------
3674
sub createAfcRcScriptLink2
3675
#
3676
#    Description:
3677
#        This sub-routine is used to create links into the afc rc.d for start & stop 
3678
#        scripts.  It differs from the original in that you pass a TargetDirType
3679
#        parameter and the filename instead of a full path.  It then creates a relative
3680
#        link from $BASEDIR/rc.d to TargetBaseDir
3681
#
3682
#    INPUT:
3683
#        Start prefix number (2 digit number)
3684
#        Stop prefix Number (2 digit Number)
3685
#        Full path to script to create link to.
3686
#
3687
#------------------------------------------------------------------------------
3688
{
3689
    # correct number of parameters?
3690
    if ( ($#_+1) != 4 )
3691
    {
3692
        LogError("Incorrect number of params passed to " .
3693
                  "createAfcRcScriptLink() function. " .
3694
                  "Check deploy config.");
3695
    }
3696
 
3697
 
3698
    # lets just check to see if we can execute this function on
3699
    # this machine.
3700
    #
3701
    if ( "$MachType" ne "sparc" )
3702
    {
3703
        LogInfo("createAfcRcScriptLink() not supported on this machine type.");
3704
        return 1;
3705
    }
3706
 
3707
    my ($startPrefix, $stopPrefix, $targetTag, $scriptPath) = @_;
3708
 
3709
    # lets check to see if the target tag exists if does not the process with log an error.
3710
    my ($targetValue) = getTargetDstDirValue($targetTag, "R");
3711
 
3712
    if ( $startPrefix ne "" )
3713
    {
3714
        updatePrototypeFileAddItem2(sprintf("rc.d/S%02d%s", $startPrefix, $PkgName), 
3715
                                    "../$targetValue/$scriptPath", "0755", "root", "other", "S");
3716
    }
3717
    if ( $stopPrefix ne "" )
3718
    {
3719
        updatePrototypeFileAddItem2(sprintf("rc.d/K%02d%s", $stopPrefix, $PkgName), 
3720
                                    "../$targetValue/$scriptPath", "0755", "root", "other", "S");        
3721
    }
3722
}
3723
 
3724
 
3725
#------------------------------------------------------------------------------
3726
sub createGenericCopy
3727
#
3728
#    Description:
3729
#        This sub-routine is used to create a generic copy of a specific item.
3730
#
3731
#        On sparc this will be a link, but on win32 it will be a file based on the
3732
#        buildType.
3733
#
3734
#    INPUT:
3735
#        src item name
3736
#        generic item name
3737
#        target dir
3738
#
3739
#    RETURN:
3740
#         1
3741
#
3742
#------------------------------------------------------------------------------
3743
{
3744
    my ($sName, $sLoc, $gName, $tDir) = @_;
3745
 
3746
    my ($cmd);
3747
    my ($retVal);
3748
    if ( "$MachType" eq "sparc" )
3749
    {
3750
        # I want to cd into the tDir and then create the link.
3751
        # only if an item of the same name does not already exist
3752
        #
3753
        if ( ! -f "$tDir/$gName" )
3754
        {
3755
            $cmd = "cd $tDir; ln -s $sName $gName";
3756
            $retVal = system("$cmd");
3757
            if ( $retVal != 0 )
3758
            {
3759
                LogError("Failed to create generic link [$gName] to [$tDir/$sName]: $retVal");
3760
            }
3761
            else
3762
            {
3763
                LogNorm("Created generic link [$gName] to [$tDir/$sName] ...");
3764
            }
3765
        }
3766
    }
3767
    else
3768
    {
3769
 
3770
        # we only create a generic copy of the an item that matches
3771
        # our build type.  (i.e. if we are building a debug package then
3772
        # only the debug items shall be considered.
3773
        #
3774
        if ( "$BuildType" eq "D" )
3775
        {
3776
            if ( $sName !~ /D\./ )
3777
            {
3778
                # this item is not a debug one.
3779
                return 1;
3780
            }
3781
        }
3782
        else
3783
        {
3784
            # this is prod build
3785
            if ( $sName !~ /P\./ )
3786
            {
3787
                # this item is not a prod one.
3788
                return 1;
3789
            }
3790
        }
3791
 
3792
 
3793
        # we have a match, lets create the copy.
3794
        #
3795
        if(File::Copy::copy("$sLoc", "$tDir/$gName"))
3796
        {
3797
            LogNorm("Created generic lib copy [$tDir/$gName]...");
3798
        }
3799
        else
3800
        {
3801
            LogError("Failed to create generic lib copy [$gName] from [$sLoc]: $!");
3802
        }
3803
    }
3804
 
3805
    return 1;
3806
}
3807
 
3808
 
3809
 
3810
#------------------------------------------------------------------------------
3811
sub removeVersionNumberFromItemName
3812
#
3813
#    Description:
3814
#        This sub-routine is used to remove the version number from the item name.
3815
#        i.e.  myFile.so.1.2.3 ==> myFile.so
3816
#
3817
#    INPUT:
3818
#        item name
3819
#
3820
#    RETURN:
3821
#        new item name.
3822
#
3823
#------------------------------------------------------------------------------
3824
{
3825
    my ($file) = @_;
3826
 
3827
    my ($nfile) = $file;
3828
 
3829
    if ( "$MachType" eq "sparc" )
3830
    {
3831
        $nfile =~ s/\.so.*$/\.so/;
3832
    }
3833
    else
3834
    {
3835
        $nfile =~ s/\.[0-9]+\.[0-9]+.*dll$/\.dll/;
3836
    }
3837
    return "$nfile";
3838
}
3839
 
3840
 
3841
#------------------------------------------------------------------------------
3842
sub excludeItemFromBuild
3843
#
3844
#    Description:
3845
#        This sub-routine is used to determine is a item is to be included in
3846
#        a build based on the current build type and the extension 
3847
#        it SHOULD HAVE!.
3848
#
3849
#        i.e. debug files will be tagged with *D.* 
3850
#             prod  file will be tagged with *P.*
3851
#
3852
#        if the item does not have a *D.* or a *P.* we included it by default.
3853
#
3854
#        INPUT:
3855
#              filename
3856
#
3857
#        RETURN: 
3858
#              1  - exclude 
3859
#              0  - include 
3860
#
3861
#------------------------------------------------------------------------------
3862
{
3863
    my ($file) = @_;
3864
 
3865
    # we only want to deliver
3866
    if ( "$MachType" eq "win32" )
3867
    {
3868
        # we have to include it by default.
3869
        return 0;
3870
    }
3871
 
3872
 
3873
    #######################################################
3874
    #######################################################
3875
    #######################################################
3876
    # Third party packages do not adhere to the *D.* *P.*
3877
    # conventions of debug and production builds.
3878
    #
3879
    # Hopefully we won't have to many of these, only found 
3880
    # one so far.
3881
    # 
3882
    #######################################################
3883
    #######################################################
3884
    #######################################################
3885
    if ( $file =~ /libTAO_BiDirGIOP\.so/ )
3886
    {
3887
        return 0;
3888
    } 
3889
 
3890
    if ( $file !~ /D\./ &&
3891
         $file !~ /P\./
3892
       )
3893
    {
3894
        # we have to include it by default. 
3895
        return 0;
3896
    }
3897
 
3898
 
3899
    # we only want to deliver 
3900
    if ( "$BuildType" eq "D" )
3901
    { 
3902
        if ( $file !~ /D\./ )
3903
        {
3904
            # we do not want this file for this build type.
3905
            return 1;
3906
        }
3907
        else
3908
        {
3909
            return 0;
3910
        }
3911
    }
3912
    else
3913
    {
3914
        if ( $file !~ /P\./ )
3915
        {
3916
            # we do not want this file for this build type.
3917
            return 1;
3918
        }
3919
        else
3920
        {
3921
            return 0;
3922
        }
3923
    }
3924
 
3925
    return 1;
3926
}
3927
 
3928
 
3929
#------------------------------------------------------------------------------
3930
sub installAllDpkgArchiveBinFiles
3931
#
3932
# Description:
3933
#       This sub-routine is used to install all bin files from the
3934
#       dpkg_archive into the defined install area.
3935
#
3936
#       It assumes based on the build type where the src files will be located.
3937
#
3938
#       If it has any problems it will log an error and stop processing.
3939
#
3940
#------------------------------------------------------------------------------
3941
{
3942
    # correct number of parameters?
3943
    if ( ($#_+1) != 1 )
3944
    {
3945
        LogError("Incorrect number of params passed to " .
3946
                  "installAllDpkgArchiveBinFiles() function. " .
3947
                  "Check deploy config.");
3948
    }
3949
 
3950
    my ($targetTag) = @_;
3951
 
3952
    # lets check to see if the target tag exists
3953
    # if does not the process with log an error.
3954
    #
3955
    my ($targetValue) = getTargetDstDirValue($targetTag, "A");
3956
 
3957
 
3958
    # ok we have a valid dst value we now need to get a hold of all the 
3959
    # lib files for this buildtype
3960
    #
3961
    my ($i);
3962
    my ($m_DpkgBinDir);
3963
    foreach $i (@{$DpkgBinDirList{'_ALL_'}})
3964
    {
3965
        $m_DpkgBinDir = "$DpkgBinDir" . "/$i";
3966
        if ( ! -d "$m_DpkgBinDir" )
3967
        {
3968
            LogInfo("Directory [$m_DpkgBinDir] not found.");
3969
            next;
3970
        }
3971
 
3972
        local *DIR;
3973
        opendir(DIR, $m_DpkgBinDir) or 
3974
            LogError("can't opendir $m_DpkgBinDir : $!");
3975
 
3976
        my ($file);
3977
        while (defined($file = readdir(DIR))) 
3978
        {
3979
            if ( $file !~ /^\.$/  &&     # we do not want the . and .. entries.
3980
                 $file !~ /^\.\.$/ &&
3981
                 $file !~ /\.pdb$/ )
3982
            {
3983
                my ($m_fLoc) = "$m_DpkgBinDir/$file"; 
3984
                if(File::Copy::copy("$m_fLoc", "$targetValue"))
3985
                {
3986
                    LogNorm("Copied [$file] to [$targetValue] ...");
3987
                }
3988
                else
3989
                {
3990
                    LogError("Failed to copy bin [$m_fLoc]: $!"); 
3991
                }
3992
            }
3993
        }
3994
        closedir(DIR);
3995
    }
3996
 
3997
    return 1;
3998
}
3999
 
4000
 
4001
#------------------------------------------------------------------------------
4002
sub rmDirectory
4003
#
4004
# Description:
4005
#       This sub-routine is used to remove an entire directory tree.
4006
#
4007
#       It recurses from a starting point removing each item and if it
4008
#       finds a dir it recurses into that dir cleaning it as well.
4009
#
4010
#------------------------------------------------------------------------------
4011
{
4012
    # correct number of parameters?
4013
    if ( ($#_+1) != 1  )
4014
    {
4015
        LogError("Incorrect number of params passed to rmDirectory() function.");
4016
    }
4017
 
4018
    my ($startingPoint) = @_;
4019
 
4020
    LogInfo("Recursively removing Directory tree [$startingPoint]");
4021
 
4022
    foreach my $item ( glob("$startingPoint/*"), glob("$startingPoint/.*") ) 
4023
    {
4024
        if ( $item !~ /^$startingPoint\/\.$/  && $item !~ /^$startingPoint\/\.\.$/ ) 
4025
        {
4026
            if ( -d "$item" )
4027
            {
4028
                rmDirectory("$item");
4029
            }
4030
            else
4031
            {
4032
                unlink("$item");
4033
                LogDebug("Removed file [$item].");
4034
            }
4035
        }
4036
    }
4037
 
4038
    # lets clean the starting point.
4039
    #
4040
    my($base)= File::Basename::basename($startingPoint);
4041
    if ( "$base" ne "." && "$base" ne ".." )
4042
    {
4043
        my $retVal = rmdir("$startingPoint");
4044
        if( $retVal )
4045
        {
4046
            LogDebug("Removed dir [$startingPoint].");
4047
        }
4048
        else
4049
        {
4050
            LogError("Failed to remove dir [$startingPoint] : $!");
4051
        }
4052
    }
4053
    return 1;
4054
}
4055
 
4056
 
4057
 
4058
#------------------------------------------------------------------------------
4059
sub CreateDirectory
4060
#
4061
# Description
4062
#       Create a directory tree based on the path specified.  It creates the tree
4063
#       rooted at the root path specified.  This path must exist
4064
#
4065
#       The first parameter is the root path to root the tree at (optional).
4066
#       The second parameter is the tree to create.
4067
#       The third parameter is the umask to create the path with
4068
#------------------------------------------------------------------------------
4069
{
4070
    if ( ($#_+1) != 3  )
4071
    {
4072
        LogError("Incorrect number of params passed to CreateDirectory() function.");
4073
    }
4074
 
4075
    my ( $rootPath, $dirPath, $umask ) = @_;
4076
 
4077
    # remove trailing slash from rootPath
4078
    $rootPath =~ s|/$||;
4079
    # remove leading slash from dirPath
4080
    $dirPath =~ s|^/||;
4081
 
4082
    if ( ! -d $rootPath )
4083
    {
4084
        LogError("CreateDirectory: RootPath [$rootPath] does not exist");
4085
    }
4086
 
4087
    LogNorm("CreateDirectory: Creating path [$dirPath] in [$rootPath]");
4088
 
4089
    my @dirs = split("/", $dirPath);
4090
 
4091
    foreach my $i ( @dirs )
4092
    {
4093
        $rootPath .= "/$i";
4094
        if ( ! -d $rootPath )
4095
        {
4096
            LogDebug("CreateDirectory: Creating [$rootPath]");
4097
            mkdir($rootPath, $umask);
4098
        }
4099
    }
4100
}   # CreateDirectory
4101
 
4102
 
4103
#------------------------------------------------------------------------------
4104
sub CreateTargetDirStructure
4105
#
4106
# Description:
4107
#       This sub-routine create the target stucture based on what the user has
4108
#       previously defined in the %TargetDstDirStructure hash array
4109
#
4110
#       It will also clean the contents of this location prior to creation.
4111
#
4112
#       In this function we also check to see if all the LocalSrcDirStructure
4113
#       directories exist. We warn if they do not.
4114
#
4115
#------------------------------------------------------------------------------
4116
{
4117
    LogNorm("Cleaning any previous target file items...");
4118
 
4119
    my ($i);
4120
    my ($m_dirD);
4121
 
4122
    # lets clean.
4123
    #
4124
    foreach $i ( sort {$b cmp $a} values %TargetDstDirStructure )
4125
    {
4126
        if ( "$i" !~ /^\.$/ &&
4127
             "$i" !~ /^\.\.$/   )
4128
        {
4129
 
4130
            $m_dirD = "$PkgBaseDir/$TargetBaseDir/$i";
4131
            if ( -d "$m_dirD" )
4132
            {
4133
                rmDirectory("$m_dirD");
4134
            }
4135
        }
4136
    } 
4137
 
4138
    $m_dirD = "$PkgPatchTmpDir";
4139
    if ( -d "$m_dirD" )
4140
    {
4141
        rmDirectory("$m_dirD");
4142
    }
4143
 
4144
    $m_dirD = "$PkgBaseDir/$TargetBaseDir";
4145
    if ( -d "$m_dirD" )
4146
    {
4147
        rmDirectory("$m_dirD");
4148
    }
4149
 
4150
    $m_dirD = "$PkgBaseDir";
4151
    if ( -d "$m_dirD" )
4152
    {
4153
        rmDirectory("$m_dirD");
4154
    }
4155
 
4156
    # lets create.
4157
    #
4158
    LogNorm ("Creating target directory structure...");
4159
 
4160
    $m_dirD = "$PkgBaseDir";
4161
    if ( ! -d "$m_dirD" )
4162
    {
4163
        mkpath ( "$m_dirD", 0, 0777);
4164
        LogInfo("Creating target dir [$m_dirD].");
4165
    }
4166
 
4167
    CreateDirectory($PkgBaseDir, $TargetBaseDir, 0777);
4168
 
4169
    foreach $i ( sort {$a cmp $b} values %TargetDstDirStructure )
4170
    {
4171
        CreateDirectory("$PkgBaseDir/$TargetBaseDir", $i, 0777);
4172
    }
4173
 
4174
 
4175
    # lets determine if we have a InstallShield config dir
4176
    #
4177
    if ( "$MachType" eq "win32" || "$MachType" eq "WinCE" )
4178
    {
4179
 
4180
        # if this is a patch build i expect to find a "p" in the front of the
4181
        # file names. we use this as a simple visual differentiation.
4182
        #
4183
        my ($m_ishieldDir);    
4184
        my ($m_ishieldProjFile);
4185
        if ( "x$PkgPatchNum" ne "x" )
4186
        {
4187
            # patch build.
4188
            $m_ishieldDir      = "$RootDir/" . "p$PkgName";
4189
            $m_ishieldProjFile = "$RootDir/" . "p$PkgName" . ".ism";
4190
        }
4191
        else
4192
        {
4193
            # normal build.
4194
            $m_ishieldDir      = "$RootDir/" . "$PkgName";
4195
            $m_ishieldProjFile = "$RootDir/" . "$PkgName" . ".ism";
4196
        }
4197
 
4198
        # here i can set the location of my IShield project dir
4199
        # so i can use it later if required.
4200
        $PKG_ISHIELD_DIR = $m_ishieldDir;
4201
 
4202
 
4203
        # we check for an ism file based on the pkg name
4204
        # if we find one we need to deal with the dir and
4205
        # the isheildlib files.
4206
        #
4207
        if ( -f "$m_ishieldProjFile" )
4208
        {
4209
            if ( ! -d "$m_ishieldDir" )
4210
            {
4211
                LogError ("Local InstallShield config dir [$m_ishieldDir] does not exist. " .
4212
                          "Please create before continuing.");
4213
            }
4214
            else
4215
            {
4216
                # we populate the ishield config dir with the ishieldlib files
4217
                #
4218
                my ($i);
4219
                LogNorm("Installing Standard ishieldlib files from [$PKG_UTIL_DIR] to [$m_ishieldDir]");
4220
                foreach $i ( @PKG_ISHIELD_FILES )
4221
                {
4222
                    # first we remove the file (as previously it install read-only).
4223
                    unlink("$m_ishieldDir/$i");
4224
                    if( File::Copy::copy("$PKG_UTIL_DIR/$i", "$m_ishieldDir") )
4225
                    {
4226
                        LogInfo("Copied [$PKG_UTIL_DIR/$i] to [$m_ishieldDir] ...");
4227
                    }
4228
                    else
4229
                    {
4230
                        LogError("Failed to copy info file [$PKG_UTIL_DIR/$i] to [$m_ishieldDir] : $!");
4231
                    }
4232
                }
4233
 
4234
 
4235
                # we also want to deliver the patch rule files
4236
                # if this build is a patch build.
4237
                #
4238
                if ( "x$PkgPatchNum" ne "x" )
4239
                {
4240
                    LogNorm("Installing Patch ishieldlib files from [$PKG_UTIL_DIR] to [$m_ishieldDir]");
4241
                    foreach $i ( @PATCH_ISHIELD_FILES )
4242
                    {
4243
                        # first we remove the file (as previously it install read-only).
4244
                        unlink("$m_ishieldDir/$i");
4245
                        if( File::Copy::copy("$PKG_UTIL_DIR/$i", "$m_ishieldDir") )
4246
                        {
4247
                            LogInfo("Copied [$PKG_UTIL_DIR/$i] to [$m_ishieldDir] ...");
4248
                        }
4249
                        else
4250
                        {
4251
                            LogError("Failed to copy info file [$PKG_UTIL_DIR/$i] to [$m_ishieldDir] : $!");
4252
                        }
4253
                    }
4254
                }
4255
 
4256
 
4257
                # we also want to deliver the islib imgages to be
4258
                # used by this project, we assume the image has a project
4259
                # acronym prefix, and if not found we just WARN the user
4260
                #
4261
                # we assume our source dir is the interface/etc dir and our
4262
                # dst dir is the PkgBaseDir
4263
                #
4264
                my ($m_islibImgFile) = "";
4265
                LogNorm("Installing ishield image files from [$DpkgEtcDir] to [$m_ishieldDir]");
4266
                foreach $i ( @PKG_ISHIELD_IMG_FILES )
4267
                {
4268
                    $m_islibImgFile = "$DpkgEtcDir/$ProjectAcronym" . "_" . $i;
4269
                    if ( -f "$m_islibImgFile" )
4270
                    {
4271
                        if( File::Copy::copy("$m_islibImgFile", "$PkgBaseDir") )
4272
                        {
4273
                            LogInfo("Copied [$m_islibImgFile] to [$PkgBaseDir] ...");
4274
                        }
4275
                        else
4276
                        {
4277
                            LogError("Failed to copy info file [$m_islibImgFile] to " .
4278
                                     "[$PkgBaseDir] : $!");
4279
                        }
4280
                    }
4281
                    else
4282
                    {
4283
                        # we shall check for the MASS items, if the exist we copy them
4284
                        # over. Here we assume the 'mas' acronymn is correct.
4285
                        #
4286
                        $m_islibImgFile = "$DpkgEtcDir/mas" . "_" . $i;
4287
                        if ( -f "$m_islibImgFile" )
4288
                        {
4289
                            if( File::Copy::copy("$m_islibImgFile", "$PkgBaseDir") )
4290
                            {
4291
                                LogInfo("Copied [$m_islibImgFile] to [$PkgBaseDir] ...");
4292
                            }
4293
                            else
4294
                            {
4295
                                LogError("Failed to copy info file [$m_islibImgFile] to " .
4296
                                         "[$PkgBaseDir] : $!");
4297
                            } 
4298
                        } 
4299
                        else
4300
                        {
4301
                            LogWarn("Failed to locate ishieldlib image [xxx_$i], no image copied, " .
4302
                                    "check depolylib config.");
4303
                        }
4304
                    }
4305
                }
4306
 
4307
            }
4308
        }
4309
        else
4310
        {
4311
            LogWarn("Did not detect InstallShield project file [$m_ishieldProjFile]");
4312
            LogWarn("Not installing InstallShield library files.");
4313
        }
4314
    }
4315
 
4316
    # done.
4317
    return 1;
4318
}
4319
 
4320
#------------------------------------------------------------------------------
4321
sub generateIShieldIncludeFile ()
4322
#
4323
# Description:
4324
#     This subroutine is used to generate a definition include file 
4325
#     that is used during IShield builds.
4326
#
4327
#     The output location of the file is the IShieldProjDir.
4328
#    
4329
#------------------------------------------------------------------------------
4330
{
4331
    my ($outFile) = "$PKG_ISHIELD_DIR/$PKG_ISHIELD_DEF_FILE";
4332
 
4333
    # this is only relavent for win32 builds.
4334
    if ( "$MachType" eq "sparc" )
4335
    {
4336
        return 1;
4337
    }
4338
 
4339
    # lets open the file.
4340
    #
4341
    local *FILE;
4342
    open ( FILE, "> $outFile") or
4343
        LogError("Failed to open file [$outFile].");
4344
 
4345
    # lets populate the pkgdef file.
4346
 
4347
    printf FILE ("// This is an automatically generated include file.\n");
4348
    printf FILE ("// Please do not modify, and please do not check into ClearCase.\n");
4349
    printf FILE ("//\n");
4350
    printf FILE ("#define PKG_NAME         \"$PkgName\"\n");
4351
    printf FILE ("#define PKG_NAMELONG     \"$PkgNameLong\"\n");
4352
    printf FILE ("#define PKG_VERSION      \"$PkgVersion\"\n");
4353
    printf FILE ("#define PKG_BUILDNUM     \"$PkgBuildNum\"\n");
4354
    printf FILE ("#define PKG_PROJACRONYM  \"$ProjectAcronym\"\n");
4355
    printf FILE ("#define PKG_DESC         \"$PkgDesc\"\n");
4356
 
4357
    # if this build is a patch build.
4358
    #
4359
    if ( "x$PkgPatchNum" ne "x" )
4360
    {
4361
        printf FILE ("#define PATCH_NAME       \"$PkgPatchName\"\n");
4362
        printf FILE ("#define PATCH_NUM        \"$PkgPatchNum\"\n");
4363
        printf FILE ("#define PATCH_ID         \"$PkgPatchID\"\n");
4364
    }
4365
    else
4366
    {
4367
        printf FILE ("#define PATCH_NAME       \"\"\n");
4368
        printf FILE ("#define PATCH_NUM        \"\"\n");
4369
        printf FILE ("#define PATCH_ID         \"\"\n");
4370
    }
4371
 
4372
    # lets close the file
4373
    close FILE;
4374
 
4375
    # done.
4376
    return 1;
4377
}
4378
 
4379
 
4380
#------------------------------------------------------------------------------
4381
sub ValidateLocalSrcDirStructure
4382
#
4383
# Description:
4384
#       This sub-routine is used to check the existence the local dir 
4385
#       configuration items, these are stored in 
4386
#       %LocalSrcDirStructure.
4387
#
4388
#------------------------------------------------------------------------------
4389
{
4390
    # lets check the configured local direcotry structure
4391
    #
4392
    my ($i);
4393
    foreach $i ( values %LocalSrcDirStructure )
4394
    {
4395
        my ($m_Dir) = "$SrcDir/$i";
4396
        if ( ! -d "$m_Dir" )
4397
        {
4398
            LogWarn ("Local src dir [$m_Dir] does not exist.");
4399
        }
4400
    }
4401
 
4402
    return 1;
4403
}
4404
 
4405
 
4406
#------------------------------------------------------------------------------
4407
sub getLocalDirValue
4408
#
4409
# Description:
4410
#       This sub-routine is used to return the local dir value from
4411
#       %LocalSrcDirStructure based on providing the 
4412
#       associated key.
4413
#
4414
#       If the value does not exist then it will return an error
4415
#       and terminate processing.
4416
#
4417
#------------------------------------------------------------------------------
4418
{
4419
    # correct number of parameters?
4420
    if ( ($#_+1) != 2 ) 
4421
    {
4422
        LogError("Incorrect number of params passed to " .
4423
                  "getLocalDirValue() function.");
4424
    }
4425
 
4426
    my ($m_key, $m_type) = @_;
4427
    if (exists  $LocalSrcDirStructure{$m_key} )    
4428
    {
4429
        if ( "$m_type" eq "A" )
4430
        {
4431
            return "$SrcDir/" .
4432
                   "$LocalSrcDirStructure{$m_key}";
4433
        }
4434
        else
4435
        {
4436
            return "$LocalSrcDirStructure{$m_key}";
4437
        }
4438
    }
4439
    else
4440
    {
4441
        LogError("Local src tag [$m_key] does not exist in " .
4442
                 "LocalSrcDirStructure. " .
4443
                 "Check deploy configuration.");
4444
    }
4445
 
4446
    return 1;
4447
}
4448
 
4449
 
4450
#------------------------------------------------------------------------------
4451
sub getTargetDstDirValue
4452
#
4453
# Description:
4454
#       This sub-routine is used to return the target dest dir value from
4455
#       %TargetDstDirStructure based on providing the 
4456
#       associated key.
4457
#
4458
#       If the value does not exist then it will return an error
4459
#       and terminate processing.
4460
#
4461
#------------------------------------------------------------------------------
4462
{
4463
    # correct number of parameters?
4464
    if ( ($#_+1) != 2 ) 
4465
    {
4466
        LogError("Incorrect number of params passed to " .
4467
                  "getTargetDstDirValue() function.");
4468
    }
4469
 
4470
    my ($m_key, $m_type) = @_;
4471
    if (exists  $TargetDstDirStructure{$m_key} )    
4472
    {
4473
        if ( "$m_type" eq "A" )
4474
        {
4475
            return "$PkgBaseDir/$TargetBaseDir/" .
4476
                   "$TargetDstDirStructure{$m_key}";
4477
        }
4478
 
4479
        if ( "$m_type" eq "R" )
4480
        {
4481
             return "$TargetBaseDir/$TargetDstDirStructure{$m_key}";
4482
        }
4483
    }
4484
    else
4485
    {
4486
        LogError("Target destination dir tag [$m_key] does not exist in " .
4487
                 "TargetDstDirStructure. " .
4488
                 "Check deploy configuration.");
4489
    }
4490
 
4491
    return 1;
4492
}
4493
 
4494
 
4495
#------------------------------------------------------------------------------
4496
sub createPatch
4497
#
4498
# Description:
4499
#       This sub-routine is used to create a solaris patch.
4500
#
4501
#------------------------------------------------------------------------------
4502
{
4503
    # correct number of parameters?
4504
    if ( ($#_+1) != 0 )
4505
    {
4506
        LogError("Incorrect number of params passed to " .
4507
                  "createPatch() function. Check deploy config.");
4508
    }
4509
 
4510
    # lets just check to see if we can execute this function on
4511
    # this machine.
4512
    #
4513
    if ( "$MachType" ne "sparc" )
4514
    {
4515
        LogInfo("createPatch() not supported on this machine type.");
4516
        return 1;
4517
    }
4518
 
4519
    # lets just check to see if we can execute this function on
4520
    # for  this build.
4521
    #
4522
    if ( "x$PkgPatchNum" eq "x" )
4523
    {
4524
        LogWarn("createPatch() can only be called during a PATCH build.");
4525
        return 1;
4526
    }
4527
 
4528
    # we need to create the patch directory that contains
4529
    #
4530
    LogNorm("Creating patch ...");
4531
 
4532
    my ( $m_pkgmkCmd );
4533
    my ( $m_pkgtransCmd );
4534
    $m_pkgmkCmd = "pkgmk -o " .
4535
                  "-f $PkgBaseDir/prototype " .
4536
                  "-d $PkgBaseDir";
4537
 
4538
    # lets execute the package commands.
4539
    my ($retVal);
4540
    $retVal = system("$m_pkgmkCmd");
4541
    if ( $retVal != 0 )
4542
    {
4543
        LogError("Failed to complete command [$m_pkgmkCmd].");
4544
    }
4545
 
4546
    # we need to generate a README file to help during installation
4547
    #
4548
    generatePatchREADME();
4549
 
4550
 
4551
    my ($m_Cmd)    = ""; 
4552
    my ($m_tmpDir) = "$PkgPatchTmpDir/$PkgPatchID";
4553
 
4554
    LogNorm("Creating staging area of patch...");
4555
    $m_Cmd = "cd $PkgBaseDir && mkdir -p $m_tmpDir;";
4556
    system($m_Cmd);
4557
 
4558
    LogNorm("Copying patch contents to staging area of patch...");
4559
    $m_Cmd = "cd $PkgBaseDir && cp -r $PkgName $m_tmpDir;";
4560
    system($m_Cmd);
4561
 
4562
    # we need to copy the patch install utility files from
4563
    # their resting place.
4564
    #
4565
    my ($i);
4566
    foreach $i ( @PATCH_UTIL_FILES )
4567
    {
4568
        if( File::Copy::copy("$PATCH_UTIL_DIR/$i", "$PkgPatchTmpDir") )
4569
        {
4570
            LogNorm("Copied [$PATCH_UTIL_DIR/$i] to [$PkgPatchTmpDir] ...");
4571
            system("chmod 0755 $PkgPatchTmpDir/$i");
4572
        }
4573
        else
4574
        {
4575
            LogError("Failed to copy info file [$PATCH_UTIL_DIR/$i] to [$PkgPatchTmpDir] : $!");
4576
        }
4577
    }
4578
 
4579
    # Lets put the readme in place
4580
    #
4581
    if( File::Copy::copy("$PkgPatchReadme", "$PkgPatchTmpDir") )
4582
    {
4583
        LogNorm("Copied [$PkgPatchReadme] to [$PkgPatchTmpDir] ...");
4584
    }
4585
    else
4586
    {
4587
        LogError("Failed to copy info file [$PkgPatchReadme] to [$PkgPatchTmpDir] : $!");
4588
    }
4589
 
4590
    LogNorm("Copying patch contents to staging area of patch...");
4591
    $m_Cmd = "cd $PkgBaseDir && cp -r $PkgName $m_tmpDir;";
4592
    system($m_Cmd);
4593
 
4594
    my ($m_oFile) = "$PkgPatchID-$ProjectAcronym\.tgz";
4595
    LogNorm("Creating a gzip'd compressed tar (.tgz) output file [$m_oFile]...");
4596
    my ($base) = File::Basename::basename($PkgPatchTmpDir);
4597
    $m_Cmd = "cd $PkgBaseDir && tar cvf - $base | gzip > $m_oFile";
4598
    system($m_Cmd);
4599
 
4600
    return 1;
4601
}
4602
 
4603
 
4604
 
4605
#------------------------------------------------------------------------------
4606
sub generatePatchREADME
4607
#
4608
#   This function is used to generate a README text file to help the user
4609
#   duing the patch installation.
4610
#
4611
#------------------------------------------------------------------------------
4612
{
4613
    local *FILE;
4614
    open ( FILE, "> $PkgPatchReadme") or
4615
        LogError("Failed to open file [$PkgPatchReadme].");
4616
 
4617
    printf FILE ("This is a patch for $PkgName $PkgVersion\n");
4618
    printf FILE ("---------------------------------------------------------------\n");
4619
    printf FILE ("\n");
4620
    printf FILE ("Installing patch (as the 'root' user) :\n");
4621
    printf FILE ("---------------------------------------------------------------\n");
4622
    printf FILE ("./installpatch $PkgPatchID\n");
4623
    printf FILE ("\n");
4624
    printf FILE ("Backing Out patch:\n");
4625
    printf FILE ("---------------------------------------------------------------\n");
4626
    printf FILE ("./backoutpatch $PkgPatchID\n");
4627
    printf FILE ("\n");
4628
 
4629
    printf FILE ("Patch contents of $PkgPatchID\n");
4630
    printf FILE ("---------------------------------------------------------------\n");
4631
    close FILE;
4632
 
4633
    # now we need to get the contents of the patch we are creating.
4634
    #
4635
    File::Find::find(\&getPatchContents, "$PkgBaseDir/$TargetBaseDir");
4636
 
4637
    return 1;
4638
}
4639
 
4640
 
4641
#------------------------------------------------------------------------------
4642
sub getPatchContents
4643
#
4644
#   This sub-routine adds an entry into the readme file for each
4645
#   item in the patch delivery tree.
4646
#
4647
#------------------------------------------------------------------------------
4648
{
4649
    my($file)= "$File::Find::name";
4650
    my($base)= File::Basename::basename($file);
4651
 
4652
    # we get the absolute path from the find, but we only require
4653
    # a relative path from the starting dir.
4654
    # so our start dir.
4655
 
4656
    my ($m_sfile) = $file;
4657
    $file =~ s/$PkgBaseDir//;
4658
 
4659
    open ( FILE, ">> $PkgPatchReadme") or
4660
         LogError("Failed to open file [$deplylib::PkgPatchReadme].");
4661
 
4662
    # lets populate the prototype file.
4663
    printf FILE ("* $file\n");
4664
 
4665
    close (FILE);
4666
}
4667
 
4668
 
4669
#------------------------------------------------------------------------------
4670
sub createPackage
4671
#
4672
# Description:
4673
#       This sub-routine is used to create a solaris package.
4674
#
4675
#------------------------------------------------------------------------------
4676
{
4677
    # correct number of parameters?
4678
    if ( ($#_+1) != 0 )
4679
    {
4680
        LogError("Incorrect number of params passed to " .
4681
                  "createPackage() function. Check deploy config.");
4682
    }
4683
 
4684
    # lets just check to see if we can execute this function on
4685
    # this machine.
4686
    #
4687
    if ( "$MachType" ne "sparc" )
4688
    {
4689
        LogInfo("createPackage() not supported on this machine type.");
4690
        return 1;
4691
    }
4692
 
4693
    # lets just check to see if we can execute this function on
4694
    # for  this build.
4695
    #
4696
    if ( "x$PkgPatchNum" ne "x" )
4697
    {
4698
        LogWarn("createPackage() can only be called during a RELEASE build.");
4699
        return 1;
4700
    }
4701
 
4702
 
4703
    # we need to copy the package utility files from
4704
    # their resting place.
4705
    #
4706
    my ($i);
4707
    foreach $i ( @PKG_UTIL_FILES )
4708
    {
4709
        if( File::Copy::copy("$PKG_UTIL_DIR/$i", "$PkgBaseDir") )
4710
        {
4711
            LogNorm("Copied [$PKG_UTIL_DIR/$i] to [$PkgBaseDir] ...");
4712
            updatePrototypeFileAddItem2("$i", "$i", "", "", "", "I");
4713
            system("chmod 0755 $PkgBaseDir/$i");
4714
        }
4715
        else
4716
        {
4717
            LogError("Failed to copy info file [$PKG_UTIL_DIR/$i] to [$PkgBaseDir] : $!");
4718
        }
4719
    }
4720
 
4721
 
4722
    my ( $m_pkgmkCmd );
4723
    my ( $m_pkgtransCmd );
4724
    $m_pkgmkCmd = "pkgmk -o " .
4725
                  "-f $PkgBaseDir/prototype " .
4726
                  "-d $PkgBaseDir";
4727
 
4728
 
4729
    $m_pkgtransCmd = "pkgtrans -o " .
4730
                     "-s $PkgBaseDir " .
4731
                     "$PkgOutputFile " .
4732
                     "$PkgName";
4733
 
4734
    # lets execute the package commands.
4735
    my ($retVal);
4736
    $retVal = system("$m_pkgmkCmd");
4737
    if ( $retVal != 0 )
4738
    {
4739
        LogError("Failed to complete command [$m_pkgmkCmd].");
4740
    }
4741
 
4742
    $retVal = system("$m_pkgtransCmd");
4743
    system("$m_pkgtransCmd");
4744
    if ( $retVal != 0 )
4745
    {
4746
        LogError("Failed to complete command [$m_pkgtransCmd].");
4747
    }
4748
 
4749
    # lets compress the output to save some space.
4750
    #
4751
    LogNorm("Compressing $PkgOutputFile");
4752
    my ($m_compressCmd) = "cd $PkgBaseDir; gzip $PkgOutputFile";
4753
    system($m_compressCmd);
4754
 
4755
    return 1;
4756
}
4757
 
4758
 
4759
#------------------------------------------------------------------------------
4760
sub createPrototypeFile
4761
#
4762
# Description:
4763
#       This sub-routine is used to create the required package prototye file
4764
#       from a known directory struture using the search path method.
4765
#
4766
#------------------------------------------------------------------------------
4767
{
4768
    # correct number of parameters?
4769
    if ( ($#_+1) != 2 )
4770
    {
4771
        LogError("Incorrect number of params passed to " .
4772
                  "createPrototypeFile() function. Check deploy config.");
4773
    }
4774
 
4775
    # lets just check to see if we can execute this function on
4776
    # this machine.
4777
    #
4778
    if ( "$MachType" ne "sparc" )
4779
    {
4780
        LogInfo("createPrototypeFile() not supported on this machine type.");
4781
        return 1;
4782
    }
4783
 
4784
    # lets take the passed in args.
4785
    my ($uid, $gid) = @_;
4786
 
4787
 
4788
    # we need to determine whiich file we are dealing with
4789
    my ($protoTypeFile);
4790
    my ($targetBaseDir);
4791
    my ($pkgBaseDir);
4792
    $protoTypeFile = "$ProtoTypeFile"; 
4793
    $targetBaseDir = "$PkgBaseDir/$TargetBaseDir"; 
4794
    $pkgBaseDir    = "$PkgBaseDir"; 
4795
 
4796
 
4797
    # we need to locate the prototype file
4798
    if ( -f "$protoTypeFile" )
4799
    {
4800
        unlink("$protoTypeFile");
4801
        LogInfo("Removing prototype file [$protoTypeFile].");
4802
    }
4803
 
4804
    # lets open the prototype file.
4805
    #    
4806
    local *FILE;
4807
    open ( FILE, "> $protoTypeFile") or
4808
        LogError("Failed to open file [$protoTypeFile].");
4809
 
4810
    # lets populate the prototype file.
4811
    printf FILE ("i pkginfo\n");
4812
 
4813
    if ( "x$TargetBaseDir" ne "x." )
4814
    {
4815
        printf FILE ("!search $TargetBaseDir");
4816
    }
4817
    else
4818
    {
4819
        printf FILE ("!search ");
4820
    }
4821
 
4822
    # now we need to add entries for each directory we will 
4823
    # be installing 
4824
    File::Find::find(\&prototypeFind, "$targetBaseDir");
4825
 
4826
    # lets populate the prototype file with a newline.
4827
    open ( FILE, ">> $protoTypeFile") or
4828
        LogError("Failed to open file [$protoTypeFile].");
4829
    printf FILE ("\n");
4830
    close (FILE);
4831
 
4832
 
4833
    # lets put the pre-deinfed generic entries into the 
4834
    # prototype file
4835
    #
4836
    if ( "x$PkgPatchNum" ne "x" )
4837
    {
4838
        addPatchInfo2ProtoTypeFile();
4839
    }
4840
 
4841
 
4842
    # we need to expand and complete the creation of the 
4843
    # prototype file
4844
    # if targetbasedir is "." the pkgproto will pick up the pkginfo and
4845
    # prototype files so we need to remove them
4846
    my ($m_cmd) = "pkgproto " .
4847
                  "$TargetBaseDir " .
4848
                  "| egrep -v \"($ProtoTypeFileName|$PkgInfoFileName)\"" .
4849
                  "| cut -f1-4 -d' ' | sed " . '"s/\$/ ' . "$uid $gid" . '/g"' . 
4850
                  " >> $protoTypeFile";
4851
 
4852
    my ($retVal) = system("cd $pkgBaseDir; $m_cmd");
4853
    if ( $retVal != 0 )
4854
    {
4855
        LogError("Failed to create prototype file [$protoTypeFile].");
4856
    }
4857
 
4858
    LogNorm("Created prototype file [$protoTypeFile].");
4859
 
4860
    return 1;
4861
}
4862
 
4863
#------------------------------------------------------------------------------
4864
sub prototypeFind
4865
#
4866
#    Description:
4867
#        This subroutine is used to locate all associated package dirs.
4868
#        It also adds an entry into the prototype file for each dir.
4869
#
4870
#------------------------------------------------------------------------------
4871
{
4872
    my($file)= "$File::Find::name";
4873
    my($base)= File::Basename::basename($file);
4874
 
4875
    # we get the absolute path from the find, but we only require
4876
    # a relative path from the starting dir.
4877
    # so our start dir.
4878
 
4879
    # we need to determine whiich file we are dealing with
4880
    my ($pfile);
4881
    my ($tDir);
4882
    $pfile = "$ProtoTypeFile"; 
4883
    $tDir = "$PkgBaseDir/$TargetBaseDir"; 
4884
    if ( "$file" ne "$tDir" )
4885
    {
4886
        if ( -d "$file" )  
4887
        {
4888
            my ($m_sfile) = $file;
4889
 
4890
            if ( "x$TargetBaseDir" eq "x." )
4891
            {
4892
                $tDir = $tDir . "/";
4893
                $file =~ s/$tDir//;
4894
            }
4895
            else
4896
            {
4897
                $file =~ s/$tDir/$TargetBaseDir/;
4898
            }
4899
 
4900
            open ( FILE, ">> $pfile") or
4901
                 LogError("Failed to open file [$pfile].");
4902
 
4903
            # lets populate the prototype file.
4904
            printf FILE (" $file");
4905
            close (FILE);
4906
        }
4907
    }
4908
}
4909
 
4910
 
4911
#------------------------------------------------------------------------------
4912
sub addPatchInfo2ProtoTypeFile
4913
#
4914
# Description:
4915
#       This sub-routine is used to add additonal genericinformation
4916
#       used by the patch.
4917
#
4918
#------------------------------------------------------------------------------
4919
{
4920
    LogNorm("Adding patch information files to patch build...");
4921
 
4922
    # we need to determine whiich file we are dealing with
4923
    my ($protoTypeFile);
4924
    $protoTypeFile = "$ProtoTypeFile";
4925
 
4926
    # lets open the prototype file.
4927
    #
4928
    local *FILE;
4929
    open ( FILE, ">> $protoTypeFile") or
4930
        LogError("Failed to open file [$protoTypeFile].");
4931
 
4932
 
4933
    # we need to copy the install informational files from
4934
    # their resting place.
4935
    my ($i);
4936
    foreach $i ( @PATCH_INFO_FILES )
4937
    {
4938
        if( File::Copy::copy("$PATCH_UTIL_DIR/$i", "$PkgBaseDir") )
4939
        {
4940
            LogNorm("Copied [$PATCH_UTIL_DIR/$i] to [$PkgBaseDir] ...");
4941
            printf FILE ("i $i\n"); 
4942
        }
4943
        else
4944
        {
4945
            LogError("Failed to copy info file [$PATCH_UTIL_DIR/$i]: $!");
4946
        }
4947
    }
4948
    close FILE;
4949
 
4950
    return 1;
4951
}
4952
 
4953
 
4954
#------------------------------------------------------------------------------
4955
sub useReplaceClass
4956
#
4957
# Description:
4958
#       This sub-routine is used to add replace class to the classes list and
4959
#       include the i.replace file in the PKG_INFO_FILES List
4960
#
4961
#------------------------------------------------------------------------------
4962
{
4963
 
4964
    LogNorm("useReplaceClass: Adding replace class to installer");
4965
 
4966
    $PkgInfoClasses = $PkgInfoClasses . " " . "replace";
4967
    push(@PKG_UTIL_FILES, "i.replace");
4968
}
4969
 
4970
 
4971
#------------------------------------------------------------------------------
4972
sub addPkgInfoClasses
4973
#
4974
# Description:
4975
#       This sub-routine is used to add new classes to the pkginfo CLASSES variable.
4976
#
4977
#------------------------------------------------------------------------------
4978
{
4979
    # correct number of parameters?
4980
    if ( ($#_+1) == 0 )
4981
    {
4982
        LogError("Incorrect number of params passed to " .
4983
                  "createPkginfoFile() function. Check deploy config.");
4984
    }
4985
 
4986
    LogNorm("addPkgInfoClasses() Adding classes \"" . join(" ", @_) . "\" to CLASSES List");
4987
 
4988
    $PkgInfoClasses = $PkgInfoClasses . " " . join(" ", @_);
4989
}
4990
 
4991
 
4992
#------------------------------------------------------------------------------
4993
sub addPkgInfoField
4994
#
4995
# Description:
4996
#       This sub-routine is used to add new fields to already created pkginfo file
4997
#       Acccepts any number of fields of format A=B as one string parameter.
4998
#------------------------------------------------------------------------------
4999
{
5000
    # lets just check to see if we can execute this function on this machine.
5001
    if ( "$MachType" ne "sparc" )
5002
    {
5003
        LogInfo("addPkgInfoField() not supported on this machine type.");
5004
        return 1;
5005
    }
5006
    # lets open the pkginfo file.   
5007
    local *FILE;
5008
    open ( FILE, ">> $PkgInfoFile") or LogError("Failed to open file [$PkgInfoFile].");
5009
 
5010
    foreach my $i ( @_ )
5011
    {
5012
        print FILE "$i\n";
5013
    }
5014
    close FILE;
5015
    return 1;
5016
}
5017
 
5018
#------------------------------------------------------------------------------
5019
sub updatePrototypeFileItemClass
5020
#
5021
# Description:
5022
#       This subroutine is used to change the class of a file already in the prototype file
5023
#
5024
#------------------------------------------------------------------------------
5025
{
5026
    # correct number of parameters?
5027
    if ( ($#_+1) != 2 )
5028
    {
5029
        LogError("Incorrect number of params passed to " .
5030
                  "updatePrototypeFileItemClass() function. Check deploy config.");
5031
    }
5032
 
5033
 
5034
    # lets just check to see if we can execute this function on
5035
    # this machine.
5036
    #
5037
    if ( "$MachType" ne "sparc" )
5038
    {
5039
        LogInfo("updatePrototypeFileItemClass() not supported on this machine type.");
5040
        return 1;
5041
    }
5042
 
5043
 
5044
    # lets setup the passed values.
5045
    my ($m_item, $class) = @_;
5046
 
5047
    my ($tmpProtoTypeFile) = "/tmp/xx_prototypefile.$$";
5048
 
5049
    # lets open the prototype file if it exists
5050
    #
5051
    open (PFILE, "< $ProtoTypeFile") or
5052
        LogError("Failed to open prototype file [$ProtoTypeFile].");
5053
 
5054
    open (PFILETMP, "> $tmpProtoTypeFile") or
5055
        LogError("Failed to open tmp prototype file [$tmpProtoTypeFile].");
5056
 
5057
    while ( <PFILE> )
5058
    {
5059
        chomp;
5060
        # The path section will normally contain "path [mode]" or path=path
5061
        # The passed arg can be full path or can skip top level dirs
5062
        # eg prototype can have line with path ergbpeod/etc/afcbp.ini
5063
        # arg to match can be ergbpeod/etc/afcbp.ini, etc/afcbp.ini or afcbp.ini
5064
        # therefore we need to match arg to the end of the path in line 
5065
        # so we append [= ] to arg
5066
        s/^(\s*[bcdefilpsvx]\s*)[^\s]*(.*$)/$1$class$2/ if ( /$m_item[ =]/ );
5067
        printf PFILETMP ("$_\n");
5068
    }
5069
    close PFILE;
5070
    close PFILETMP;
5071
 
5072
    # now we need to copy the file.
5073
    if(File::Copy::copy("$tmpProtoTypeFile", "$ProtoTypeFile"))
5074
    {
5075
        LogNorm("Updated file $m_item to class $class");
5076
        unlink($tmpProtoTypeFile);
5077
    }
5078
    else
5079
    {
5080
        LogError("Failed to copy lib [$tmpProtoTypeFile]: $!");
5081
    }
5082
 
5083
    return 1;
5084
 
5085
}
5086
 
5087
 
5088
 
5089
#------------------------------------------------------------------------------
5090
sub setReplaceClassFiles
5091
#
5092
# Description:
5093
#       This subroutine is used to change the class of a file already in the prototype file
5094
#
5095
#------------------------------------------------------------------------------
5096
{
5097
    # lets just check to see if we can execute this function on
5098
    # this machine.
5099
    #
5100
    if ( "$MachType" ne "sparc" )
5101
    {
5102
        LogInfo("updatePrototypeFileItemClass() not supported on this machine type.");
5103
        return 1;
5104
    }
5105
 
5106
    LogError("Must call useReplaceClass() before calling setReplaceClassFiles()") if ( $PkgInfoClasses !~ /replace/ );
5107
 
5108
    my ($tmpProtoTypeFile) = "/tmp/xx_prototypefile.$$";
5109
 
5110
    # lets open the prototype file if it exists
5111
    #
5112
    open (PFILE, "< $ProtoTypeFile") or
5113
        LogError("Failed to open prototype file [$ProtoTypeFile].");
5114
 
5115
    open (PFILETMP, "> $tmpProtoTypeFile") or
5116
        LogError("Failed to open tmp prototype file [$tmpProtoTypeFile].");
5117
 
5118
    my $line;
5119
    while ( $line = <PFILE> )
5120
    {
5121
        chomp $line;
5122
        # The path section will normally contain "path [mode]" or path=path
5123
        # The passed args can be full path or can skip top level dirs
5124
        # eg prototype can have line with path ergbpeod/etc/afcbp.ini
5125
        # args to match can be ergbpeod/etc/afcbp.ini, etc/afcbp.ini or afcbp.ini
5126
        # therefore we need to match each arg to the end of the path in line 
5127
        # so we append [= ] to end of each arg
5128
        $line =~ s/^(\s*[bcdefilpsvx]\s*)[^\s]*(.*$)/$1replace$2/ if ( scalar(grep { $line =~ /$_[ =]/ } @_) > 0 );
5129
        printf PFILETMP ("$line\n");
5130
    }
5131
    close PFILE;
5132
    close PFILETMP;
5133
 
5134
    # now we need to copy the file.
5135
    if(File::Copy::copy("$tmpProtoTypeFile", "$ProtoTypeFile"))
5136
    {
5137
        LogNorm("Updated prototype file entries to class replace");
5138
        unlink($tmpProtoTypeFile);
5139
    }
5140
    else
5141
    {
5142
        LogError("Failed to copy lib [$tmpProtoTypeFile]: $!");
5143
    }
5144
 
5145
    return 1;
5146
 
5147
}
5148
 
5149
 
5150
#------------------------------------------------------------------------------
5151
sub createPkginfoFile
5152
#
5153
# Description:
5154
#       This sub-routine is used to create the required package info.
5155
#       Accepts any number of parameters, with each parameter taken as a literal
5156
#       Field=Value string and inserted into the PkgInfo File
5157
#------------------------------------------------------------------------------
5158
{
5159
    # lets check to see if our description has been set
5160
    if ( $PkgDesc eq "" )
5161
    {
5162
        LogError("Package description not set. " .
5163
                 "Use setPkgDescription('my package description') function.");
5164
    }
5165
 
5166
    # lets check to see if our long name has been set
5167
    if ( $PkgNameLong eq "" )
5168
    {
5169
        LogError("Package name not set. Use setPkgName('my package long name') function.");
5170
    }
5171
 
5172
 
5173
    # lets just check to see if we can execute this function on
5174
    # this machine.
5175
    #
5176
    if ( "$MachType" ne "sparc" )
5177
    {
5178
        generateIShieldIncludeFile();
5179
        return 1;
5180
    }
5181
 
5182
    # we need to determine whiich file we are dealing with
5183
    my ($pkginfoFile) = "$PkgInfoFile"; 
5184
 
5185
    # we need to locate the pkginfo file
5186
    if ( -f "$pkginfoFile" )
5187
    {
5188
        unlink("$pkginfoFile");
5189
        LogInfo("Removing pkginfo file [$pkginfoFile].");
5190
    }
5191
 
5192
    # lets open the pkginfo file.
5193
    #    
5194
    local *FILE;
5195
    open ( FILE, "> $pkginfoFile") or
5196
        LogError("Failed to open file [$pkginfoFile].");
5197
 
5198
    # lets populate the pkginfo file.
5199
    printf FILE ("PKG=$PkgName\n");
5200
 
5201
 
5202
    # here we deal with the new version number format
5203
    #
5204
    printf FILE ("NAME=$PkgNameLong\n");
5205
    printf FILE ("VERSION=$PkgVersion.$ProjectAcronym\n");
5206
    printf FILE ("ARCH=$MachType\n");
5207
    printf FILE ("VENDOR=$VENDOR_DESC\n");
5208
    printf FILE ("DESC=$PkgDesc\n");
5209
    printf FILE ("CATEGORY=$CATEGORY_DESC\n");
5210
    printf FILE ("BASEDIR=$ERGAFC_BASEDIR\n");
5211
    printf FILE ("TARGETBASEDIR=$TargetBaseDir\n");
5212
    printf FILE ("CLASSES=$PkgInfoClasses\n");
5213
 
5214
    foreach my $param ( @_ )
5215
    {
5216
        printf FILE "$param\n";
5217
    }
5218
 
5219
    if ( "x$PkgPatchNum" ne "x" )
5220
    {
5221
        my ($count)=1;
5222
        my ($pRev)="";
5223
        printf FILE ("MAXINST=$MAXINST\n");
5224
        printf FILE ("SUNW_PATCHID=$PkgPatchID\n");
5225
        printf FILE ("SUNW_REQUIRES=\n");
5226
        printf FILE ("SUNW_INCOMPAT=\n");
5227
 
5228
        $count=1;
5229
        $pRev="";
5230
        printf FILE ("SUNW_OBSOLETES=");
5231
        while ( $count < $PkgPatchNum )
5232
        {
5233
            $pRev = sprintf ("%02s", $count); 
5234
            printf FILE ("$PkgPatchName" . 
5235
                         "$PkgVersionStr" . 
5236
                         "-" . 
5237
                         "$pRev ");
5238
            $count++;
5239
        }
5240
        printf FILE ("\n");
5241
 
5242
        $count=1;
5243
        $pRev="";
5244
        printf FILE ("PATCH_OBSOLETES=");
5245
        while ( $count < $PkgPatchNum )
5246
        {
5247
            $pRev = sprintf ("%02s", $count); 
5248
            printf FILE ("$PkgPatchName" . 
5249
                         "$PkgVersionStr" . 
5250
                         "-" . 
5251
                         "$pRev ");
5252
            $count++;
5253
        }
5254
        printf FILE ("\n");
5255
    }
5256
 
5257
 
5258
    # now we will list the build dependencies so
5259
    # we can refer to them online
5260
    #
5261
    my ($i);
5262
    my ($m_Str);
5263
    # printf FILE ("\n");
5264
    my ($count) = 1;
5265
    foreach $i ( $BuildFileInfo->getDpkgArchiveList() )
5266
    {
5267
         my $moduleInfo = $BuildFileInfo->getDpkgArchiveInfo($i);
5268
 
5269
         printf FILE ( "$moduleInfo->{type}\_$count=$i $moduleInfo->{version}");
5270
 
5271
         # we shall print the project bit if we have one
5272
         if ( $moduleInfo->{proj} ne "" )
5273
         {
5274
             printf FILE ( "\.$moduleInfo->{proj}\n");
5275
         }
5276
         else
5277
         {
5278
             printf FILE ("\n");
5279
         }
5280
         $count++;
5281
    }
5282
    close FILE;
5283
 
5284
 
5285
    # lets close the pkginfo file.
5286
    close (FILE);
5287
    LogNorm("Created pkginfo file [$pkginfoFile].");
5288
 
5289
    return 1;
5290
}
5291
 
5292
 
5293
#------------------------------------------------------------------------------
5294
sub updatePrototypeFileItemOwner
5295
#
5296
# Description:
5297
#       This sub-routine is used to change the ownership of a file item
5298
#       in the prototype file.
5299
#
5300
#------------------------------------------------------------------------------
5301
{
5302
    # correct number of parameters?
5303
    if ( ($#_+1) != 4 )
5304
    {
5305
        LogError("Incorrect number of params passed to " .
5306
                  "updatePrototypeFileItemOwner() function. Check deploy config.");
5307
    }
5308
 
5309
 
5310
    # lets just check to see if we can execute this function on
5311
    # this machine.
5312
    #
5313
    if ( "$MachType" ne "sparc" )
5314
    {
5315
        LogInfo("chmod() not supported on this machine type.");
5316
        return 1;
5317
    }
5318
 
5319
 
5320
    # lets setup the passed values.
5321
    my ($m_item, $m_ownPerms, $m_ownUser, $m_ownGroup) = @_;
5322
 
5323
 
5324
    my ($tmpProtoTypeFile) = "/tmp/xx_prototypefile.$$";
5325
 
5326
 
5327
    # lets open the prototype file if it exists
5328
    #
5329
    open (PFILE, "< $ProtoTypeFile") or
5330
        LogError("Failed to open prototype file [$ProtoTypeFile].");
5331
 
5332
    open (PFILETMP, "> $tmpProtoTypeFile") or
5333
        LogError("Failed to open tmp prototype file [$tmpProtoTypeFile].");
5334
 
5335
    my ($inLine);
5336
    while ( <PFILE> )
5337
    {
5338
        $inLine = $_;
5339
        chomp($inLine);
5340
        if ( "$inLine" =~ /^f / && "$inLine" =~ /$m_item/ )
5341
        {
5342
            my ($b1, $b2, $b3, $b4, $b5, $b6) = split (/ /, $inLine); 
5343
            printf PFILETMP ("$b1 $b2 $b3 $m_ownPerms $m_ownUser $m_ownGroup\n");
5344
        }
5345
        else
5346
        {
5347
            printf PFILETMP ("$inLine\n");
5348
        }
5349
    }
5350
    close PFILE;
5351
    close PFILETMP;
5352
 
5353
    # now we need to copy the file.
5354
    if(File::Copy::copy("$tmpProtoTypeFile", "$ProtoTypeFile"))
5355
    {
5356
        LogNorm("Copied [$tmpProtoTypeFile] to [$ProtoTypeFile] ...");
5357
        unlink($tmpProtoTypeFile);
5358
    }
5359
    else
5360
    {
5361
        LogError("Failed to copy lib [$tmpProtoTypeFile]: $!");
5362
    }
5363
 
5364
    return 1;
5365
 
5366
}
5367
 
5368
 
5369
#------------------------------------------------------------------------------
5370
sub chmod
5371
#
5372
# Description:
5373
#       This sub-routine is used to change the ownership of a file or
5374
#       directory structure.
5375
#
5376
#------------------------------------------------------------------------------
5377
{
5378
    # correct number of parameters?
5379
    if ( ($#_+1) != 3 )
5380
    {
5381
        LogError("Incorrect number of params passed to " .
5382
                  "chmod() function. Check deploy config.");
5383
    }
5384
 
5385
 
5386
    # lets setup the passed values.
5387
    my ($m_sDirTag, $m_sfile, $m_ownPerms) = @_;
5388
 
5389
 
5390
    # lets just check to see if the perms are in correct format.
5391
    #
5392
    if ( "$m_ownPerms" !~ m/^[0-9][0-9][0-9][0-9]$/ )
5393
    {
5394
        LogError("chmod() does not support [$m_ownPerms] permission, use format 0755 etc.");
5395
        return 1;
5396
    }
5397
 
5398
    # lets get the absolute src dir value
5399
    my ($m_sDirAbsoluteValue) = getTargetDstDirValue($m_sDirTag, "A");
5400
 
5401
    my($item);
5402
    if ( "x$m_sfile" eq "x" )
5403
    {
5404
        $item = "$m_sDirAbsoluteValue";
5405
    }
5406
    else
5407
    {
5408
        $item = "$m_sDirAbsoluteValue/$m_sfile";
5409
    }
5410
 
5411
    # check to see if item exists
5412
    #
5413
    if ( ! -f "$item" && 
5414
         ! -d "$item" )
5415
    {
5416
        LogError("Failed to find item [$item]. Check deploy config."); 
5417
    }
5418
    LogNorm("chmod: Changing permisions of file [$m_sfile] in dirtag [$m_sDirTag] to [$m_ownPerms]");
5419
    chmodFile("$item", $m_ownPerms);
5420
 
5421
    return 1;
5422
}
5423
 
5424
 
5425
#------------------------------------------------------------------------------
5426
sub chmodRecursive
5427
#
5428
# Description:
5429
#       This sub-routine is used to change the permissions recursively in
5430
#       the target packgae.
5431
#
5432
#------------------------------------------------------------------------------
5433
{
5434
    # correct number of parameters?
5435
    if ( ($#_+1) != 2 )
5436
    {
5437
        LogError("Incorrect number of params passed to " .
5438
                  "chmodRecursive() function. Check deploy config.");
5439
    }
5440
 
5441
    # lets setup the passed values.
5442
    my ($m_sDirTag, $m_ownPerms) = @_;
5443
 
5444
    # lets just check to see if the perms are in correct format.
5445
    #
5446
    if ( "$m_ownPerms" !~ m/^[0-9][0-9][0-9][0-9]$/ )
5447
    {
5448
        LogError("chmod() does not support [$m_ownPerms] permission, use format 0755 etc.");
5449
        return 1;
5450
    }
5451
 
5452
 
5453
    # lets get the absolute src dir value
5454
    my ($m_sDirAbsoluteValue) = getTargetDstDirValue($m_sDirTag, "A");
5455
 
5456
 
5457
    # check to see if item exists
5458
    #
5459
    if ( ! -f "$m_sDirAbsoluteValue" &&
5460
         ! -d "$m_sDirAbsoluteValue" )
5461
    {
5462
        LogError("Failed to find item [$m_sDirAbsoluteValue]. " .
5463
                  "Check deploy config."); 
5464
    }
5465
 
5466
 
5467
    # if its a not a dir
5468
    #
5469
    if ( ! -d "$m_sDirAbsoluteValue" && -f "$m_sDirAbsoluteValue" )
5470
    {
5471
        LogWarn("chmodRecursive: This should not happen as dirtag [$m_sDirTag] is a file, changings perms to [$m_ownPerms] anyway");
5472
        chmodFile("$m_sDirAbsoluteValue", $m_ownPerms);
5473
    }
5474
    else
5475
    {
5476
        # it must be a dir
5477
        LogNorm("chmodRecursive: Recursively setting perms on dirtag [$m_sDirTag] to [$m_ownPerms]");
5478
        chmodDir("$m_sDirAbsoluteValue", $m_ownPerms);
5479
    }
5480
 
5481
    return 1;
5482
}
5483
 
5484
 
5485
 
5486
 
5487
#------------------------------------------------------------------------------
5488
sub chmodDir
5489
#
5490
# Description:
5491
#       This sub-routine is used to change the permissions an entire directory tree.
5492
#
5493
#       It recurses from a starting point chmod'ing each item and if it
5494
#       finds a dir it recurses into that dir chmod'ing it as well.
5495
#
5496
#------------------------------------------------------------------------------
5497
{
5498
    # correct number of parameters?
5499
    if ( ($#_+1) != 2 )
5500
    {
5501
        LogError("Incorrect number of params passed to " .
5502
                  "chmodDir() function.");
5503
    }
5504
 
5505
    my ($startingPoint, $perms) = @_;
5506
 
5507
    LogInfo("chmodDir: Recursively setting permsision of [$startingPoint] to [$perms]");
5508
 
5509
    local *DIR;
5510
    opendir(DIR, $startingPoint) or
5511
        LogError("can't opendir $startingPoint: $!");
5512
 
5513
    my ($item);
5514
    while (defined($item = readdir(DIR)))
5515
    {
5516
        if ( "$item" !~ /^\.$/  &&
5517
             "$item" !~ /^\.\.$/ )
5518
        {
5519
            if ( -d "$startingPoint/$item" )
5520
            {
5521
                chmodDir("$startingPoint/$item", $perms);
5522
            }
5523
            else
5524
            {
5525
                chmodFile("$startingPoint/$item", $perms);
5526
            }
5527
        }
5528
    }
5529
    close (DIR);
5530
 
5531
    # lets deal with starting dir
5532
    # 
5533
    chmodFile("$startingPoint", $perms);
5534
 
5535
    return 1;
5536
}
5537
 
5538
 
5539
 
5540
#------------------------------------------------------------------------------
5541
sub chmodFile
5542
#
5543
#    this function is used to chmod the perms od an item
5544
#    it is passed the absolute path to the item and the associated 
5545
#    perms.
5546
#
5547
#------------------------------------------------------------------------------
5548
{
5549
    my ($item, $perms) = @_;
5550
 
5551
    my ($cmd) = "CORE::chmod $perms, $item";
5552
    my ($noItems) = CORE::chmod oct($perms), $item;
5553
    if ( $noItems == 0 )
5554
    {
5555
        LogError("Failed to complete command [$cmd], retVal=[$noItems]");
5556
    }
5557
    else
5558
    {
5559
        LogDebug("Executed command: [$cmd]");
5560
    }
5561
 
5562
    return 1;
5563
}
5564
 
5565
 
5566
 
5567
#------------------------------------------------------------------------------
5568
sub createSymbolicLink
5569
#
5570
# Description:
5571
#       This sub-routine is used to copy a local deployment file into
5572
#       the target destination dir. 
5573
#
5574
#
5575
#------------------------------------------------------------------------------
5576
{
5577
    # correct number of parameters?
5578
    if ( ($#_+1) != 3 )
5579
    {
5580
        LogError("Incorrect number of params passed to " .
5581
                  "createSymbolicLink() function. Check deploy config.");
5582
    }
5583
 
5584
 
5585
    # lets just check to see if we can execute this function on
5586
    # this machine.
5587
    #
5588
    if ( "$MachType" ne "sparc" )
5589
    {
5590
        LogInfo("createSymbolicLink() not supported on this machine type.");
5591
        return 1;
5592
    }
5593
 
5594
 
5595
    # lets setup the passed values.
5596
    my ($m_sDirTag, $m_srcStr, $m_linkStr) = @_;
5597
 
5598
    # lets get the absolute src dir value
5599
    my ($m_sDirAbsoluteValue) = getTargetDstDirValue($m_sDirTag, "A");
5600
 
5601
 
5602
    # lets see if the source item exists
5603
    #
5604
    if ( ! -f "$m_sDirAbsoluteValue/$m_srcStr" )
5605
    {
5606
        LogError("Failed to locate item [$m_sDirAbsoluteValue/$m_srcStr], link not created.");
5607
    }
5608
 
5609
 
5610
 
5611
    my ($cmd) = "cd $m_sDirAbsoluteValue; ln -s $m_srcStr $m_linkStr";
5612
    system("$cmd");
5613
    if ( $? != 0 )
5614
    {
5615
        LogError("Failed to complete command: [$cmd]");
5616
    }
5617
    else
5618
    {
5619
        LogNorm("Executed command: [$cmd]");
5620
    }
5621
 
5622
    return 1;
5623
}
5624
 
5625
 
5626
#------------------------------------------------------------------------------
5627
sub createPrototypeFile2
5628
#
5629
# Description:
5630
#       This sub-routine is used to create the required package prototype file
5631
#       fom a known directory struture using the a=b format.
5632
#
5633
#------------------------------------------------------------------------------
5634
{
5635
    # correct number of parameters?
5636
    if ( ($#_+1) != 3 )
5637
    {
5638
        LogError("Incorrect number of params passed to " .
5639
                  "createPrototypeFile2() function. Check deploy config.");
5640
    }
5641
 
5642
    # lets just check to see if we can execute this function on
5643
    # this machine.
5644
    #
5645
    if ( "$MachType" ne "sparc" )
5646
    {
5647
        LogInfo("createPrototypeFile2() not supported on this machine type.");
5648
        return 1;
5649
    }
5650
 
5651
    # lets take the passed in args.
5652
    my ($uid, $gid, $mask) = @_;
5653
 
5654
 
5655
    # we need to determine whiich file we are dealing with
5656
    my ($protoTypeFile);
5657
    my ($targetBaseDir);
5658
    my ($pkgBaseDir);
5659
    $protoTypeFile = "$ProtoTypeFile"; 
5660
    $targetBaseDir = "$PkgBaseDir/$TargetBaseDir"; 
5661
    $pkgBaseDir    = "$PkgBaseDir"; 
5662
 
5663
 
5664
    # we need to locate the prototype file
5665
    if ( -f "$protoTypeFile" )
5666
    {
5667
        unlink("$protoTypeFile");
5668
        LogInfo("Removing prototype file [$protoTypeFile].");
5669
    }
5670
 
5671
    # lets open the prototype file.
5672
    #    
5673
    local *FILE;
5674
    open ( FILE, "> $protoTypeFile") or
5675
        LogError("Failed to open file [$protoTypeFile].");
5676
    # lets populate the prototype file.
5677
    printf FILE ("!default $mask $uid $gid\n");
5678
    printf FILE ("i pkginfo\n");
5679
    close (FILE);
5680
 
5681
 
5682
    # lets put the pre-deinfed generic entries into the
5683
    # prototype file
5684
    #
5685
    if ( "x$PkgPatchNum" ne "x" )
5686
    {
5687
        addPatchInfo2ProtoTypeFile();
5688
    }
5689
 
5690
 
5691
    # lets set the associated uid, gid and mask
5692
    # for the bits in the prototype file.
5693
    #
5694
    $m_UID  = $uid;
5695
    $m_GID  = $gid;
5696
    $m_MASK = $mask;
5697
 
5698
 
5699
    # now we need to add entries for each directory we will 
5700
    # be installing 
5701
    File::Find::find(\&prototype2Find, "$targetBaseDir");
5702
 
5703
 
5704
    # lets populate the prototype file with a newline.
5705
    open ( FILE, ">> $protoTypeFile") or
5706
        LogError("Failed to open file [$protoTypeFile].");
5707
    printf FILE ("\n");
5708
    close (FILE);
5709
 
5710
 
5711
    LogNorm("Created prototype file [$protoTypeFile].");
5712
 
5713
    return 1;
5714
}
5715
 
5716
 
5717
#------------------------------------------------------------------------------
5718
sub prototype2Find
5719
#
5720
#    Description:
5721
#        This subroutine is used to locate all associated package dirs.
5722
#        It also adds an entry into the prototype file for each dir.
5723
#
5724
#------------------------------------------------------------------------------
5725
{
5726
    my($file)= "$File::Find::name";
5727
    my($base)= File::Basename::basename($file);
5728
 
5729
    # we get the absolute path from the find, but we only require
5730
    # a relative path from the starting dir.
5731
    # so our start dir.
5732
 
5733
    # we need to determine which file we are dealing with
5734
    my ($pfile);
5735
    my ($tDir);
5736
    $pfile = "$ProtoTypeFile";
5737
    $tDir = "$PkgBaseDir/$TargetBaseDir";
5738
 
5739
    if ( "$file" ne "$tDir" )
5740
    {
5741
        my ($m_sfile) = $file;
5742
        if ( "x$TargetBaseDir" eq "x." )
5743
        {
5744
            $tDir = $tDir . "/";
5745
            $file =~ s/$tDir//;
5746
        }
5747
        else
5748
        {
5749
            $file =~ s/$tDir/$TargetBaseDir/;
5750
        }
5751
 
5752
        # if TargetBaseDir is "." then find will find the pkginfo & prototype 
5753
        # files so we need to exclude them
5754
        if ( "$file" ne "$ProtoTypeFileName" &&
5755
             "$file" ne "$PkgInfoFileName")
5756
        {
5757
            open ( FILE, ">> $pfile") or
5758
                LogError("Failed to open file [$pfile].");
5759
 
5760
            if ( -f "$m_sfile" )
5761
            {
5762
                printf FILE ("f none $file=$file $m_MASK $m_UID $m_GID\n");
5763
            }
5764
 
5765
            if ( -d "$m_sfile" )
5766
            {
5767
                printf FILE ("d none $file $m_MASK $m_UID $m_GID\n");
5768
            }
5769
 
5770
            close (FILE);
5771
        }
5772
    }
5773
}
5774
 
5775
 
5776
#------------------------------------------------------------------------------
5777
sub convertFile
5778
#
5779
# Description:
5780
#       This sub-routine is used to remove all carrage return\line feeds
5781
#       from a line and replace them with the platform specific equivalent chars.
5782
#
5783
#       We let PERL determine what characters are written to the file base on the 
5784
#       platform you are running on.
5785
#
5786
#
5787
#       i.e. LF    for unix
5788
#            CR\LF for win32
5789
#
5790
#------------------------------------------------------------------------------
5791
{
5792
   # correct number of parameters?
5793
    if ( ($#_+1) != 2 )
5794
    {
5795
        LogError("Incorrect number of params passed to " .
5796
                  "convertFile() function. Check deploy config.");
5797
    }
5798
    my ($m_targetDirTag, $m_nfile) = @_;
5799
 
5800
 
5801
    # lets get the src dir value
5802
    my ($m_targetDirValue) = getTargetDstDirValue($m_targetDirTag, "A");
5803
 
5804
 
5805
    # this is our file that we want to clean.
5806
    my ($m_ifileLoc) = "$m_targetDirValue/$m_nfile";
5807
    my ($m_tfileLoc) = "$m_targetDirValue/$m_nfile\.tmp";
5808
 
5809
 
5810
    # we will check to see if the file exists.
5811
    #
5812
    local *IFILE;
5813
    local *TFILE;
5814
    if ( -f "$m_ifileLoc" )
5815
    {
5816
        open (IFILE, "< $m_ifileLoc" ) or
5817
            LogError("Failed to open file [$m_ifileLoc] : $!");
5818
 
5819
        open (TFILE, "> $m_tfileLoc" ) or
5820
            LogError("Failed to open file [$m_tfileLoc] : $!");
5821
 
5822
        while ( <IFILE> ) 
5823
        {
5824
            chomp;
5825
            print TFILE "$_\n";
5826
        }
5827
    }
5828
    else
5829
    {
5830
        LogError("Deploy file [$m_ifileLoc] does not exist.");
5831
    }
5832
 
5833
    close IFILE;
5834
    close TFILE;
5835
 
5836
 
5837
    # lets replace our original file with the new one
5838
    #
5839
    if(File::Copy::move("$m_tfileLoc", "$m_ifileLoc"))
5840
    {
5841
        LogNorm("Renamed [$m_tfileLoc] to [$m_ifileLoc] ...");
5842
    }
5843
    else
5844
    {
5845
        LogError("Failed to crename file [$m_tfileLoc] to [$m_ifileLoc]: $!");
5846
    }
5847
 
5848
    return 1;
5849
}
5850
 
5851
 
5852
#------------------------------------------------------------------------------
5853
sub installDeployFile
5854
#
5855
# Description:
5856
#       This sub-routine is used to copy a local deployment file into
5857
#       the target destination dir. 
5858
#
5859
#
5860
#------------------------------------------------------------------------------
5861
{
5862
    # correct number of parameters?
5863
    if ( ($#_+1) != 4 )
5864
    {
5865
        LogError("Incorrect number of params passed to " .
5866
                  "installDeployFile() function. Check deploy config.");
5867
    }
5868
 
5869
    my ($m_srcDirTag, $m_sfile, $m_targetDirTag, $m_nfile) = @_;
5870
 
5871
    # lets get the src dir value
5872
    my ($m_targetDirValue) = getTargetDstDirValue($m_targetDirTag, "A");
5873
 
5874
    # lets get the target dir value
5875
    my ($m_srcDirValue) = getLocalDirValue($m_srcDirTag, "A");
5876
 
5877
 
5878
    # we know where we are getting this from and where we 
5879
    # going to put them.
5880
    my ($m_sfileLoc) = "$m_srcDirValue/$m_sfile";
5881
 
5882
    my ($m_nfileLoc) = "";
5883
    # lets determine what we are going to call the new file.
5884
    #
5885
    if ( "x$m_nfile" eq "x" )
5886
    {
5887
        $m_nfileLoc = "$m_targetDirValue/$m_sfile";
5888
    }
5889
    else
5890
    {
5891
        $m_nfileLoc = "$m_targetDirValue/$m_nfile";
5892
    }
5893
 
5894
 
5895
    # we will check to see if the file exists.
5896
    #
5897
    if ( -f "$m_sfileLoc" )
5898
    {
5899
        # now we need to copy the file. 
5900
        if(File::Copy::copy("$m_sfileLoc", "$m_nfileLoc"))
5901
        {
5902
            LogNorm("Copied [$m_sfile] to [$m_nfileLoc] ...");
5903
 
5904
            # now we need to ensure the item is writable as it
5905
            # has come from our VOB that is by definition read-only
5906
            #
5907
            CORE::chmod oct("0755"), $m_nfileLoc;
5908
 
5909
        }
5910
        else
5911
        {
5912
            LogError("Failed to copy lib [$m_sfileLoc]: $!"); 
5913
        }
5914
    }
5915
    else
5916
    {
5917
        LogError("Deploy file [$m_sfileLoc] does not exist.");
5918
    }
5919
 
5920
    return 1;
5921
}
5922
 
5923
 
5924
#------------------------------------------------------------------------------
5925
sub getGenericNameForLib
5926
#
5927
# Description:
5928
#       This sub-routine is used to determine the generic name for
5929
#       a library. I.E remove the buildtype and version number.
5930
#
5931
#       It also checks if the name provided should be excluded from
5932
#       the build.
5933
#
5934
#------------------------------------------------------------------------------
5935
{
5936
   # correct number of parameters?
5937
    if ( ($#_+1) != 1 )
5938
    {
5939
        LogError("Incorrect number of params passed to " .
5940
                  "getGenericNameForLib() function. Check deploy config.");
5941
    }
5942
 
5943
    # lets just check to see if we can execute this function on
5944
    # this machine.
5945
    #
5946
    if ( "$MachType" ne "sparc" )
5947
    {
5948
        LogInfo("getGenericNameForLib() not supported on this machine type.");
5949
        return "";
5950
    }
5951
 
5952
 
5953
    my($itemName) = @_;
5954
 
5955
    # first we need to check to see if it belongs in this build
5956
    #
5957
    my ($gName) = "";
5958
    if(excludeItemFromBuild($itemName))
5959
    {
5960
        LogInfo("Excluding item [$itemName] from build as not compatible with build type " .
5961
                "[$BuildType].");
5962
        return "";  # file should be excluded.
5963
    }
5964
    else
5965
    {
5966
        $gName = removeBuildTypeFromItemName($itemName);
5967
        $gName = removeVersionNumberFromItemName($gName);
5968
 
5969
        return "$gName";
5970
    }
5971
 
5972
    return 1;
5973
}
5974
 
5975
 
5976
#------------------------------------------------------------------------------
5977
sub getGenericNameNoVersionForLib
5978
#
5979
# Description:
5980
#       This sub-routine is used to determine the generic name for
5981
#       a library. I.E removes the version number.
5982
#
5983
#       It also checks if the name provided should be excluded from
5984
#       the build.
5985
#
5986
#------------------------------------------------------------------------------
5987
{
5988
   # correct number of parameters?
5989
    if ( ($#_+1) != 1 )
5990
    {
5991
        LogError("Incorrect number of params passed to " .
5992
                  "getGenericNameNoVersionForLib() function. Check deploy config.");
5993
    }
5994
 
5995
    # lets just check to see if we can execute this function on
5996
    # this machine.
5997
    #
5998
    if ( "$MachType" ne "sparc" )
5999
    {
6000
        LogInfo("getGenericNameNoVersionForLib() not supported on this machine type.");
6001
        return "";
6002
    }
6003
 
6004
 
6005
    my($itemName) = @_;
6006
 
6007
    # first we need to check to see if it belongs in this build
6008
    #
6009
    my ($gName) = "";
6010
    if(excludeItemFromBuild($itemName))
6011
    {
6012
        LogInfo("Excluding item [$itemName] from build as not compatible with build type " .
6013
                "[$BuildType].");
6014
        return "";  # file should be excluded.
6015
    }
6016
    else
6017
    {
6018
        $gName = removeVersionNumberFromItemName($itemName);
6019
        return "$gName";
6020
    }
6021
 
6022
    return 1;
6023
}
6024
 
6025
 
6026
#------------------------------------------------------------------------------
6027
sub getGenericNameNoVersionForXML
6028
#
6029
# Description:
6030
#       This sub-routine is used to determine the generic name for
6031
#       an XML file. I.E removes the version number.
6032
#
6033
#------------------------------------------------------------------------------
6034
{
6035
   # correct number of parameters?
6036
    if ( ($#_+1) != 1 )
6037
    {
6038
        LogError("Incorrect number of params passed to " .
6039
                  "getGenericNameNoVersionForXML() function. Check deploy config.");
6040
    }
6041
 
6042
    my($itemName) = @_;
6043
    my ($gName) = "";
6044
    $gName = removeVersionNumberFromXMLItemName($itemName);
6045
    return "$gName";
6046
 
6047
    return 1;
6048
}
6049
 
6050
 
6051
#------------------------------------------------------------------------------
6052
sub removeVersionNumberFromXMLItemName
6053
#
6054
#    Description:
6055
#        This sub-routine is used to remove the version number from the item name.
6056
#        i.e.  myFile_1_2_3.xml ==> myFile.xml
6057
#
6058
#    INPUT:
6059
#        item name
6060
#
6061
#    RETURN:
6062
#        new item name.
6063
#
6064
#------------------------------------------------------------------------------
6065
{
6066
    my ($file)  = @_;
6067
    my ($nfile) = $file;
6068
 
6069
    if ( $nfile =~ m/_[0-9]+_[0-9]+_[0-9]+\.xml$/ )
6070
    {
6071
        # if we match lets deal with it.
6072
        $nfile =~ s/_[0-9]+_[0-9]+_[0-9]+\.xml$/\.xml/;
6073
    }
6074
    else
6075
    {
6076
        LogWarn("Filename [$nfile] does not contain required format [myfile_N_N_N.xml].");
6077
    }
6078
    return "$nfile";
6079
}
6080
 
6081
 
6082
#------------------------------------------------------------------------------
6083
sub createDpkgArchive
6084
#
6085
# Description:
6086
#       This sub-routine is used to create a dpkg_archive directory
6087
#       structure.
6088
#
6089
#------------------------------------------------------------------------------
6090
{
6091
    # correct number of parameters?
6092
    if ( ($#_+1) != 1 )
6093
    {
6094
        LogError("Incorrect number of params passed to " .
6095
                  "createDpkgArchive() function. Check deploy config.");
6096
    }
6097
 
6098
    my ($desc) = @_;
6099
 
6100
    # lets just check to see if we can execute this function on
6101
    # for  this build.
6102
    #
6103
    if ( "x$PkgPatchNum" ne "x" )
6104
    {
6105
        LogInfo("createDpkgArchive() can only be called during a RELEASE build.");
6106
        return 1;
6107
    }
6108
 
6109
 
6110
    # 1. we create a dpkg_archive top level dir within the output directory
6111
    #
6112
    my ($m_tmpDir) = "$PkgBaseDir/dpkg_archive";
6113
    if ( ! -d $m_tmpDir )
6114
    {
6115
        mkdir("$m_tmpDir", 0777);
6116
        LogInfo("created [$m_tmpDir] dir...");
6117
    }
6118
 
6119
    # 2. we create a sub-directory with the package name
6120
    #
6121
    $m_tmpDir = "$PkgBaseDir/dpkg_archive/$TargetBaseDir";
6122
    if ( ! -d $m_tmpDir )
6123
    {
6124
        mkdir("$m_tmpDir", 0777);
6125
        LogInfo("created [$m_tmpDir] dir...");
6126
    }
6127
 
6128
    # 3. we create a sub-directory with the package version number
6129
    #
6130
    my ($m_tmpDir2) = "$PkgBaseDir/dpkg_archive/$TargetBaseDir/" .
6131
                      "$PkgVersion" .  "." . "$ProjectAcronym";
6132
    if ( ! -d $m_tmpDir2 )
6133
    {
6134
        mkdir("$m_tmpDir2", 0777);
6135
        LogInfo("created [$m_tmpDir2] dir...");
6136
    }
6137
 
6138
 
6139
    # 4. we replacate the contents of the original outputdir/package name
6140
    #    to do this we shall execute a find starting within the original package target dir
6141
    #    any copy all items we find to the new location under the dpkg_archive/package/version dir.
6142
    #
6143
    File::Find::find( \&DpkgFind, "$PkgBaseDir/$TargetBaseDir");
6144
 
6145
 
6146
    # 5. we create a descpkg file, with the Package Name, Version and Desc
6147
    #
6148
    my ($m_DescPkgFile) = "$PkgBaseDir/dpkg_archive/$TargetBaseDir/$PkgVersion\.$ProjectAcronym/descpkg";
6149
 
6150
    # now we need to update the prototype file
6151
    #
6152
    local *FILE;
6153
    open ( FILE, ">> $m_DescPkgFile") or
6154
        LogError("Failed to open file [$m_DescPkgFile].");
6155
    printf FILE ("$PkgName, $PkgVersion.$ProjectAcronym - $desc\n");
6156
    close (FILE);
6157
 
6158
 
6159
    # done.
6160
    LogNorm("createDpkgArchive() completed.");
6161
 
6162
    return 1;
6163
}
6164
 
6165
 
6166
#------------------------------------------------------------------------------
6167
sub DpkgFind
6168
#
6169
#    Description:
6170
#        This subroutine is used to locate all associated items to
6171
#        create a new dpkg_archive directory structure. 
6172
#
6173
#------------------------------------------------------------------------------
6174
{
6175
    my($item)= "$File::Find::name";
6176
    my($base)= File::Basename::basename($item);
6177
 
6178
 
6179
    # we get the absolute path from the find, but we only require
6180
    # a relative path from the starting dir.
6181
 
6182
 
6183
    # we need to determine which file we are dealing with
6184
    if ( ! -d "$item")
6185
    {
6186
        my ($m_sfile) = $item;
6187
        $item =~ s/$PkgBaseDir\/$TargetBaseDir/$PkgBaseDir\/dpkg_archive\/$TargetBaseDir\/$PkgVersion\.$ProjectAcronym/;
6188
 
6189
        if(File::Copy::copy("$m_sfile", "$item"))
6190
        {
6191
            LogNorm("Copied [$base] to [$item] ...");
6192
        }
6193
        else
6194
        {
6195
            LogError("Failed to copy pkg file [$m_sfile] to [$item]: $!");
6196
        }
6197
    }
6198
    else
6199
    {
6200
        # we have found a dir
6201
        my ($m_sDir) = $item;
6202
        $item =~ s/$PkgBaseDir\/$TargetBaseDir/$PkgBaseDir\/dpkg_archive\/$TargetBaseDir\/$PkgVersion\.$ProjectAcronym/;
6203
 
6204
        # if the dir does not exist lets create it
6205
        # 
6206
        if ( ! -d $item)
6207
        {
6208
            mkdir ( $item, 0777 );
6209
        }
6210
 
6211
    }
6212
}
6213
 
6214
 
6215
 
6216
 
6217
#------------------------------------------------------------------------------
6218
sub getRmDetails
6219
#
6220
#    Description:
6221
#        This is called to update the RM class objects with details from RM database
6222
#------------------------------------------------------------------------------
6223
{
6224
    if ( ! defined($RmPkgDetails) )
6225
    {
6226
        # Set defaults for elements in RM if not found
6227
        DeployUtils::RmPkgInfo->DefaultDescription($PkgDesc);
6228
        DeployUtils::RmPkgInfo->DefaultLabel($PkgLabel);
6229
 
6230
        $RmPkgDetails = DeployUtils::RmPkgInfo->new( 
6231
                                    { PKG_NAME => $PkgName, 
6232
                                      PKG_VERSION => ( "$PkgPatchNum" ne "" ) ? $PkgPatchID : $PkgVersionUser } );
6233
 
6234
        # lets check to see if we got something
6235
        if ( $RmPkgDetails->foundPkg() )
6236
        {
6237
            $RmPvPkgDetails = DeployUtils::RmPkgInfo->new( { PKG_NAME => $PkgName, 
6238
                                                             PKG_VERSION => $PkgPreviousVersionStr } );
6239
            if ( $RmPvPkgDetails->foundDetails() )
6240
            {
6241
                LogNorm("Retrieved Package Details from Release Manager");
6242
                LogInfo("RM pkg_name       = [" . $RmPkgDetails->pkg_name()       . "]");
6243
                LogInfo("RM pkg_id         = [" . $RmPkgDetails->pkg_id()         . "]");
6244
                LogInfo("RM pv_id          = [" . $RmPkgDetails->pv_id()          . "]");
6245
                LogInfo("RM pv_description = [" . $RmPkgDetails->pv_description() . "]");
6246
                LogInfo("RM pv_overview    = [" . $RmPkgDetails->pv_overview()    . "]");
6247
                LogInfo("RM pv_reason      = [" . $RmPkgDetails->pv_reason()      . "]");
6248
                LogInfo("RM pv_label       = [" . $RmPkgDetails->pv_label()       . "]");
6249
                LogInfo("RM previousPv_id  = [" . $RmPvPkgDetails->pv_id()        . "]");
6250
                LogInfo("RM pv_dlocked     = [" . $RmPvPkgDetails->pv_dlocked()   . "]");
6251
            }
6252
            else
6253
            {
6254
                # our package does not exist in release manager
6255
                LogWarn("Could not retrieve package $PkgName $PkgVersionUser previous version " .
6256
                        "details from Release Manager.")
6257
            }
6258
        }
6259
        else
6260
        {
6261
            # our package does not exist in release manager 
6262
            LogWarn("Package $PkgName $PkgVersionUser does not exist in the Release Manager. Please check configuration.") 
6263
        }
6264
    }
6265
}  
6266
 
6267
 
6268
 
6269
# This is now depricated
6270
sub generateReleaseNote
6271
{
6272
    LogError("generateReleaseNote is depricated please use generateHtmlReleaseNote");
6273
    return 1;
6274
}
6275
 
6276
 
6277
 
6278
#------------------------------------------------------------------------------
6279
sub generateHtmlReleaseNote
6280
#
6281
#    Description:
6282
#
6283
#------------------------------------------------------------------------------
6284
{
6285
    #
6286
    #   Ensure the Release directory is present
6287
    #
6288
    if ( ! -d $ReleaseDir )
6289
    {
6290
        mkpath ( $ReleaseDir, 0, 0777);
6291
        LogInfo("created [$ReleaseDir] dir...");
6292
    }
6293
 
6294
    if ( ! getRmReleaseNote() )
6295
    {
6296
        LogNorm("No Release Manager release note, lets attempt to create an internal version");
6297
        if ( $RmPkgDetails->foundPkg() )
6298
        {
6299
            # internal version
6300
            generateInternalHtmlReleaseNote();
6301
        }
6302
        else
6303
        {
6304
            LogWarn("No Release Manager details, release note not generated.");
6305
        }
6306
    }
6307
}
6308
 
6309
 
6310
 
6311
#------------------------------------------------------------------------------
6312
sub getRmReleaseNote
6313
#
6314
#    Description:
6315
#
6316
#------------------------------------------------------------------------------
6317
{
6318
    # lets get some details for our package
6319
    getRmDetails();
6320
 
6321
 
6322
    # now we need to ensure that our local build file dependencies are
6323
    # the same as those we have entered in the Release Manager database.
6324
    checkDependencies();
6325
 
6326
 
6327
    # let's update the release contents now
6328
    #
6329
    generateProductContents();
6330
 
6331
 
6332
    LogNorm("Retrieving Release Notes From Release Manager...Please wait...");
6333
 
6334
    my $user_agent = LWP::UserAgent->new( timeout => 30 );
6335
    my $response = $user_agent->get('http://erg:8002/ManagerSuite/Release_Manager/_adhoc_release_notes.asp?pv_id='. $RmPkgDetails->pv_id(), 
6336
                                    ':content_file' => "$PkgReleaseNote\.html");
6337
    if ( $response->is_success )
6338
    {
6339
        LogNorm("Retrieved Release Manager HTML Release note [$PkgReleaseNote\.html]");
6340
        return 1;
6341
    }
6342
    else
6343
    {
6344
        LogWarn("Unable to retrieve Release Manager Release Notes");
6345
        return 0;
6346
    }
6347
}
6348
 
6349
 
6350
 
6351
#------------------------------------------------------------------------------
6352
sub generateInternalHtmlReleaseNote
6353
#
6354
#    Description:
6355
#        This subroutine is used to generate a simple release note in HTML format 
6356
#        for the package.
6357
#
6358
#        The function populates various sections of the release note 
6359
#        with details that are available at the time of execution 
6360
#        and it also creates blank sections to be populated later by the user
6361
#        when the information is available.
6362
#
6363
#------------------------------------------------------------------------------
6364
{
6365
    # correct number of parameters?
6366
    if ( ($#_+1) != 0 )
6367
    {
6368
        LogError("Incorrect number of params passed to " .
6369
                  "generateReleaseNote2() function. Check deploy config.");
6370
    }
6371
 
6372
 
6373
    local *FILE;
6374
    open ( FILE, "> $PkgReleaseNote\.html") or
6375
        LogError("Failed to open file [$PkgReleaseNote\.html].");
6376
 
6377
 
6378
    my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
6379
    my $dateStr = sprintf ("%04u-%02u-%02u", $year + 1900, $mon+1, $mday);
6380
    my $timeStr = sprintf ("%02u:%02u:%02u", $hour, $min, $sec);
6381
    my ($i);
6382
 
6383
    # lets check to see if our package desc field has been set
6384
    #
6385
    if ( "$PkgDesc" eq "" )
6386
    {
6387
        LogError("Package description not set. Use setPkgDescription('my description') function.");
6388
    }
6389
 
6390
 
6391
    # lets get some details for our package
6392
    getRmDetails();
6393
 
6394
    # now we need to ensure that our local build file dependencies are
6395
    # the same as those we have entered in the Release Manager database.
6396
    checkDependencies();
6397
 
6398
 
6399
    print FILE ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\n");                            
6400
    print FILE ("    \"http://www.w3.org/TR/html4/loose.dtd\">\n");                            
6401
 
6402
    print FILE ("<html>\n");
6403
    print FILE ("<head>\n");                       
6404
 
6405
    print FILE ("<title>Software Release Note: " .
6406
                 "$PkgName $PkgVersion.$ProjectAcronym</title>\n");
6407
 
6408
    print FILE ("</head>\n");
6409
    print FILE ("<body>\n");                                                                          
6410
    print FILE ("<h1><font face=\"Arial\">Software Release Note</h1>\n");     
6411
 
6412
 
6413
    print FILE ("<hr>\n");                          
6414
    print FILE ("<h2><font face=\"Arial\">Identification</h2>\n");
6415
 
6416
    print FILE ("<table width=\"100%\" >\n");
6417
 
6418
    print FILE ("<tr>\n");
6419
    print FILE ("\t<td colspan=\"2\"><font face=\"Arial\">This release can be uniquely identified by,</font></td>\n");
6420
    print FILE ("</tr>\n");
6421
 
6422
    print FILE ("<tr>\n");
6423
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Name:</b></font></td>\n");
6424
    print FILE ("\t<td width=\"80%\"><font face=\"Arial\">" . $RmPkgDetails->pkg_name() . "</font></td>\n");
6425
    print FILE ("</tr>\n");
6426
 
6427
    print FILE ("<tr>\n");
6428
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Description:</b></font></td>\n");
6429
    print FILE ("\t<td width=\"80%\"><font face=\"Arial\">" . $RmPkgDetails->pv_description() . "</font></td>\n");
6430
    print FILE ("</tr>\n");
6431
 
6432
    print FILE ("<tr>\n");
6433
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Version:</b></font></td>\n");
6434
    print FILE ("\t<td width=\"80%\"><font face=\"Arial\">" . 
6435
                "$PkgVersion.$ProjectAcronym" . "</font></td>\n");
6436
    print FILE ("</tr>\n");
6437
 
6438
    print FILE ("<tr>\n");
6439
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Platform:</b></font></td>\n");
6440
    print FILE ("\t<td width=\"80%\"><font face=\"Arial\">$MachType</font></td>\n");
6441
    print FILE ("</tr>\n");
6442
 
6443
    print FILE ("<tr>\n");
6444
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>PkgLabel:</b></font></td>\n");
6445
    print FILE ("\t<td width=\"80%\"><font face=\"Arial\">$PkgLabel</font></td>\n");
6446
    print FILE ("</tr>\n");
6447
 
6448
    print FILE ("<tr>\n");
6449
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Date:</b></font></td>\n");
6450
    print FILE ("\t<td width=\"80%\"><font face=\"Arial\">$dateStr $timeStr</font></td>\n");
6451
    print FILE ("</tr>\n");
6452
 
6453
    print FILE ("<tr>\n");
6454
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Correspondence No:</b></font></td>\n");
6455
    print FILE ("\t<td width=\"80%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6456
    print FILE ("</tr>\n");
6457
    print FILE ("</table>\n");
6458
 
6459
 
6460
    print FILE ("<hr>\n");                          
6461
    print FILE ("<h2><font face=\"Arial\">Package Overview</h2>\n");
6462
 
6463
    print FILE ("<table width=\"100%\">\n");
6464
    print FILE ("<tr>\n");
6465
    print FILE ("\t<td width=\"100%\"><font face=\"Arial\">" . $RmPkgDetails->pv_overview() . "</font></td>\n");
6466
    print FILE ("</tr>\n");
6467
    print FILE ("</table>\n");
6468
    print FILE ("<br>\n");                          
6469
 
6470
 
6471
    print FILE ("<hr>\n");                          
6472
    print FILE ("<h2><font face=\"Arial\">Release Summary</h2>\n");
6473
 
6474
    print FILE ("<table width=\"100%\">\n");
6475
    print FILE ("<tr>\n");
6476
    print FILE ("\t<td width=\"100%\"><font face=\"Arial\">Reason for this release,</font></td>\n");
6477
    print FILE ("</tr>\n");
6478
    print FILE ("<tr>\n");
6479
    print FILE ("\t<td width=\"100%\"><font face=\"Arial\">" . $RmPkgDetails->pv_reason() . "</font></td>\n");
6480
    print FILE ("</tr>\n");
6481
    print FILE ("</table>\n");
6482
 
6483
 
6484
    # here we will list any issues that have been associated with
6485
    # the package
6486
    #
6487
    print FILE ("<br>\n");
6488
 
6489
    my ($j);
6490
    my ($k);
6491
    my ($m_str) = "";
6492
    foreach $i ( $RmPkgDetails->getIssueTypes() )
6493
    {
6494
        print FILE ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" " .
6495
                    "bordercolordark=\"White\" bordercolorlight=\"Black\">\n");
6496
 
6497
        print FILE ("<tr>\n");
6498
        print FILE ("<td colspan=\"6\"><font face=\"Arial\"><b>Issues - $i</b></font></td>\n");
6499
        print FILE ("</tr>\n");
6500
 
6501
        print FILE ("<tr>\n");
6502
        print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Fixed</b></font></td>\n");
6503
        print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Issue Id</b></font></td>\n");
6504
        print FILE ("\t<td width=\"50%\"><font face=\"Arial\"><b>Summary</b></font></td>\n");
6505
        print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Issue Type</b></font></td>\n");
6506
        print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Status</b></font></td>\n");
6507
        print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Priority</b></font></td>\n");
6508
        print FILE ("</tr>\n");
6509
 
6510
        foreach $j ( $RmPkgDetails->getIssueNumbers($i) )
6511
        {
6512
            print FILE ("<tr>\n");
6513
            if (  $RmPkgDetails->iss_state($i, $j) == 1 )
6514
            {
6515
                $m_str = "Yes";
6516
            }
6517
            else
6518
            {
6519
                $m_str = "No";
6520
            }
6521
 
6522
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\">$m_str</font></td>\n");
6523
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $RmPkgDetails->iss_numStr($i, $j)   . "</font></td>\n");
6524
            print FILE ("\t<td width=\"50%\"><font face=\"Arial\">" . $RmPkgDetails->iss_summary($i, $j)  . "</font></td>\n");
6525
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $RmPkgDetails->iss_type($i, $j)     . "</font></td>\n");
6526
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $RmPkgDetails->iss_status($i, $j)   . "</font></td>\n");
6527
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $RmPkgDetails->iss_priority($i, $j) . "</font></td>\n");
6528
            print FILE ("</tr>\n");
6529
        }
6530
        print FILE ("</table>\n");
6531
    }
6532
 
6533
    print FILE ("<hr>\n");                          
6534
    print FILE ("<h2><font face=\"Arial\">Build Dependencies</h2>\n");
6535
 
6536
    print FILE ("<table width=\"100%\">\n");
6537
    print FILE ("<tr>\n");
6538
    print FILE ("\t<td width=\"100%\"><font face=\"Arial\">The release was built with the following " .
6539
                "\"dpkg_archive\" modules,</font></td>\n");
6540
    print FILE ("</tr>\n");
6541
    print FILE ("</table>\n");
6542
    print FILE ("<br>\n");
6543
 
6544
    my $depObj;
6545
 
6546
    foreach $i ( $RmPkgDetails->getDependencyNames() )
6547
    {
6548
        $depObj = $RmPkgDetails->getDependencyObject($i); 
6549
 
6550
        print FILE ("<h4><font face=\"Arial\">" . $depObj->pkg_name() . " - " . $depObj->pkg_version() . "</h4>\n");
6551
 
6552
        print FILE ("<tr>\n");
6553
        print FILE ("\t<td width=\"100%\"><font face=\"Arial\">Reason for this release,</font></td>\n");
6554
        print FILE ("</tr>\n");
6555
        print FILE ("<tr>\n");
6556
        print FILE ("\t<td width=\"100%\"><font face=\"Arial\">" . $depObj->pv_reason() . "</font></td>\n");
6557
        print FILE ("</tr>\n");
6558
        print FILE ("</table>\n");
6559
        print FILE ("<br><br>\n"); 
6560
 
6561
        foreach $j ( $depObj->getIssueTypes() )
6562
        {
6563
            print FILE ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" " .
6564
                        "bordercolordark=\"White\" bordercolorlight=\"Black\">\n");
6565
 
6566
            print FILE ("<tr>\n");
6567
            print FILE ("<td colspan=\"6\"><font face=\"Arial\"><b>Issues - $j</b></font></td>\n");
6568
            print FILE ("</tr>\n");
6569
 
6570
            print FILE ("<tr>\n");
6571
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Fixed</b></font></td>\n");
6572
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Issue Id</b></font></td>\n");
6573
            print FILE ("\t<td width=\"50%\"><font face=\"Arial\"><b>Summary</b></font></td>\n");
6574
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Issue Type</b></font></td>\n");
6575
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Status</b></font></td>\n");
6576
            print FILE ("\t<td width=\"10%\"><font face=\"Arial\"><b>Priority</b></font></td>\n");
6577
            print FILE ("</tr>\n");
6578
 
6579
            foreach $k ( $depObj->getIssueNumbers($j) )
6580
            {
6581
                if ( $depObj->iss_state($j, $k) == 1 )
6582
                {  
6583
                    $m_str = "Yes";
6584
                }
6585
                else
6586
                {
6587
                    $m_str = "No";
6588
                }
6589
                print FILE ("\t<td width=\"10%\"><font face=\"Arial\">$m_str</font></td>\n");
6590
 
6591
                print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $depObj->iss_numStr($j, $k)   . "</font></td>\n");
6592
                print FILE ("\t<td width=\"50%\"><font face=\"Arial\">" . $depObj->iss_summary($j, $k)  . "</font></td>\n");
6593
                print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $depObj->iss_type($j, $k)     . "</font></td>\n");
6594
                print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $depObj->iss_status($j, $k)   . "</font></td>\n");
6595
                print FILE ("\t<td width=\"10%\"><font face=\"Arial\">" . $depObj->iss_priority($j, $k) . "</font></td>\n");
6596
                print FILE ("</tr>\n");
6597
 
6598
            }
6599
            print FILE ("</table>\n"); 
6600
            print FILE ("<br><br>\n"); 
6601
        }
6602
        print FILE ("</table>\n"); 
6603
    }
6604
 
6605
 
6606
    print FILE ("<hr>\n");                          
6607
    print FILE ("<h2><font face=\"Arial\">System (Runtime) Dependencies</h2>\n");
6608
 
6609
    print FILE ("<table width=\"100%\">\n");
6610
    print FILE ("<tr>\n");
6611
    print FILE ("\t<td width=\"100%\"><font face=\"Arial\">The release is dependent and requires the presence of the " .
6612
                "following modules to operate correctly,</font></td>\n");
6613
    print FILE ("</tr>\n");
6614
    print FILE ("</table>\n");
6615
    print FILE ("<br>\n");
6616
 
6617
 
6618
    print FILE ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" " .
6619
                "bordercolordark=\"White\" bordercolorlight=\"Black\">\n");
6620
 
6621
    print FILE ("<tr>\n");
6622
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Package</b></font></td>\n");
6623
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Version</b></font></td>\n");
6624
    print FILE ("\t<td width=\"60%\"><font face=\"Arial\"><b>Comments</b></font></td>\n");
6625
    print FILE ("</tr>\n");
6626
 
6627
    my ($count) = 0;
6628
    foreach $i ( $RmPkgDetails->getRtDepNames() )
6629
    {
6630
        print FILE ("<tr>\n");
6631
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">$i</font></td>\n");
6632
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">" . $RmPkgDetails->rt_version($i)  . "</font></td>\n");
6633
        print FILE ("\t<td width=\"60%\"><font face=\"Arial\">" . $RmPkgDetails->rt_comments($i) . "</font></td>\n");
6634
        print FILE ("</tr>\n");
6635
        $count++;
6636
    }
6637
    # if we have no RTDs lets add an empty row.
6638
    if ( $count == 0 )
6639
    {
6640
        print FILE ("<tr>\n");
6641
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">&nbsp</font></td>\n");
6642
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">&nbsp</font></td>\n");
6643
        print FILE ("\t<td width=\"60%\"><font face=\"Arial\">&nbsp</font></td>\n");
6644
        print FILE ("</tr>\n");
6645
    }
6646
    print FILE ("</table>\n");
6647
 
6648
 
6649
 
6650
    print FILE ("<hr>\n");                          
6651
    print FILE ("<h2><font face=\"Arial\">Files</h2>\n");
6652
 
6653
    print FILE ("<table width=\"100%\">\n");
6654
    print FILE ("<tr>\n");
6655
    print FILE ("\t<td width=\"100%\">\n");
6656
    print FILE ("\t\t<p><font face=\"Arial\">This release contains the following files,</font></p>\n");
6657
    print FILE ("\t\t<p><font face=\"Arial\">(Note: checksums are derived using,</font></p>\n");
6658
    print FILE ("\t\t<ul>\n");
6659
 
6660
    print FILE ("\t\t\t<li><font face=\"Arial\">The /usr/bin/cksum utility provided by the Solaris ".
6661
          "8 operating system, or</font></li>\n");
6662
 
6663
    print FILE ("<li><font face=\"Arial\">The ~/core_devl/BIN.win32/cksum.exe utility provided ". 
6664
          "by the ERG JATS build tools.)</font></li>\n");
6665
 
6666
    print FILE ("\t\t</ul>\n");
6667
    print FILE ("\t</td>\n");
6668
    print FILE ("</tr>\n");
6669
    print FILE ("</table>\n");
6670
 
6671
    print FILE ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" " .
6672
                "bordercolordark=\"White\" bordercolorlight=\"Black\">\n");
6673
    print FILE ("<tr>\n");
6674
    print FILE ("\t<td width=\"60%\"><font face=\"Arial\"><b>Name</b></font></td>\n");
6675
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Size</b></font></td>\n");
6676
    print FILE ("\t<td width=\"20%\"><font face=\"Arial\"><b>Checksum</b></font></td>\n");
6677
    print FILE ("</tr>\n");
6678
 
6679
    my ($m_cksum, $m_size, $m_rest) = "";
6680
    if ( "$MachType" eq "sparc" )
6681
    {
6682
        my $retStr = `cksum $PkgBaseDir/$PkgOutputFile\.gz`;
6683
        chomp($retStr);
6684
 
6685
        $retStr =~ s/\s+/ /g;
6686
        ($m_cksum, $m_size, $m_rest) = split / /,$retStr;
6687
 
6688
        $m_cksum =~ s/\s+//g;
6689
        $m_size  =~ s/\s+//g;
6690
 
6691
        print FILE ("<tr>\n");
6692
        print FILE ("\t<td width=\"60%\"><font face=\"Arial\">$PkgOutputFile\.gz</font></td>\n");
6693
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">$m_size (bytes)</font></td>\n");
6694
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">$m_cksum</font></td>\n");
6695
        print FILE ("</tr>\n");
6696
    }
6697
    else
6698
    {
6699
        print FILE ("<tr>\n");
6700
        print FILE ("\t<td width=\"60%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6701
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6702
        print FILE ("\t<td width=\"20%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6703
        print FILE ("</tr>\n");
6704
    }
6705
    print FILE ("</table>\n");
6706
 
6707
    print FILE ("<hr>\n");                          
6708
    print FILE ("<h2><font face=\"Arial\">Installation Instructions</h2>\n");
6709
 
6710
    print FILE ("<table width=\"100%\">\n");
6711
    print FILE ("<tr>\n");
6712
    print FILE ("\t<td width=\"100%\"><font face=\"Arial\">Please follow the instructions described below " .
6713
                "when attempting to install the package,</font></td>\n");
6714
    print FILE ("</tr>\n");
6715
    print FILE ("</table>\n");
6716
 
6717
    print FILE ("<br>\n");
6718
 
6719
    print FILE ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" " .
6720
                "bordercolordark=\"White\" bordercolorlight=\"Black\">\n");
6721
    if ( "$MachType" eq "sparc" )
6722
    {
6723
        print FILE ("<tr>\n");
6724
        print FILE ("\t<td width=\"5%\"><font face=\"Arial\"><b>1.</b></font></td>\n");
6725
        print FILE ("\t<td width=\"95%\"><font face=\"Arial\">" .
6726
                    "Ensure the previous package has been removed by using the " .
6727
                    "\'pkginfo -l $PkgName\' command. " .
6728
                    "If the command returns that a package is cuurently installed you will " . 
6729
                    "need to remove it by executing the \'pkgrm $PkgName\' command. " .
6730
                    "</font></td>\n");
6731
        print FILE ("</tr>\n");
6732
 
6733
        print FILE ("<tr>\n");
6734
        print FILE ("\t<td width=\"5%\"><font face=\"Arial\"><b>2.</b></font></td>\n");
6735
        print FILE ("\t<td width=\"95%\"><font face=\"Arial\">" .
6736
                    "Copy the new package \'$PkgOutputFile\.gz\' into the " .
6737
                    "'/tmp' directory as the 'root' user. " .
6738
                    "Uncompress the package (i.e. \'gzip -d $PkgOutputFile\.gz\')." .
6739
                    "</font></td>\n");
6740
        print FILE ("</tr>\n");
6741
 
6742
        print FILE ("<tr>\n");
6743
        print FILE ("\t<td width=\"5%\"><font face=\"Arial\"><b>3.</b></font></td>\n");
6744
        print FILE ("\t<td width=\"95%\"><font face=\"Arial\">" .
6745
                    "Install the package as the 'root' user (i.e. execute the following command " .
6746
                    "\'pkgadd -d $PkgOutputFile\'), providing all the information " . 
6747
                    "required during the package install." .
6748
                    "</font></td>\n");
6749
        print FILE ("</tr>\n");
6750
    }
6751
    else
6752
    {
6753
        print FILE ("<tr>\n");
6754
        print FILE ("\t<td width=\"5%\"><font face=\"Arial\"><b>1.</b></font></td>\n");
6755
        print FILE ("\t<td width=\"95%\"><font face=\"Arial\">" .
6756
                    "Ensure the previous package has been removed by using the Add-Remove " .
6757
                    "programs option in the Control Panel. " .
6758
                    "</font></td>\n");
6759
        print FILE ("</tr>\n");
6760
 
6761
        print FILE ("<tr>\n");
6762
        print FILE ("\t<td width=\"5%\"><font face=\"Arial\"><b>2.</b></font></td>\n");
6763
        print FILE ("\t<td width=\"95%\"><font face=\"Arial\">" .
6764
                    "Copy the installer into the /temp directory as a user with Administrator " .
6765
                    "privileges." .
6766
                    "</font></td>\n");
6767
        print FILE ("</tr>\n");
6768
 
6769
        print FILE ("<tr>\n");
6770
        print FILE ("\t<td width=\"5%\"><font face=\"Arial\"><b>3.</b></font></td>\n");
6771
        print FILE ("\t<td width=\"95%\"><font face=\"Arial\">" .
6772
                    "Execute the package and follow the prompts." .
6773
                    "</font></td>\n");
6774
        print FILE ("</tr>\n");
6775
 
6776
    }
6777
    print FILE ("</table>\n");
6778
 
6779
 
6780
    print FILE ("<hr>\n");                          
6781
    print FILE ("<h2><font face=\"Arial\">Additional Notes</h2>\n");
6782
    print FILE ("<p><font face=\"Arial\">None</p>\n");
6783
 
6784
 
6785
    print FILE ("<hr>\n");                          
6786
    print FILE ("<h2><font face=\"Arial\">Dependency History</h2>\n");
6787
 
6788
 
6789
    # lets check to see if we got something
6790
    if ( $RmPkgDetails->foundPkg() )
6791
    {
6792
        if ( $RmPvPkgDetails->foundDetails() != 0 && $RmPvPkgDetails->pv_id() != $RmPkgDetails->pv_id() )
6793
        {
6794
            print FILE ("<table width=\"100%\">\n");
6795
            print FILE ("<tr>\n");
6796
            print FILE ("\t<td width=\"100%\"><font face=\"Arial\">The table below describes the differences between " .
6797
                        "$PkgName $PkgVersionUser and " .
6798
                        "$PkgPreviousVersionStr,</font></td>\n");
6799
            print FILE ("</tr>\n");
6800
            print FILE ("</table>\n");
6801
            print FILE ("<br>\n");
6802
 
6803
 
6804
            print FILE ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" " .
6805
                        "bordercolordark=\"White\" bordercolorlight=\"Black\">\n");
6806
 
6807
            print FILE ("<tr>\n");
6808
            print FILE ("\t<td width=\"30%\"><font face=\"Arial\"><b>Dependency</b></font></td>\n");
6809
            print FILE ("\t<td width=\"30%\"><font face=\"Arial\"><b>Status</b></font></td>\n");
6810
            print FILE ("\t<td width=\"40%\"><font face=\"Arial\"><b>Previous Version</b></font></td>\n");
6811
            print FILE ("</tr>\n");
6812
 
6813
            my $PvDepObj;
6814
            foreach $i ( $RmPkgDetails->getDependencyNames() )
6815
            {
6816
                $PvDepObj = $RmPvPkgDetails->getDependencyObject($i);
6817
 
6818
                if ( defined($PvDepObj) )
6819
                {
6820
                    if ( $PvDepObj->pkg_version() ne $RmPkgDetails->getDependencyObject($i)->pkg_version() )
6821
                    {
6822
                        print FILE ("<tr>\n");
6823
                        print FILE ("\t<td width=\"30%\"><font face=\"Arial\">$i</font></td>\n");
6824
                        print FILE ("\t<td width=\"30%\"><font face=\"Arial\">Updated</font></td>\n");
6825
                        print FILE ("\t<td width=\"40%\"><font face=\"Arial\">" . $PvDepObj->pkg_version() . "</font></td>\n");
6826
                        print FILE ("</tr>\n");
6827
                    }
6828
                }
6829
                else
6830
                {
6831
                    print FILE ("<tr>\n");
6832
                    print FILE ("\t<td width=\"30%\"><font face=\"Arial\">$i</font></td>\n");
6833
                    print FILE ("\t<td width=\"30%\"><font face=\"Arial\">New</font></td>\n");
6834
                    print FILE ("\t<td width=\"40%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6835
                    print FILE ("</tr>\n");
6836
                }
6837
            }
6838
            print FILE ("</table>\n"); 
6839
        }
6840
        else
6841
        {
6842
            print FILE ("<p><font face=\"Arial\">No history available.</p>\n");
6843
        }
6844
    }
6845
 
6846
 
6847
    print FILE ("<hr>\n");                          
6848
    print FILE ("<h2><font face=\"Arial\">Approval</h2>\n");
6849
 
6850
    print FILE ("<table width=\"100%\">\n");
6851
    print FILE ("<tr>\n");
6852
    print FILE ("\t<td colspan=\"4\"><font face=\"Arial\">This release requires the signature of the " .
6853
                "following persons for approval,</font></td>\n");
6854
    print FILE ("</tr>\n");
6855
    print FILE ("</table>\n");
6856
    print FILE ("<br>\n");
6857
 
6858
 
6859
    print FILE ("<table width=\"100%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" " .
6860
                "bordercolordark=\"White\" bordercolorlight=\"Black\">\n");
6861
 
6862
    print FILE ("<tr>\n");
6863
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\"><b>Tile</b></font></td>\n");
6864
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\"><b>Name</b></font></td>\n");
6865
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\"><b>Signature</b></font></td>\n");
6866
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\"><b>Date</b></font></td>\n");
6867
    print FILE ("</tr>\n");
6868
 
6869
    print FILE ("<tr>\n");
6870
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">Software Engineer</font></td>\n");
6871
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">$Username</font></td>\n");
6872
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6873
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">$dateStr</font></td>\n");
6874
    print FILE ("</tr>\n");
6875
 
6876
    print FILE ("<tr>\n");
6877
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">Team Leader</font></td>\n");
6878
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6879
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6880
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6881
    print FILE ("</tr>\n");
6882
 
6883
    print FILE ("<tr>\n");
6884
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">Manager</font></td>\n");
6885
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6886
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">&nbsp;</b></font></td>\n");
6887
    print FILE ("\t<td width=\"25%\"><font face=\"Arial\">&nbsp;</font></td>\n");
6888
    print FILE ("</tr>\n");
6889
 
6890
    print FILE ("</table>\n");
6891
 
6892
 
6893
    print FILE ("</head>\n");
6894
    print FILE ("</body>\n");
6895
    printf FILE ("</html>\n");
6896
 
6897
    # done.
6898
    close FILE;
6899
 
6900
    LogNorm("Generated HTML Release note [$PkgReleaseNote\.html]");
6901
    return 1;
6902
}
6903
 
6904
 
6905
#------------------------------------------------------------------------------
6906
sub checkDependencies
6907
#
6908
#------------------------------------------------------------------------------
6909
{
6910
    my ($i);
6911
    my ($retValue) = 0;
6912
 
6913
    # first we want to loop through all our local build archives
6914
    # 
6915
    my ($versionStr) = "";
6916
    foreach $i ( $BuildFileInfo->getDpkgArchiveList() )
6917
    {
6918
        if (       "$i" eq "ishieldlibimg"
6919
                || "$i" eq "ishieldlibicon"
6920
                || "$i" eq "ishieldmodules"
6921
                || "$i" eq "deployfiles" )
6922
        {
6923
            # these three packages are a special case,
6924
            # we do not include them in the dependecy check
6925
            #
6926
            # This is BAD and should be removed.
6927
            # We do have a dependancy ! Lets be honest about it.
6928
            #
6929
            next;
6930
        }
6931
 
6932
        my $moduleInfo = $BuildFileInfo->getDpkgArchiveInfo($i);
6933
 
6934
        $versionStr = "$moduleInfo->{version}"; 
6935
        $versionStr .= "\.$moduleInfo->{proj}" if ( $moduleInfo->{proj} ne "" );
6936
        my $depObj = $RmPkgDetails->getDependencyObject($i);
6937
 
6938
        if ( defined ( $depObj ) )
6939
        {
6940
            if ( $depObj->pkg_version() ne "$versionStr" )
6941
            {
6942
                LogWarn("Dependency difference, [$i] local version $versionStr, RM version " . $depObj->pkg_version());
6943
                $retValue = 1;
6944
            }
6945
        }  
6946
        else
6947
        {
6948
            LogWarn("Dependency difference, cannot locate archive [$i] in Release Manager database.");
6949
            $retValue = 1;
6950
        }
6951
    }
6952
 
6953
    # lets check to see if we detected a difference 
6954
    if ( $retValue != 0 )
6955
    { 
6956
        LogError("Difference detected between the local build.pl and Release Manager config. " .
6957
                 "Please check Release Manager configuration.");
6958
    }
6959
 
6960
 
6961
 
6962
    # now we check release manager details against our local ones
6963
    #
6964
    foreach $i ( $RmPkgDetails->getDependencyNames() )
6965
    {
6966
        if ( "$i" eq "ishieldlibimg" || "$i" eq "ishieldlibicon" )
6967
        {
6968
            # these two packages are a special case,
6969
            # we do not include them in the dependecy check
6970
            #
6971
            next;
6972
        }
6973
 
6974
        my $moduleInfo = $BuildFileInfo->getDpkgArchiveInfo($i);
6975
 
6976
        if ( defined ( $moduleInfo ) )
6977
        {
6978
            $versionStr = "$moduleInfo->{version}"; 
6979
            $versionStr .= "\.$moduleInfo->{proj}" if ( $moduleInfo->{proj} ne "" );
6980
            my $depObj = $RmPkgDetails->getDependencyObject($i);
6981
 
6982
            if ( $depObj->pkg_version() ne "$versionStr" )
6983
            {
6984
                LogWarn("Dependency difference, [$i] local version $versionStr, RM version " . $depObj->pkg_version());
6985
                $retValue = 1;
6986
            }
6987
        }  
6988
        else
6989
        {
6990
            LogWarn("Dependency difference, cannot locate archive [$i] in local build.pl.");
6991
            $retValue = 1;
6992
        }
6993
    }
6994
 
6995
    # lets check to see if we detected a difference 
6996
    if ( $retValue != 0 )
6997
    { 
6998
        LogError("Difference detected between Release Manager config and the local build.pl. " .
6999
                 "Please check the local configuration.");
7000
    }
7001
 
7002
    return 1;
7003
}
7004
 
7005
 
7006
 
7007
#------------------------------------------------------------------------------
7008
sub createPerlSvcWin32
7009
#
7010
# Description:
7011
#       This sub-routine is used to create a Win32  service 
7012
#       using a PERL script as the input.
7013
#
7014
#       note we assume here that you have installed ther ActiveState PERL
7015
#       developement KIT and have also installed a valid license key.
7016
#
7017
#------------------------------------------------------------------------------
7018
{
7019
    # lets just check to see if we can execute this function on
7020
    # this machine.
7021
    #
7022
    if ( "$MachType" ne "win32" )
7023
    {
7024
        LogNorm("createPerlSvcWin32() not supported on this machine type.");
7025
        return 1;
7026
    }
7027
 
7028
 
7029
    my ($m_srcDirTag, $m_sfile, $m_targetDirTag, $m_ofile, @m_libDirTags) = @_;
7030
 
7031
 
7032
    # lets get the src dir value
7033
    my ($m_targetDirValue) = getTargetDstDirValue($m_targetDirTag, "A");
7034
 
7035
 
7036
    # lets get the lib src dir value
7037
    my (@m_libDirValue) = ();
7038
    my $i;
7039
    my ($_libStr) = "";
7040
    foreach $i ( 0 .. $#m_libDirTags )
7041
    {
7042
        $m_libDirValue[$i] = getLocalDirValue($m_libDirTags[$i], "A");
7043
        $_libStr = $_libStr . "$m_libDirValue[$i];"
7044
    }
7045
    if ( -d $DpkgScriptsDir )
7046
    {
7047
        $_libStr = $_libStr . "$DpkgScriptsDir";
7048
    }
7049
    LogNorm("additional places to look for perl modules, [$_libStr]");
7050
 
7051
 
7052
    # lets get the target dir value
7053
    my ($m_srcDirValue) = getLocalDirValue($m_srcDirTag, "A");
7054
 
7055
    # we know where we are getting this from and where we
7056
    # going to put them.
7057
    my ($m_sfileLoc) = "$m_srcDirValue/$m_sfile";
7058
 
7059
 
7060
    my ($_cmdStr) = "perlsvc --verbose --lib $_libStr --exe $m_targetDirValue/$m_ofile $m_sfileLoc";
7061
 
7062
 
7063
    # lets execute the package commands.
7064
    my ($retVal);
7065
    $retVal = system("$_cmdStr");
7066
    if ( $retVal != 0 )
7067
    {
7068
        LogError("Failed to complete command [$_cmdStr].");
7069
    }
7070
 
7071
    # done.
7072
    return 1;
7073
}
7074
 
7075
 
7076
#------------------------------------------------------------------------------
7077
sub createPerlAppWin32
7078
#
7079
# Description:
7080
#       This sub-routine is used to create a Win32 free-standing application 
7081
#       using a PERL script as the input.
7082
#
7083
#       note we assume here that you have installed ther ActiveState PERL
7084
#       developement KIT and have also installed a valid license key.
7085
#
7086
#------------------------------------------------------------------------------
7087
{
7088
    # lets just check to see if we can execute this function on
7089
    # this machine.
7090
    #
7091
    if ( "$MachType" ne "win32" )
7092
    {
7093
        LogNorm("createPerlAppWin32() not supported on this machine type.");
7094
        return 1;
7095
    }
7096
 
7097
 
7098
    my ($m_srcDirTag, $m_sfile, $m_targetDirTag, $m_ofile, @m_libDirTags) = @_;
7099
 
7100
 
7101
    # lets get the src dir value
7102
    my ($m_targetDirValue) = getTargetDstDirValue($m_targetDirTag, "A");
7103
 
7104
 
7105
    # lets get the lib src dir value
7106
    my (@m_libDirValue) = ();
7107
    my $i;
7108
    my ($_libStr) = "";
7109
    foreach $i ( 0 .. $#m_libDirTags )
7110
    {
7111
        $m_libDirValue[$i] = getLocalDirValue($m_libDirTags[$i], "A");
7112
        $_libStr = $_libStr . "$m_libDirValue[$i];"
7113
    }
7114
    if ( -d $DpkgScriptsDir )
7115
    {
7116
        $_libStr = $_libStr . "$DpkgScriptsDir";
7117
    }
7118
    LogNorm("additional places to look for perl modules, [$_libStr]");
7119
 
7120
 
7121
    # lets get the target dir value
7122
    my ($m_srcDirValue) = getLocalDirValue($m_srcDirTag, "A");
7123
 
7124
    # we know where we are getting this from and where we
7125
    # going to put them.
7126
    my ($m_sfileLoc) = "$m_srcDirValue/$m_sfile";
7127
 
7128
 
7129
    my ($_cmdStr) = "perlapp --verbose --clean --force --lib $_libStr --exe $m_targetDirValue/$m_ofile --script $m_sfileLoc";
7130
 
7131
 
7132
    # lets execute the package commands.
7133
    my ($retVal);
7134
    $retVal = system("$_cmdStr");
7135
    if ( $retVal != 0 )
7136
    {
7137
        LogError("Failed to complete command [$_cmdStr].");
7138
    }
7139
 
7140
    # done.
7141
    return 1;
7142
}
7143
 
7144
 
7145
#------------------------------------------------------------------------------
7146
sub generateProductContents
7147
#
7148
#------------------------------------------------------------------------------
7149
{
7150
    if ( ! defined($RmPkgDetails) )
7151
    {
7152
        # Set defaults for elements in RM if not found
7153
        DeployUtils::RmPkgInfo->DefaultDescription($PkgDesc);
7154
        DeployUtils::RmPkgInfo->DefaultLabel($PkgLabel);
7155
 
7156
        $RmPkgDetails = DeployUtils::RmPkgInfo->new( 
7157
                        {
7158
                            PKG_NAME => $PkgName,
7159
                            PKG_VERSION => ( "$PkgPatchNum" ne "" ) ? $PkgPatchID : $PkgVersionUser
7160
                        } );
7161
    }
7162
 
7163
 
7164
    # we only go on if we have a pkg 
7165
    if ( $RmPkgDetails->foundPkg() )
7166
    {
7167
        # lets zap the product contents
7168
        # only if the release manager entry is not locked.
7169
        if ( $RmPkgDetails->pv_dlocked() ne "Y" )
7170
        {
7171
           LogError("Failed to zap product contents.")
7172
                if ( ! $RmPkgDetails->zapProductContents( $Platform ) );
7173
        }
7174
 
7175
 
7176
        # lets get a listing of the products contents
7177
        #
7178
        File::Find::find( \&ProductContentsFind, "$PkgBaseDir/$TargetBaseDir");
7179
    }
7180
    else
7181
    {
7182
        LogWarn("Unable to load product contents because we do not have a connection to Release Manager.");
7183
    }
7184
 
7185
 
7186
    # done
7187
    return 1;
7188
}
7189
 
7190
 
7191
#------------------------------------------------------------------------------
7192
sub ProductContentsFind
7193
#
7194
#    Description:
7195
#        This subroutine is used to locate all associated items that 
7196
#        have been designated for the product.
7197
#
7198
#------------------------------------------------------------------------------
7199
{
7200
    my($item)= "$File::Find::name";
7201
    my($base)= File::Basename::basename($item);
7202
 
7203
 
7204
    # we get the absolute path from the find, but we only require
7205
    # a relative path from the starting dir.
7206
 
7207
    my ($_item)   = $item;
7208
    my ($_subStr) = "$PkgBaseDir\/$TargetBaseDir";
7209
    $_item =~ s/$_subStr//;
7210
 
7211
    my $cksumStr;
7212
    my $cksumValue;
7213
    my $cksumSize;
7214
    my $cksumName;
7215
    my $_tmpStr;
7216
    my $retVal;
7217
    my $cksumPath;
7218
 
7219
    if ( "$base" ne "." && "$base" ne ".." && "x$_item" ne "x" )
7220
    {
7221
        $_item =~ s/^\///;
7222
        $cksumPath = $_item;
7223
        $cksumName = File::Basename::basename($_item);
7224
 
7225
        # we need to determine which file we are dealing with
7226
        if ( ! -d "$item")
7227
        {
7228
            $cksumStr  = `cksum "$item"`;
7229
            $retVal    = $? / 256;
7230
            if ( $retVal != 0 )
7231
            {
7232
                LogError("Failed to determine cksum for product content item [$item].") 
7233
            }
7234
            else
7235
            {
7236
                chomp($cksumStr);
7237
                $cksumStr =~ s/^\s+|\s+$//g;
7238
                if ( $cksumStr =~ m/^([0-9]*)\s*([0-9]*)\s*(.*)$/ )
7239
                {
7240
                    ($cksumValue, $cksumSize, $_tmpStr) = ($1, $2, $3);
7241
                    $cksumValue =~ s/^\s+|\s+$//g;
7242
                    $cksumSize  =~ s/^\s+|\s+$//g;
7243
                    $_tmpStr    =~ s/^\s+|\s+$//g;
7244
                }
7245
                else
7246
                {
7247
                    $cksumValue = '';
7248
                    $cksumSize  = 0;
7249
                    $_tmpStr    = '';
7250
                }
7251
            }
7252
 
7253
            $cksumPath = File::Basename::dirname($_item);
7254
            if ( $cksumPath eq "." )
7255
            {
7256
                $cksumPath = '';
7257
            }
7258
            else
7259
            {
7260
                $cksumPath =~ s/$/\//;
7261
            }
7262
 
7263
            # we only mess with the product contents
7264
            # if the package is not released.
7265
            if ( $RmPkgDetails->pv_dlocked() ne "Y" )
7266
            {
7267
                LogError("Failed to insert product content item.")
7268
                     if ( ! $RmPkgDetails->insertProductContentItem( $Target, $cksumPath, $cksumName, '', $cksumSize, $cksumValue) );
7269
            }
7270
            else
7271
            {
7272
                LogInfo("product item - $Target, $cksumPath, $cksumName, '', $cksumSize, $cksumValue");
7273
            }
7274
        }
7275
        else
7276
        {
7277
            $cksumPath =~ s/$/\//;
7278
            if ( $RmPkgDetails->pv_dlocked() ne "Y" )
7279
            {
7280
               LogError("Failed to insert product content item.")
7281
                     if ( ! $RmPkgDetails->insertProductContentItem( $Target, $cksumPath, '', '', 0, '') );
7282
            }
7283
            else
7284
            {
7285
                LogInfo("product dir - $Target, $cksumPath, '', '', 0, ''");
7286
            }
7287
        }
7288
    }
7289
}
7290
 
7291
 
7292
 
7293
#------------------------------------------------------------------------------
7294
1;