Subversion Repositories DevTools

Rev

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