Subversion Repositories DevTools

Rev

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