Subversion Repositories DevTools

Rev

Rev 1554 | Rev 1558 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1554 Rev 1556
Line 13... Line 13...
13
#      deliverable package.
13
#      deliverable package.
14
#
14
#
15
# Description:
15
# Description:
16
#
16
#
17
#
17
#
-
 
18
#
-
 
19
# 2008-08-13 Note on --InstallProdAndDebug option and AlternateBuildType:
-
 
20
#   This option has been added to several functions to allow for the a build
-
 
21
#   to contain both debug and production files. 
-
 
22
#   Most of the deploylib is based on the use of $BuildType to determine where 
-
 
23
#   to look for things and what files to include. To allow for both types, 
-
 
24
#   $AlternateBuildType is set up to hold the opposite of $BuildType 
-
 
25
#   (e.g. D vs P). and the DpkgBinDirListAlternate and DpkgLibDirListAlternate
-
 
26
#   variables are set up to hold 'alternate' sets of directories to search.
-
 
27
#   In theory, we should support 'any' build type, in which case this option
-
 
28
#   would be implemented differently, but P/D are hardcoded throughout here,
-
 
29
#   so this was done as a minimal impact change.
-
 
30
#   
-
 
31
#
18
#......................................................................#
32
#......................................................................#
19
 
33
 
20
require 5.6.1;
34
require 5.006_001;
-
 
35
 
21
 
36
 
22
#------------------------------------------------------------------------------
37
#------------------------------------------------------------------------------
23
# Package definition
38
# Package definition
24
#------------------------------------------------------------------------------
39
#------------------------------------------------------------------------------
25
package deploylib;
40
package deploylib;
Line 39... Line 54...
39
use DeployUtils::RmPkgInfo;
54
use DeployUtils::RmPkgInfo;
40
use BuildConfig;
55
use BuildConfig;
41
use Exporter();
56
use Exporter();
42
 
57
 
43
use ArrayHashUtils;
58
use ArrayHashUtils;
-
 
59
use JatsEnv;
44
use JatsError;
60
use JatsError;
45
use JatsSystem;
61
use JatsSystem;
46
 
62
 
47
#
63
#
48
#   The LWP is a part of the Active State Perl, but not the solaris perl
64
#   The LWP is a part of the Active State Perl, but not the solaris perl
Line 114... Line 130...
114
                    &updatePrototypeFileItemClass
130
                    &updatePrototypeFileItemClass
115
                    &useReplaceClass
131
                    &useReplaceClass
116
                    &setReplaceClassFiles
132
                    &setReplaceClassFiles
117
                    &createPkginfoFile
133
                    &createPkginfoFile
118
                    &updatePrototypeFileItemOwner
134
                    &updatePrototypeFileItemOwner
-
 
135
                    &setPermissions
119
                    &chmod
136
                    &chmod
120
                    &chmodRecursive
137
                    &chmodRecursive
121
                    &chmodDir
138
                    &chmodDir
122
                    &chmodFile
139
                    &chmodFile
123
                    &createSymbolicLink
140
                    &createSymbolicLink
Line 199... Line 216...
199
 
216
 
200
my ($m_UID)  = "";
217
my ($m_UID)  = "";
201
my ($m_GID)  = "";
218
my ($m_GID)  = "";
202
my ($m_MASK) = "";
219
my ($m_MASK) = "";
203
my ($m_KEEP_MASK) = "";
220
my ($m_KEEP_MASK) = "";
-
 
221
my ($m_KEEP_LINKS) = "";
204
 
222
 
205
 
223
 
206
#------------------------------------------------------------------------------
224
#------------------------------------------------------------------------------
207
# Variables global/local to this package
225
# Variables global/local to this package
208
#------------------------------------------------------------------------------
226
#------------------------------------------------------------------------------
209
our $InterfaceDir       = "";
227
our $InterfaceDir       = "";
210
 
228
 
211
our $DpkgBinDir         = "";
229
our $DpkgBinDir         = "";
212
our %DpkgBinDirList     = ();
230
our %DpkgBinDirList     = ();
-
 
231
our %DpkgBinDirListAlternate = (); # bin dir list for $AlternateBuildType
213
our $DpkgLibDir         = "";
232
our $DpkgLibDir         = "";
214
our %DpkgLibDirList     = ();
233
our %DpkgLibDirList     = ();
-
 
234
our %DpkgLibDirListAlternate = (); # lib dir list for $AlternateBuildType
215
our $DpkgScriptsDir     = "";
235
our $DpkgScriptsDir     = "";
216
our $DpkgEtcDir         = "";
236
our $DpkgEtcDir         = "";
217
our $DpkgJarDir         = "";
237
our $DpkgJarDir         = "";
218
our $DpkgSarDir         = "";
238
our $DpkgSarDir         = "";
219
our $DpkgWarDir         = "";
239
our $DpkgWarDir         = "";
Line 234... Line 254...
234
our @LibCheckList       = ();
254
our @LibCheckList       = ();
235
 
255
 
236
our $CurrentDir         = "";
256
our $CurrentDir         = "";
237
our $RootDir            = "";
257
our $RootDir            = "";
238
our $BuildType          = "";
258
our $BuildType          = "";
-
 
259
our $AlternateBuildType = ""; # the opposite of $BuildType
239
our $MachType           = "";
260
our $MachType           = "";
240
our $Platform           = "";
261
our $Platform           = "";
241
our $Product            = "";
262
our $Product            = "";
242
our $Target             = "";
263
our $Target             = "";
243
our $SrcDir             = "";
264
our $SrcDir             = "";
Line 538... Line 559...
538
    $Username     = getlogin || getpwuid($<);
559
    $Username     = getlogin || getpwuid($<);
539
 
560
 
540
    if ( "$BuildType" eq "D" )
561
    if ( "$BuildType" eq "D" )
541
    {
562
    {
542
        $PkgBaseDir = "$PkgDir/debug"; 
563
        $PkgBaseDir = "$PkgDir/debug"; 
-
 
564
        $AlternateBuildType = "P";
543
    }
565
    }
544
    else
566
    else
545
    {
567
    {
546
        $PkgBaseDir = "$PkgDir/prod"; 
568
        $PkgBaseDir = "$PkgDir/prod"; 
-
 
569
        $AlternateBuildType = "D";
547
    }
570
    }
548
 
571
 
549
    $PkgInfoFile   = "$PkgBaseDir/$PkgInfoFileName";
572
    $PkgInfoFile   = "$PkgBaseDir/$PkgInfoFileName";
550
    $ProtoTypeFile = "$PkgBaseDir/$ProtoTypeFileName";
573
    $ProtoTypeFile = "$PkgBaseDir/$ProtoTypeFileName";
551
 
574
 
Line 628... Line 651...
628
            }
651
            }
629
        }
652
        }
630
 
653
 
631
    }
654
    }
632
 
655
 
-
 
656
    # Here we are going to build the same lists but for the $AlternateBuildType
-
 
657
    # (i.e P if $BuildType=D) 
-
 
658
    # We use these when we need to work with both production and debug files.
-
 
659
    foreach my $part ( $BuildFileInfo->getPlatformParts($Platform), $MachType )
-
 
660
    {
-
 
661
        next unless ( $part );
-
 
662
        foreach my $subdir ( "lib." . "$part",
-
 
663
                             "lib." . "$part" . "$AlternateBuildType",
-
 
664
                             "lib/lib." . "$part" . "$AlternateBuildType",
-
 
665
                             "lib/$part" . "$AlternateBuildType",
-
 
666
                             "lib/$part" )
-
 
667
        {
-
 
668
            if ( -d "$DpkgLibDir/$subdir" )
-
 
669
            {
-
 
670
                UniquePush( \@{$DpkgLibDirListAlternate{_ALL_}}, $subdir);
-
 
671
                UniquePush( \@{$DpkgLibDirListAlternate{$part}}, $subdir);
-
 
672
            }
-
 
673
        }
-
 
674
    }
-
 
675
 
-
 
676
    foreach my $part ( $BuildFileInfo->getPlatformParts($Platform), $MachType )
-
 
677
    {
-
 
678
        next unless ( $part );
-
 
679
        foreach my $subdir ( "bin." . "$part" . "$AlternateBuildType",
-
 
680
                             "bin." . "$part",
-
 
681
                             "bin/bin." . "$part" . "$AlternateBuildType",
-
 
682
                             "bin/" . "$part" . "$AlternateBuildType",
-
 
683
                             "bin/" . uc($part) . "$AlternateBuildType",
-
 
684
                             "bin/$part",
-
 
685
 
-
 
686
                             "bin." . "$part" . "P",
-
 
687
                             "bin/bin." . "$part" . "P",
-
 
688
                             "bin/" . "$part" . "P",
-
 
689
                             "bin/" . uc($part) . "P" )
-
 
690
        {
-
 
691
            if ( -d "$DpkgBinDir/$subdir" )
-
 
692
            {
-
 
693
                UniquePush( \@{$DpkgBinDirListAlternate{_ALL_}}, $subdir);
-
 
694
                UniquePush( \@{$DpkgBinDirListAlternate{$part}}, $subdir);
-
 
695
            }
-
 
696
        }
-
 
697
   }
633
    Information("------------------------------------------------------------");
698
    Information("------------------------------------------------------------");
634
 
699
 
635
 
700
 
636
    # lets generate the patch id if we are building a patch
701
    # lets generate the patch id if we are building a patch
637
    #
702
    #
Line 1220... Line 1285...
1220
    #   Creating a list allows:
1285
    #   Creating a list allows:
1221
    #       Simplified coding
1286
    #       Simplified coding
1222
    #       Flattening and testing of the flattening
1287
    #       Flattening and testing of the flattening
1223
    #
1288
    #
1224
    my @elements = $search->search( $src_base_dir);
1289
    my @elements = $search->search( $src_base_dir);
-
 
1290
    Warning("installAllDpkgArchivePkgFiles2: No files found") unless ( @elements );
1225
 
1291
 
1226
    #
1292
    #
1227
    #   Perform the file copy
1293
    #   Perform the file copy
1228
    #   This copy will NOT create empty directories, but it will create needed
1294
    #   This copy will NOT create empty directories, but it will create needed
1229
    #   directories on the fly.
1295
    #   directories on the fly.
Line 2813... Line 2879...
2813
    return 1;
2879
    return 1;
2814
}
2880
}
2815
 
2881
 
2816
 
2882
 
2817
#------------------------------------------------------------------------------
2883
#------------------------------------------------------------------------------
-
 
2884
sub copyDpkgArchiveBinFile
-
 
2885
#
-
 
2886
# Description:
-
 
2887
#       This sub-routine is used to find a binary file from the
-
 
2888
#       dpkg_archive and copy it into the supplied install dir. 
-
 
2889
#
-
 
2890
#       If it fails to find the file it will report an error and terminates
-
 
2891
#       processing.
-
 
2892
#
-
 
2893
# Inputs          :     @srcDirList         - array of subdirectories to search
-
 
2894
#                                             within the $DpkgBinDir
-
 
2895
#                       $srcFilename        - file to find then copy
-
 
2896
#                       $destDir            - destination directory
-
 
2897
#                       $rename             - Optional Rename
-
 
2898
#
-
 
2899
#
-
 
2900
# Returns         :     Nothing of use
-
 
2901
#                       Will not return if the file is not found
-
 
2902
#
-
 
2903
#------------------------------------------------------------------------------
-
 
2904
{
-
 
2905
    my ($srcDirList, $srcFilename, $destDir, $rename ) = @_;
-
 
2906
 
-
 
2907
    if ( "$MachType" eq "win32" )
-
 
2908
    {
-
 
2909
        # if the item does not have an .exe extention
-
 
2910
        # we shall add one for convience.
-
 
2911
        #
-
 
2912
        $srcFilename .= '.exe'
-
 
2913
            if ( $srcFilename !~ m~\.(exe)|(dll)$~i );
-
 
2914
 
-
 
2915
        $rename .= '.exe'
-
 
2916
            if ( $rename && $rename !~ m~\.(exe)|(dll)$~i );
-
 
2917
    }
-
 
2918
 
-
 
2919
    foreach my $i (@$srcDirList)
-
 
2920
    {
-
 
2921
        my $m_DpkgDir = "$DpkgBinDir/$i";
-
 
2922
        if ( ! -d $m_DpkgDir )
-
 
2923
        {
-
 
2924
            Debug("Directory [$m_DpkgDir] not found.");
-
 
2925
            next;
-
 
2926
        }
-
 
2927
 
-
 
2928
        # Define the absolute location of the file
-
 
2929
        #
-
 
2930
        my $m_srcFileLocation = "$m_DpkgDir/$srcFilename";
-
 
2931
        my $m_dstFileLocation = "$destDir/" . ( $rename ? $rename : $srcFilename );
-
 
2932
 
-
 
2933
        # we will check to see if the file exists.
-
 
2934
        #
-
 
2935
        if ( -f $m_srcFileLocation )
-
 
2936
        {
-
 
2937
            # now we need to copy the file.
-
 
2938
            if(File::Copy::copy($m_srcFileLocation, $m_dstFileLocation))
-
 
2939
            {
-
 
2940
                Verbose("Copied Bin [$srcFilename] to [$m_dstFileLocation] ...");
-
 
2941
 
-
 
2942
                # no need to go further, we have found the file.
-
 
2943
                #
-
 
2944
                return 1;
-
 
2945
            }
-
 
2946
            else
-
 
2947
            {
-
 
2948
                Error("Failed to copy binary [$srcFilename]: $!");
-
 
2949
            }
-
 
2950
        }
-
 
2951
        # else we have not found the file yet!
-
 
2952
    }
-
 
2953
 
-
 
2954
    # if we do not find the file at all we need to inform the user.
-
 
2955
    #
-
 
2956
    Error("Dpkg_archive bin file [$srcFilename]",
-
 
2957
          "File does not exist or is not in correct directory structure");
-
 
2958
}
-
 
2959
 
-
 
2960
#------------------------------------------------------------------------------
2818
sub installDpkgArchiveBinFile
2961
sub installDpkgArchiveBinFile
2819
#
2962
#
2820
# Description:
2963
# Description:
2821
#       This sub-routine is used to install a binary file from the
2964
#       This sub-routine is used to install a binary file from the
2822
#       dpkg_archive into the supplied install dir. 
2965
#       dpkg_archive into the supplied install dir. 
Line 2835... Line 2978...
2835
#                   --SelectFrom=xxxx       - Limits file source selection
2978
#                   --SelectFrom=xxxx       - Limits file source selection
2836
#                                             By default all LIB sources are searched.
2979
#                                             By default all LIB sources are searched.
2837
#                                             The selector should be a Platform, Product
2980
#                                             The selector should be a Platform, Product
2838
#                                             ,Target or MachineType
2981
#                                             ,Target or MachineType
2839
#
2982
#
-
 
2983
#                   --Rename=xxxx           - Rename the file during the copy operation
-
 
2984
#                                             Not valid if $sfile is a ref to a list
-
 
2985
#
-
 
2986
#                   --InstallProdAndDebug   - install both production and debug
-
 
2987
#                                             versions of any binary files 
-
 
2988
#                                             in bin/P and bin/D sub-dirs, 
-
 
2989
#                                             and create a links/copy of the 
-
 
2990
#                                             file for the $BuildType
-
 
2991
#                                             in the actual bin directory.
-
 
2992
#                                             (only tested for sparc)
2840
#
2993
#
2841
# Returns         :     Nothing of use
2994
# Returns         :     Nothing of use
2842
#                       Will not return if the file is not found
2995
#                       Will not return if the file is not found
2843
#
2996
#
2844
#------------------------------------------------------------------------------
2997
#------------------------------------------------------------------------------
2845
{
2998
{
2846
    my @args;
2999
    my @args;
2847
    my $select = '_ALL_';
3000
    my $select = '_ALL_';
-
 
3001
    my $rename = "";
-
 
3002
    my $installProdAndDebug;
2848
 
3003
 
2849
    #
3004
    #
2850
    #   Process parameters and extract options
3005
    #   Process parameters and extract options
2851
    #
3006
    #
2852
    foreach  ( @_ )
3007
    foreach  ( @_ )
2853
    {
3008
    {
2854
        if ( m/^--SelectFrom=(.*)/ ) {
3009
        if ( m/^--SelectFrom=(.*)/ ) {
2855
            $select = $1;
3010
            $select = $1;
2856
            Error("installDpkgArchiveBinFile: Selector not known: $_")
3011
            Error("installDpkgArchiveBinFile: Selector not known: $_")
2857
                unless ( defined $DpkgLibDirList{$select} );
3012
                unless ( defined $DpkgLibDirList{$select} );
-
 
3013
        } elsif ( m/^--InstallProdAndDebug/ ) {
-
 
3014
            if ( "$MachType" eq "sparc" )
-
 
3015
            {
-
 
3016
                $installProdAndDebug = 1;
-
 
3017
            }
-
 
3018
            else
-
 
3019
            {
-
 
3020
                Error("--InstallProdAndDebug option only supported for sparc.");
-
 
3021
            }
-
 
3022
 
-
 
3023
        } elsif ( m/^--Rename=(.+)/ ) {
-
 
3024
            $rename = $1;
2858
 
3025
 
2859
        } elsif ( m/^--/ ) {
3026
        } elsif ( m/^--/ ) {
2860
            Warning ("installDpkgArchiveBinFile: Unknown option ignored: $_")
3027
            Warning ("installDpkgArchiveBinFile: Unknown option ignored: $_")
2861
 
3028
 
2862
        } else {
3029
        } else {
Line 2890... Line 3057...
2890
    unless ( ref ( $fref ) eq 'ARRAY' )
3057
    unless ( ref ( $fref ) eq 'ARRAY' )
2891
    {
3058
    {
2892
        push @one_file, $fref;
3059
        push @one_file, $fref;
2893
        $fref = \@one_file;
3060
        $fref = \@one_file;
2894
    }
3061
    }
-
 
3062
    else
-
 
3063
    {
-
 
3064
        Error ("installDpkgArchiveBinFile. --Rename option cannot be used with a list of files")
-
 
3065
            if $rename;
-
 
3066
    }
2895
 
3067
 
2896
    foreach my $sfile ( @$fref )
3068
    foreach my $sfile ( @$fref )
2897
    {
3069
    {
2898
    
-
 
2899
        if ( "$MachType" eq "win32" )
3070
        if ( $installProdAndDebug )
2900
        {
3071
        {
2901
            # if the item does not have an .exe extention
3072
            # This option allows you to install both prod and debug binaries.
-
 
3073
            # 1) creates a bin/P and bin/D subdirectory of the bin directory, 
2902
            # we shall add one for convience.
3074
            # 2) copies the binaries into them, then 
-
 
3075
            # 3) links/copies from bin/$BuildType to bin directory.
2903
            #
3076
            
2904
            if ( $sfile !~ m/\.exe$/  &&
3077
            # if the bin/P bin/D dirs don't exist, create them.
2905
                 $sfile !~ m/\.dll$/ )
3078
            if (! -d "$targetValue/$BuildType" )
2906
            {
3079
            {
2907
                $sfile = $sfile . ".exe";
3080
                make_directory( "$targetValue/$BuildType", 0777, "Create BinDir/$BuildType dir");
2908
            }
3081
            }
2909
        }
-
 
2910
 
-
 
2911
 
-
 
2912
        my ($i);
-
 
2913
        my ($foundFileFlag) = "false";
-
 
2914
        my ($m_DpkgBinDir)  = "";
-
 
2915
        my ($m_srcFileLocation) = "";
-
 
2916
        my ($m_dstFileLocation) = "";
-
 
2917
        foreach $i (@{$DpkgBinDirList{$select}})
-
 
2918
        {
-
 
2919
            $m_DpkgBinDir = "$DpkgBinDir" . "/$i";
-
 
2920
            if ( ! -d "$m_DpkgBinDir" )
3082
            if (! -d "$targetValue/$AlternateBuildType" )
2921
            {
3083
            {
2922
                Debug("Directory [$m_DpkgBinDir] not found.");
3084
                make_directory( "$targetValue/$AlternateBuildType", 0777, "Create BinDir/$AlternateBuildType dir");
2923
                next;
-
 
2924
            }
3085
            }
-
 
3086
            
-
 
3087
            # copy in the production and debug binaries. Note the separate search paths.
-
 
3088
            copyDpkgArchiveBinFile(\@{$DpkgBinDirList{$select}}, $sfile, "$targetValue/$BuildType", $rename);
-
 
3089
            copyDpkgArchiveBinFile(\@{$DpkgBinDirListAlternate{$select}}, $sfile, "$targetValue/$AlternateBuildType", "$rename");
2925
 
3090
 
2926
            # lets define the absolute location of the file
3091
            # create link (or copy) from bin to bin/$BuildType dir 
2927
            $m_srcFileLocation = "$m_DpkgBinDir/$sfile";
-
 
2928
            $m_dstFileLocation = "$targetValue/$sfile";
-
 
2929
 
-
 
2930
            # we will check to see if the file exists.
-
 
2931
            #
-
 
2932
            if ( -f "$m_srcFileLocation" )
3092
            if ( $MachType eq "sparc" )
2933
            {
3093
            {
2934
                # now we need to copy the file.
3094
                # create symbolic link in the bin directory
2935
                if(File::Copy::copy("$m_srcFileLocation", "$m_dstFileLocation"))
3095
                if ( ! -f "$targetValue/$sfile" )
2936
                {
3096
                {
2937
                    Verbose("Copied Bin [$sfile] to [$m_dstFileLocation] ...");
3097
                    my $cmd = "cd $targetValue; ln -s $BuildType/$sfile $sfile ";
-
 
3098
                    my $retVal = system($cmd);
2938
                    $foundFileFlag = "true";
3099
                    if ( $retVal != 0 )
2939
                 
3100
                    {
2940
                    # no need to go further, we have found the file.
3101
                        Error("Failed to create generic link [$targetValue/$sfile] to [$targetValue/$BuildType/$sfile]: $retVal");
2941
                    #
3102
                    }
2942
                    last;
3103
                    else
-
 
3104
                    {
-
 
3105
                        Verbose("Created generic link [$targetValue/$sfile] to [$targetValue/$BuildType/$sfile] ...");
-
 
3106
                    }
-
 
3107
                }
-
 
3108
            }
-
 
3109
            else
-
 
3110
            {
-
 
3111
                # create a copy in the bin directory
-
 
3112
                if(File::Copy::copy("$targetValue/$BuildType/$sfile" , "$targetValue" ))
-
 
3113
                {
-
 
3114
                    Verbose("Copied Bin [$targetValue/$BuildType/$sfile] to [$targetValue] ...");
2943
                }
3115
                }
2944
                else
3116
                else
2945
                {
3117
                {
2946
                    Error("Failed to copy binary [$sfile]: $!");
3118
                    Error("Failed to copy binary [$targetValue/$BuildType/$sfile] to [$targetValue]: $!");
2947
                }
3119
                }
-
 
3120
                
2948
            }
3121
            }
2949
            # else we have not found the file yet!
-
 
2950
        }
3122
        }
2951
 
-
 
2952
        # if we do not find the file at all we need to inform
-
 
2953
        # the user.
-
 
2954
        #
3123
        else
2955
        if ( "$foundFileFlag" eq "false" )
-
 
2956
        {
3124
        {
2957
            Error("Dpkg_archive bin file [$sfile] does not exist or is not in correct directory structure.");
3125
            copyDpkgArchiveBinFile(\@{$DpkgBinDirList{$select}}, $sfile, $targetValue, $rename );
2958
        }
3126
        }
2959
    }
3127
    }
2960
    
-
 
2961
    return 1;
3128
    return 1;
2962
}
3129
}
2963
 
3130
 
2964
 
3131
 
2965
#------------------------------------------------------------------------------
3132
#------------------------------------------------------------------------------
2966
sub installDpkgArchiveLibFile
3133
sub installDpkgArchiveLibFile
2967
#
3134
#
2968
# Description:
3135
# Description:
2969
#       This sub-routine is used to install a binary file from the
3136
#       This sub-routine is used to install a library file from the
2970
#       dpkg_archive into the supplied install location dir.
3137
#       dpkg_archive into the supplied install location dir.
2971
#
3138
#
2972
#       It assumes based on the build type where the file will be located.
3139
#       It assumes based on the build type where the file will be located.
2973
#
3140
#
2974
#       If it fails to find the file it will report an error and terminates
3141
#       If it fails to find the file it will report an error and terminates
Line 2989... Line 3156...
2989
#                   --Link                  - Default
3156
#                   --Link                  - Default
2990
#                   --SelectFrom=xxxx       - Limits file source selection
3157
#                   --SelectFrom=xxxx       - Limits file source selection
2991
#                                             By default all LIB sources are searched.
3158
#                                             By default all LIB sources are searched.
2992
#                                             The selector should be a Platform, Product
3159
#                                             The selector should be a Platform, Product
2993
#                                             ,Target or MachineType
3160
#                                             ,Target or MachineType
-
 
3161
#                   --InstallProdAndDebug   - install both production and debug
-
 
3162
#                                             versions of any libraries
-
 
3163
#                                             (only tested for sparc)
2994
#
3164
#
2995
# SourceFile options:
3165
# SourceFile options:
2996
#                   Source files may be a filter rule which will expand to
3166
#                   Source files may be a filter rule which will expand to
2997
#                   one or more files.
3167
#                   one or more files.
2998
#                       --FilterIn=xx
3168
#                       --FilterIn=xx
Line 3020... Line 3190...
3020
#------------------------------------------------------------------------------
3190
#------------------------------------------------------------------------------
3021
{
3191
{
3022
    my @args;
3192
    my @args;
3023
    my $links = 1;
3193
    my $links = 1;
3024
    my $select = '_ALL_';
3194
    my $select = '_ALL_';
-
 
3195
    my $installProdAndDebug;
3025
 
3196
 
3026
    #
3197
    #
3027
    #   Process parameters and extract options
3198
    #   Process parameters and extract options
3028
    #
3199
    #
3029
    foreach  ( @_ )
3200
    foreach  ( @_ )
Line 3039... Line 3210...
3039
            Error("installDpkgArchiveLibFile: Selector not known: $_")
3210
            Error("installDpkgArchiveLibFile: Selector not known: $_")
3040
                unless ( defined $DpkgLibDirList{$select} );
3211
                unless ( defined $DpkgLibDirList{$select} );
3041
 
3212
 
3042
        } elsif ( m/^--Filter.*=/ ) {
3213
        } elsif ( m/^--Filter.*=/ ) {
3043
            push @args, $_;
3214
            push @args, $_;
-
 
3215
        } elsif ( m/^--InstallProdAndDebug/ ) {
-
 
3216
            # not sure if the filename conventions allow the installation
-
 
3217
            # of both prod/debug files on windows, so limit this to sparc/unix.
-
 
3218
            if ( "$MachType" ne "sparc" ){
-
 
3219
                Error("Can only use the InstallProdAndDebug option for sparc.");
-
 
3220
            }
3044
 
3221
 
-
 
3222
            $installProdAndDebug = 1;
3045
        } elsif ( m/^--/ ) {
3223
        } elsif ( m/^--/ ) {
3046
            Warning ("installDpkgArchiveLibFile: Unknown option ignored: $_")
3224
            Warning ("installDpkgArchiveLibFile: Unknown option ignored: $_")
3047
 
3225
 
3048
        } else {
3226
        } else {
3049
            push @args, $_;
3227
            push @args, $_;
Line 3184... Line 3362...
3184
        my ($ExcludedFlag) = "false";
3362
        my ($ExcludedFlag) = "false";
3185
 
3363
 
3186
        #
3364
        #
3187
        #   Search all the 'lib' locations, or a specified subset
3365
        #   Search all the 'lib' locations, or a specified subset
3188
        #
3366
        #
3189
        foreach $i (@{$DpkgLibDirList{$select}})
3367
        my (@libDirList) = @{$DpkgLibDirList{$select}};
-
 
3368
        if ($installProdAndDebug)
-
 
3369
        {
-
 
3370
            # we want to be able to search both prod and debug dirs. 
-
 
3371
            # we can just add them together here because the lib filenames
-
 
3372
            # are different (i.e. xxxD.so vs xxxP.so) and a P or D library 
-
 
3373
            # will only exist in one dir. i.e. P.so in prod dirs, D.so in debug dirs.
-
 
3374
            push @libDirList, @{$DpkgLibDirListAlternate{$select}};
-
 
3375
        }
-
 
3376
 
-
 
3377
        foreach $i (@libDirList)
3190
        {
3378
        {
3191
 
3379
 
3192
            $m_DpkgLibDir = "$DpkgLibDir" . "/$i";
3380
            $m_DpkgLibDir = "$DpkgLibDir" . "/$i";
3193
            if ( ! -d "$m_DpkgLibDir" )
3381
            if ( ! -d "$m_DpkgLibDir" )
3194
            {
3382
            {
Line 3200... Line 3388...
3200
            $m_srcFileLocation = "$m_DpkgLibDir/$sfile";
3388
            $m_srcFileLocation = "$m_DpkgLibDir/$sfile";
3201
            $m_dstFileLocation = "$targetValue/$sfile";
3389
            $m_dstFileLocation = "$targetValue/$sfile";
3202
 
3390
 
3203
 
3391
 
3204
            # we only want debug items in a debug build
3392
            # we only want debug items in a debug build
3205
            #
3393
            # unless we are told to installProdAndDebug
3206
            if(excludeItemFromBuild($sfile))
3394
            if ( ( !$installProdAndDebug) && (excludeItemFromBuild($sfile)) )
3207
            {
3395
            {
3208
                Verbose("Excluding item [$sfile] from build as not compatible with build type [$BuildType].");
3396
                Verbose("Excluding item [$sfile] from build as not compatible with build type [$BuildType].");
3209
                $ExcludedFlag = "true";
3397
                $ExcludedFlag = "true";
3210
            }
3398
            }
3211
            else
3399
            else
Line 3251... Line 3439...
3251
                        if ( $links && ( "x$PkgPatchID" eq "x" || "$MachType" eq "win32") )
3439
                        if ( $links && ( "x$PkgPatchID" eq "x" || "$MachType" eq "win32") )
3252
                        {
3440
                        {
3253
                            # normal build or if we are building win32 we want generic names
3441
                            # normal build or if we are building win32 we want generic names
3254
 
3442
 
3255
                            # we want to create a copy of our target using
3443
                            # we want to create a copy of our target using
3256
                            # the generic name
3444
                            # the generic name (no version number)
3257
                            if ( $sfile ne $nVerName )
3445
                            if ( $sfile ne $nVerName )
3258
                            {
3446
                            {
3259
                                createGenericCopy("$sfile", "$m_srcFileLocation", "$nVerName", "$targetValue");
3447
                                createGenericCopy("$sfile", "$m_srcFileLocation", "$nVerName", "$targetValue");
3260
                            }
3448
                            }
-
 
3449
                            # and another copy with no build type or version number.
3261
                            if ( $sfile ne $gName )
3450
                            if ( $sfile ne $gName )
3262
                            {
3451
                            {
-
 
3452
                                # because this link doesn't have a P/D 
-
 
3453
                                # differentiator, we can only have one, so 
-
 
3454
                                # do this for the $BuildType file, but not any
-
 
3455
                                # $AlternateBuildType files
-
 
3456
                                if ( (!$installProdAndDebug) || ( $sfile =~ /$BuildType\./ ) )
-
 
3457
                                {
3263
                                createGenericCopy("$sfile", "$m_srcFileLocation", "$gName",    "$targetValue");
3458
                                    createGenericCopy("$sfile", "$m_srcFileLocation", "$gName",    "$targetValue");
-
 
3459
                                }
3264
                            }
3460
                            }
3265
                        }
3461
                        }
3266
 
3462
 
3267
 
3463
 
3268
                        # lets add this lib to our check list for next time.
3464
                        # lets add this lib to our check list for next time.
Line 3850... Line 4046...
3850
#
4046
#
3851
#        On sparc this will be a link, but on win32 it will be a file based on the
4047
#        On sparc this will be a link, but on win32 it will be a file based on the
3852
#        buildType.
4048
#        buildType.
3853
#
4049
#
3854
#    INPUT:
4050
#    INPUT:
3855
#        src item name
4051
#        sName = src item name without path
-
 
4052
#        sLoc = src item name including path
3856
#        generic item name
4053
#        gName = generic item name
3857
#        target dir
4054
#        tDir = target dir
3858
#
4055
#
3859
#    RETURN:
4056
#    RETURN:
3860
#         1
4057
#         1
3861
#
4058
#
3862
#------------------------------------------------------------------------------
4059
#------------------------------------------------------------------------------
Line 4821... Line 5018...
4821
        {
5018
        {
4822
            Error("Failed to copy info file [$PKG_UTIL_DIR/$i] to [$PkgBaseDir] : $!");
5019
            Error("Failed to copy info file [$PKG_UTIL_DIR/$i] to [$PkgBaseDir] : $!");
4823
        }
5020
        }
4824
    }
5021
    }
4825
 
5022
 
-
 
5023
    #
-
 
5024
    #   Scan the install 'image' looking for files and directories that have a 'space' in the name
-
 
5025
    #   These are not handled by the pkgmk utility, so it is best to create a nice error message now.
-
 
5026
    #
-
 
5027
    my $search = LocateFiles->new( recurse => 1, dirs_too => 1 );
-
 
5028
    $search->filter_in_re('\s');                                  
-
 
5029
    my @m_nfiles = $search->search($PkgBaseDir);                                  
-
 
5030
    if ( @m_nfiles )
-
 
5031
    {
-
 
5032
        Error ("Pathnames containing a space cannot be packaged under Solaris",
-
 
5033
               "The following paths contain a space",
-
 
5034
               @m_nfiles );
-
 
5035
    }
4826
 
5036
    
4827
    my ( $m_pkgmkCmd );
5037
    my ( $m_pkgmkCmd );
4828
    my ( $m_pkgtransCmd );
5038
    my ( $m_pkgtransCmd );
4829
    $m_pkgmkCmd = "pkgmk -o " .
5039
    $m_pkgmkCmd = "pkgmk -o " .
4830
                  "-f $PkgBaseDir/prototype " .
5040
                  "-f $PkgBaseDir/prototype " .
-
 
5041
                  "-d $PkgBaseDir " .
4831
                  "-d $PkgBaseDir";
5042
                  "-r $PkgBaseDir";
4832
 
-
 
4833
 
5043
 
4834
    $m_pkgtransCmd = "pkgtrans -o " .
5044
    $m_pkgtransCmd = "pkgtrans -o " .
4835
                     "-s $PkgBaseDir " .
5045
                     "-s $PkgBaseDir " .
4836
                     "$PkgOutputFile " .
5046
                     "$PkgOutputFile " .
4837
                     "$PkgName";
5047
                     "$PkgName";
Line 4982... Line 5192...
4982
        next unless ( -f $prog );
5192
        next unless ( -f $prog );
4983
        $prog_found = 1;
5193
        $prog_found = 1;
4984
        last;
5194
        last;
4985
    }
5195
    }
4986
 
5196
 
-
 
5197
    #
-
 
5198
    #   Note: Use $RootDir for the ISBUILD workdir
-
 
5199
    #         Would like t use interface, but it makes
-
 
5200
    #         the pathname longer and some MergeModules can
-
 
5201
    #         be extracted. ISBUILD appears to have a path length limit of
-
 
5202
    #         about 204 character. We need all we can get.
-
 
5203
    #
-
 
5204
 
4987
    Error("isbuild.pl not found") unless $prog_found;
5205
    Error("isbuild.pl not found") unless $prog_found;
4988
    Verbose("isbuild: $prog");
5206
    Verbose("isbuild: $prog");
4989
    my $rv = system ( $ENV{GBE_PERL}, $prog,
5207
    my $rv = system ( $ENV{GBE_PERL}, $prog,
4990
                            "-project=../$PkgName.ism",
5208
                            "-project=../$PkgName.ism",
4991
                            "-version=$PkgVersionUser",
5209
                            "-version=$PkgVersionUser",
4992
                            "-out=$ReleaseDir",
5210
                            "-out=$ReleaseDir",
4993
                            "-workdir=$InterfaceDir",
5211
                            "-workdir=$RootDir",
4994
                            @user_options,
5212
                            @user_options,
4995
                            map { "-mergemodule=$_" } @mm_dirs
5213
                            map { "-mergemodule=$_" } @mm_dirs
4996
                             );
5214
                             );
4997
    Error ("InstallShield Builder Error" ) if ( $rv );
5215
    Error ("InstallShield Builder Error" ) if ( $rv );
4998
    return 1;
5216
    return 1;
Line 5026... Line 5244...
5026
 
5244
 
5027
    # lets take the passed in args.
5245
    # lets take the passed in args.
5028
    my ($uid, $gid) = @_;
5246
    my ($uid, $gid) = @_;
5029
 
5247
 
5030
 
5248
 
5031
    # we need to determine whiich file we are dealing with
5249
    # we need to determine which file we are dealing with
5032
    my ($protoTypeFile);
5250
    my ($protoTypeFile);
5033
    my ($targetBaseDir);
5251
    my ($targetBaseDir);
5034
    my ($pkgBaseDir);
5252
    my ($pkgBaseDir);
5035
    $protoTypeFile = "$ProtoTypeFile"; 
5253
    $protoTypeFile = "$ProtoTypeFile"; 
5036
    $targetBaseDir = "$PkgBaseDir/$TargetBaseDir"; 
5254
    $targetBaseDir = "$PkgBaseDir/$TargetBaseDir"; 
Line 5609... Line 5827...
5609
 
5827
 
5610
}
5828
}
5611
 
5829
 
5612
 
5830
 
5613
#------------------------------------------------------------------------------
5831
#------------------------------------------------------------------------------
5614
sub chmod
5832
sub setPermissions
-
 
5833
#   Called to set permissions of files/dirs in a directory structure.
-
 
5834
#       With no options sets DirTag and all files/dirs in it to perms
5615
#
5835
#   
5616
# Description:
5836
#   Parameters:  
5617
#       This sub-routine is used to change the ownership of a file or
5837
#               DirTag:  The directory tag to start setting permissions on
-
 
5838
#       
-
 
5839
#   Required Options:
5618
#       directory structure.
5840
#       One or both of
-
 
5841
#               --FilePerms=    Sets the permissions of files to this permission.
-
 
5842
#                               If not supplied then no files have their permissions changed
-
 
5843
#               --DirPerms=     Sets the permissions of directories to this permission
-
 
5844
#                               If not supplied then no directories have their permissions changed
-
 
5845
#       OR
-
 
5846
#               --Perms=        Sets the permissions of both files and directories to this permissions
-
 
5847
#                               Equivalent to supplying both --FilePerms=X && --DirPerms=X
-
 
5848
#               
-
 
5849
#   Options:
-
 
5850
#               --Recurse       Recurse the directory tree.  Does a deptth first recurse so that all 
-
 
5851
#                               dir entries are processed before the dir itself
-
 
5852
#               --NoRecurse     Dont recurse, default
-
 
5853
#               --DirTagOnly    Only sets the permissions on the DirTag directory, 
-
 
5854
#                               all other options ignored
-
 
5855
#               --SkipDirTag    Does not set permissions on the DirTag Directory, 
-
 
5856
#                               obviously mutually exlusive with --DirTagOnly
-
 
5857
#               --FilterIn=     Apply permissions to files/directories that matches this value.
-
 
5858
#               --FilterInRE=   Perl RE's can be used (Not Shell wildcards) and this option
-
 
5859
#                               can be supplied mulitple times
-
 
5860
#               --FilterOut=    Dont apply permissions to any files/directories matching this value
-
 
5861
#               --FilterOutRE=  Perl RE's can be used (Not Shell wildcards) and this option
-
 
5862
#                               can be supplied mulitple times
-
 
5863
#               
-
 
5864
#                               FilterIn is applied before FilterOut.  If Recurse is specified 
-
 
5865
#                               the directory will be recursed regardless of these filters, however
-
 
5866
#                               the filter will be applied when it comes time to chmod the dir 
5619
#
5867
#
5620
#------------------------------------------------------------------------------
5868
#------------------------------------------------------------------------------
5621
{
5869
{
5622
    # correct number of parameters?
5870
    my ( $dirTag, $filePerms, $dirPerms );
-
 
5871
    my ( $dirTagOnly, $skipDirTag ) = ( 0, 0 );
-
 
5872
    
-
 
5873
    my $search =  LocateFiles->new( recurse => 0, dirs_too =>1 );
-
 
5874
 
5623
    if ( ($#_+1) != 3 )
5875
    foreach ( @_ )
5624
    {
5876
    {
5625
        Error("Incorrect number of params passed to " .
5877
        if ( m/^--Perms=(.*)/ ) {
5626
                  "chmod() function. Check deploy config.");
5878
            $filePerms = $1;
5627
    }
5879
            $dirPerms = $1;
5628
 
5880
 
-
 
5881
        } elsif ( m/^--FilePerms=(.*)/ )  {
-
 
5882
            $filePerms = $1;
5629
 
5883
 
-
 
5884
        } elsif ( m/^--DirPerms=(.*)/ )  {
-
 
5885
            $dirPerms = $1;
-
 
5886
 
5630
    # lets setup the passed values.
5887
        } elsif ( m/^--Recurse/ ) {
-
 
5888
            $search->recurse(1);
-
 
5889
        }
5631
    my ($m_sDirTag, $m_sfile, $m_ownPerms) = @_;
5890
        elsif ( m/^--NoRecurse/ ) {
-
 
5891
            $search->recurse(0);
5632
 
5892
 
-
 
5893
        }  elsif ( m/^--DirTagOnly/ ) {
-
 
5894
            $dirTagOnly = 1;
5633
 
5895
 
-
 
5896
        } elsif ( m/^--SkipDirTag/ )  {
-
 
5897
            $skipDirTag = 1;
-
 
5898
 
-
 
5899
        }  elsif ( m/^--FilterInRE=(.*)/ ) {
-
 
5900
            $search->filter_in_re($1);
-
 
5901
 
-
 
5902
        } elsif ( m/^--FilterIn=(.*)/ ) {
-
 
5903
            $search->filter_in($1);
-
 
5904
 
-
 
5905
        }  elsif ( m/^--FilterOutRE=(.*)/ ) {
-
 
5906
            $search->filter_out_re($1);
-
 
5907
 
-
 
5908
        }  elsif ( m/^--FilterOut=(.*)/ ) {
-
 
5909
            $search->filter_out($1);
-
 
5910
            
-
 
5911
        } else  {
-
 
5912
            Error("SetPermissions DirTag already set") if ( $dirTag );
-
 
5913
            $dirTag = $_;
-
 
5914
        }
-
 
5915
    }
-
 
5916
 
-
 
5917
    Error("SetPermissions called with out DirTag parameter") if ( !defined($dirTag) );
-
 
5918
    Error("SetPermissions called with out any Permission options") if ( !defined($filePerms) && !defined($dirPerms) );
-
 
5919
    Error("SetPermissions: Options --DirTagOnly & --SkipDirTag are mutually exclusive" ) if ( $dirTagOnly && $skipDirTag );
-
 
5920
 
-
 
5921
    #
5634
    # lets just check to see if the perms are in correct format.
5922
    # lets just check to see if the perms are in correct format.
5635
    #
5923
    #
5636
    if ( "$m_ownPerms" !~ m/^[0-9][0-9][0-9][0-9]$/ )
5924
    if ( (defined($filePerms) && $filePerms !~ m/^\d{4}$/) || (defined($dirPerms) && $dirPerms !~ m/^\d{4}$/) )
5637
    {
5925
    {
5638
        Error("chmod() does not support [$m_ownPerms] permission, use format 0755 etc.");
5926
        Error("setPermissions called with invalid permissions format");
5639
        return 1;
-
 
5640
    }
5927
    }
5641
 
5928
 
5642
    # lets get the absolute src dir value
5929
    #   Convert the symbolic target directory name into a real path
5643
    my ($m_sDirAbsoluteValue) = getTargetDstDirValue($m_sDirTag, "A");
5930
    my ($topDir) = getTargetDstDirValue($dirTag, "A");
5644
 
5931
 
-
 
5932
    #
-
 
5933
    #   Only set perms on the root directory
-
 
5934
    #   This is a trivial operation
5645
    my($item);
5935
    #
5646
    if ( "x$m_sfile" eq "x" )
5936
    if ( $dirTagOnly )
5647
    {
5937
    {
-
 
5938
        Error("SetPermissions:  --DirPerms or --Perms not supplied for setting perms with --DirTagOnly") 
-
 
5939
            if ( ! defined($dirPerms) );
-
 
5940
        Information("SetPermissions: Setting permissions on top level dir only [$topDir] to " . $dirPerms);
5648
        $item = "$m_sDirAbsoluteValue";
5941
        chmodFile($topDir, $dirPerms);
-
 
5942
        return;
5649
    }
5943
    }
-
 
5944
 
-
 
5945
    Information("SetPermissions: Called with options " . join(", ", @_));
-
 
5946
 
-
 
5947
 
-
 
5948
    #
-
 
5949
    #   Create a list of files/dirs to process
5650
    else
5950
    #
-
 
5951
    my @elements = $search->search( $topDir );
-
 
5952
    Warning ("setPermissions: No files located") unless ( @elements );
-
 
5953
 
-
 
5954
    foreach my $dirEntry ( @elements )
5651
    {
5955
    {
5652
        $item = "$m_sDirAbsoluteValue/$m_sfile";
5956
        my $fullPath = "$topDir/$dirEntry";
-
 
5957
 
-
 
5958
        # A dir and we dont have dirperms, so skip
-
 
5959
        if ( -d $fullPath && !defined($dirPerms) )
-
 
5960
        {
-
 
5961
            Debug2("SetPermissions: Skipping dir $fullPath as we have no dir permissions");
-
 
5962
            next;
-
 
5963
        }
-
 
5964
 
-
 
5965
        # A file and we dont have fileperms, so skip
-
 
5966
        if ( -f $fullPath && !defined($filePerms) )
-
 
5967
        {
-
 
5968
            Debug2("SetPermissions: Skipping file $fullPath as we have no file permissions");
-
 
5969
            next;
-
 
5970
        }
-
 
5971
 
-
 
5972
        # a file or a dir and have the right permissions and we are not recursing
-
 
5973
        if ( -f $fullPath || -d $fullPath )
-
 
5974
        {
-
 
5975
            chmodFile($fullPath, ( -f $fullPath ) ? $filePerms : $dirPerms);
-
 
5976
        }
-
 
5977
        else
-
 
5978
        {
-
 
5979
            Warning("SetPermissions: Skipping $fullPath as its not a file or directory");
-
 
5980
        }
5653
    }
5981
    }
5654
 
5982
 
5655
    # check to see if item exists
-
 
-
 
5983
 
5656
    #
5984
    #
5657
    if ( ! -f "$item" && 
5985
    #   Process the topDir
-
 
5986
    #   May not be modified if --SkipDirTag has been requested
-
 
5987
    #
5658
         ! -d "$item" )
5988
    if ( !$skipDirTag && defined($dirPerms) )
5659
    {
5989
    {
5660
        Error("Failed to find item [$item]. Check deploy config."); 
5990
        chmodFile($topDir, $dirPerms);
5661
    }
5991
    }
-
 
5992
 
-
 
5993
}   # setPermissions
-
 
5994
 
-
 
5995
 
-
 
5996
#------------------------------------------------------------------------------
-
 
5997
sub chmod
-
 
5998
#
-
 
5999
# Description:
-
 
6000
#       This sub-routine is used to change the ownership of a file or
-
 
6001
#       directory structure.
-
 
6002
#
-
 
6003
#------------------------------------------------------------------------------
-
 
6004
{
-
 
6005
    # correct number of parameters?
5662
    Verbose("chmod: Changing permisions of file [$m_sfile] in dirtag [$m_sDirTag] to [$m_ownPerms]");
6006
    Error("Incorrect number of params passed to chmod() function. Check deploy config.") if ( ($#_+1) != 3 );
-
 
6007
 
-
 
6008
    # lets setup the passed values.
5663
    chmodFile("$item", $m_ownPerms);
6009
    my ($m_sDirTag, $m_sfile, $m_ownPerms) = @_;
-
 
6010
 
-
 
6011
    Warning("chmod has been deprecated by and now calls setPermissions, see deploylib.pm");
-
 
6012
 
-
 
6013
    # call setPermissions, if no File then do DirTagOnly, otherwise set FilterIn=File
-
 
6014
    setPermissions($m_sDirTag, "--NoRecurse", 
-
 
6015
                    ($m_sfile) ? "--DirPerms=$m_ownPerms" : "--FilePerms=$m_ownPerms",
-
 
6016
                    ($m_sfile) ? "--DirTagOnly"           : "--FilterIn=$m_sfile" );
5664
 
6017
 
5665
    return 1;
6018
    return 1;
5666
}
6019
}
5667
 
6020
 
5668
 
6021
 
Line 5674... Line 6027...
5674
#       the target packgae.
6027
#       the target packgae.
5675
#
6028
#
5676
#------------------------------------------------------------------------------
6029
#------------------------------------------------------------------------------
5677
{
6030
{
5678
    # correct number of parameters?
6031
    # correct number of parameters?
5679
    if ( ($#_+1) != 2 )
-
 
5680
    {
-
 
5681
        Error("Incorrect number of params passed to " .
-
 
5682
                  "chmodRecursive() function. Check deploy config.");
6032
    Error("Incorrect number of params passed to chmodRecursive() function. Check deploy config.") if ( ($#_+1) != 2 );
5683
    }
-
 
5684
 
6033
 
5685
    # lets setup the passed values.
6034
    # lets setup the passed values.
5686
    my ($m_sDirTag, $m_ownPerms) = @_;
6035
    my ($m_sDirTag, $m_ownPerms) = @_;
5687
 
6036
 
5688
    # lets just check to see if the perms are in correct format.
-
 
5689
    #
-
 
5690
    if ( "$m_ownPerms" !~ m/^[0-9][0-9][0-9][0-9]$/ )
-
 
5691
    {
-
 
5692
        Error("chmod() does not support [$m_ownPerms] permission, use format 0755 etc.");
6037
    Warning("chmodRecursive has been deprecated by and now calls setPermissions, see deploylib.pm");
5693
        return 1;
-
 
5694
    }
-
 
5695
 
-
 
5696
 
-
 
5697
    # lets get the absolute src dir value
-
 
5698
    my ($m_sDirAbsoluteValue) = getTargetDstDirValue($m_sDirTag, "A");
-
 
5699
 
6038
 
5700
 
-
 
5701
    # check to see if item exists
-
 
5702
    #
-
 
5703
    if ( ! -f "$m_sDirAbsoluteValue" &&
-
 
5704
         ! -d "$m_sDirAbsoluteValue" )
-
 
5705
    {
-
 
5706
        Error("Failed to find item [$m_sDirAbsoluteValue]. " .
-
 
5707
                  "Check deploy config."); 
-
 
5708
    }
-
 
5709
 
-
 
5710
 
-
 
5711
    # if its a not a dir
-
 
5712
    #
-
 
5713
    if ( ! -d "$m_sDirAbsoluteValue" && -f "$m_sDirAbsoluteValue" )
-
 
5714
    {
-
 
5715
        Warning("chmodRecursive: This should not happen as dirtag [$m_sDirTag] is a file, changings perms to [$m_ownPerms] anyway");
-
 
5716
        chmodFile("$m_sDirAbsoluteValue", $m_ownPerms);
-
 
5717
    }
-
 
5718
    else
-
 
5719
    {
-
 
5720
        # it must be a dir
-
 
5721
        Verbose("chmodRecursive: Recursively setting perms on dirtag [$m_sDirTag] to [$m_ownPerms]");
6039
    # call setPermissions, if no File then do DirTagOnly, otherwise set FilterIn=File
5722
        chmodDir("$m_sDirAbsoluteValue", $m_ownPerms);
6040
    setPermissions($m_sDirTag, "--Recurse", "--Perms=$m_ownPerms");
5723
    }
-
 
5724
 
6041
 
5725
    return 1;
6042
    return 1;
5726
}
6043
}
5727
 
6044
 
5728
 
6045
 
Line 5738... Line 6055...
5738
#       finds a dir it recurses into that dir chmod'ing it as well.
6055
#       finds a dir it recurses into that dir chmod'ing it as well.
5739
#
6056
#
5740
#------------------------------------------------------------------------------
6057
#------------------------------------------------------------------------------
5741
{
6058
{
5742
    # correct number of parameters?
6059
    # correct number of parameters?
5743
    if ( ($#_+1) != 2 )
-
 
5744
    {
-
 
5745
        Error("Incorrect number of params passed to " .
6060
    Error("Incorrect number of params passed to chmodDir() function.") if ( ($#_+1) != 2 );
5746
                  "chmodDir() function.");
-
 
5747
    }
-
 
5748
 
6061
 
5749
    my ($startingPoint, $perms) = @_;
6062
    my ($startingPoint, $perms) = @_;
5750
 
6063
 
-
 
6064
    Warning("chmodDir has been deprecated by setPermissions, see deploylib.pm");
-
 
6065
 
5751
    Verbose("chmodDir: Recursively setting permsision of [$startingPoint] to [$perms]");
6066
    Verbose("chmodDir: Recursively setting permsision of [$startingPoint] to [$perms]");
5752
 
6067
 
5753
    local *DIR;
6068
    local *DIR;
5754
    opendir(DIR, $startingPoint) or
-
 
5755
        Error("can't opendir $startingPoint: $!");
6069
    opendir(DIR, $startingPoint) or Error("can't opendir $startingPoint: $!");
5756
 
6070
 
5757
    my ($item);
6071
    my ($item);
5758
    while (defined($item = readdir(DIR)))
6072
    while (defined($item = readdir(DIR)))
5759
    {
6073
    {
5760
        if ( "$item" !~ /^\.$/  &&
-
 
5761
             "$item" !~ /^\.\.$/ )
6074
        if ( "$item" !~ /^\.$/  && "$item" !~ /^\.\.$/ )
5762
        {
6075
        {
5763
            if ( -d "$startingPoint/$item" )
6076
            if ( -d "$startingPoint/$item" )
5764
            {
6077
            {
5765
                chmodDir("$startingPoint/$item", $perms);
6078
                chmodDir("$startingPoint/$item", $perms);
5766
            }
6079
            }
Line 5782... Line 6095...
5782
 
6095
 
5783
 
6096
 
5784
#------------------------------------------------------------------------------
6097
#------------------------------------------------------------------------------
5785
sub chmodFile
6098
sub chmodFile
5786
#
6099
#
5787
#    this function is used to chmod the perms od an item
6100
#    this function is used to chmod the perms of an item
5788
#    it is passed the absolute path to the item and the associated 
6101
#    it is passed the absolute path to the item and the associated 
5789
#    perms.
6102
#    perms.
5790
#
6103
#
5791
#------------------------------------------------------------------------------
6104
#------------------------------------------------------------------------------
5792
{
6105
{
5793
    my ($item, $perms) = @_;
6106
    my ($item, $perms) = @_;
5794
 
6107
 
5795
    my ($cmd) = "CORE::chmod $perms, $item";
-
 
5796
    my ($noItems) = CORE::chmod oct($perms), $item;
6108
    my ($noItems) = CORE::chmod oct($perms), $item;
5797
    if ( $noItems == 0 )
6109
    if ( $noItems == 0 )
5798
    {
6110
    {
5799
        Error("Failed to complete command [$cmd], retVal=[$noItems]");
6111
        Error("ERROR: Failed to chmod $item=$perms, retVal=[$noItems]");
5800
    }
6112
    }
5801
    else
6113
    else
5802
    {
6114
    {
5803
        Debug("Executed command: [$cmd]");
6115
        Debug("Successfully chmod $item=$perms");
5804
    }
6116
    }
5805
 
6117
 
5806
    return 1;
6118
    return 1;
5807
}
6119
}
5808
 
6120
 
Line 5874... Line 6186...
5874
#       This sub-routine is used to create the required package prototype file
6186
#       This sub-routine is used to create the required package prototype file
5875
#       fom a known directory struture using the a=b format.
6187
#       fom a known directory struture using the a=b format.
5876
#
6188
#
5877
#------------------------------------------------------------------------------
6189
#------------------------------------------------------------------------------
5878
{
6190
{
5879
    my ($opt_keep_mask, @args);
6191
    my ($opt_keep_mask, $opt_keep_links, @args);
5880
 
6192
 
5881
    #
6193
    #
5882
    #   Process the arguments and extract parameters and options
6194
    #   Process the arguments and extract parameters and options
5883
    #
6195
    #
5884
    foreach ( @_ )
6196
    foreach ( @_ )
5885
    {
6197
    {
5886
        if ( m/^--KeepMask/ ) {
6198
        if ( m/^--KeepMask/ ) {
5887
            $opt_keep_mask = 1;
6199
            $opt_keep_mask = 1;
5888
 
6200
 
-
 
6201
        } elsif ( m/^--KeepLinks/ ) {
-
 
6202
            $opt_keep_links = 1;
-
 
6203
 
5889
        } elsif ( m/^--/ ) {
6204
        } elsif ( m/^--/ ) {
5890
            Error("createPrototypeFile2: Unknown option: $_")
6205
            Error("createPrototypeFile2: Unknown option: $_")
5891
 
6206
 
5892
        } else {
6207
        } else {
5893
            push @args, $_;
6208
            push @args, $_;
Line 5956... Line 6271...
5956
    #
6271
    #
5957
    $m_UID  = $uid;
6272
    $m_UID  = $uid;
5958
    $m_GID  = $gid;
6273
    $m_GID  = $gid;
5959
    $m_MASK = $mask;
6274
    $m_MASK = $mask;
5960
    $m_KEEP_MASK = $opt_keep_mask;
6275
    $m_KEEP_MASK = $opt_keep_mask;
-
 
6276
    $m_KEEP_LINKS = $opt_keep_links;
5961
 
6277
 
5962
 
6278
 
5963
    # now we need to add entries for each directory we will 
6279
    # now we need to add entries for each directory we will 
5964
    # be installing 
6280
    # be installing 
5965
    File::Find::find(\&prototype2Find, "$targetBaseDir");
6281
    File::Find::find(\&prototype2Find, "$targetBaseDir");
Line 6134... Line 6450...
6134
            }
6450
            }
6135
 
6451
 
6136
            open ( FILE, ">> $pfile") or
6452
            open ( FILE, ">> $pfile") or
6137
                Error("Failed to open file [$pfile].");
6453
                Error("Failed to open file [$pfile].");
6138
 
6454
 
-
 
6455
            if ( $m_KEEP_LINKS && -l "$m_sfile" )
-
 
6456
            {
-
 
6457
                my $linkDest = readlink($m_sfile);
-
 
6458
                Warning("Link $m_sfile has an absolute path, may not be a problem but make sure its what you want") if ( $linkDest =~ /^\// );
-
 
6459
                printf FILE ("s none $file=$linkDest\n");
-
 
6460
            }
6139
            if ( -f "$m_sfile" )
6461
            elsif ( -f "$m_sfile" )
6140
            {
6462
            {
6141
                printf FILE ("f none $file=$file $fmask $m_UID $m_GID\n");
6463
                printf FILE ("f none $file=$file $fmask $m_UID $m_GID\n");
6142
            }
6464
            }
6143
 
-
 
6144
            if ( -d "$m_sfile" )
6465
            elsif ( -d "$m_sfile" )
6145
            {
6466
            {
6146
                printf FILE ("d none $file $fmask $m_UID $m_GID\n");
6467
                printf FILE ("d none $file $fmask $m_UID $m_GID\n");
6147
            }
6468
            }
6148
 
6469
 
6149
            close (FILE);
6470
            close (FILE);
Line 6440... Line 6761...
6440
#       It also checks if the name provided should be excluded from
6761
#       It also checks if the name provided should be excluded from
6441
#       the build.
6762
#       the build.
6442
#
6763
#
6443
#------------------------------------------------------------------------------
6764
#------------------------------------------------------------------------------
6444
{
6765
{
-
 
6766
    my $installProdAndDebug;
-
 
6767
    my $itemName = "";
6445
   # correct number of parameters?
6768
   # correct number of parameters?
6446
    if ( ($#_+1) != 1 )
6769
    if ( (($#_+1) < 1) || (($#_+1) > 2))
6447
    {
6770
    {
6448
        Error("Incorrect number of params passed to " .
6771
        Error("Incorrect number of params passed to " .
6449
                  "getGenericNameNoVersionForLib() function. Check deploy config.");
6772
                  "getGenericNameNoVersionForLib() function. Check deploy config.");
6450
    }
6773
    }
6451
 
6774
 
-
 
6775
    #
-
 
6776
    #   Process parameters and extract options
-
 
6777
    #
-
 
6778
    foreach  ( @_ )
-
 
6779
    {
-
 
6780
        if ( m/^--InstallProdAndDebug/ ) {
-
 
6781
            # not sure if the filename conventions allow the installation
-
 
6782
            # of both prod/debug files on windows, so limit this to sparc/unix.
-
 
6783
            if ( "$MachType" ne "sparc" ){
-
 
6784
                Error("Can only use the InstallProdAndDebug option for sparc.");
-
 
6785
            }
-
 
6786
 
-
 
6787
            $installProdAndDebug = 1;
-
 
6788
        } else {
-
 
6789
            $itemName = $_;
-
 
6790
        }
-
 
6791
    }
-
 
6792
 
6452
    # lets just check to see if we can execute this function on
6793
    # lets just check to see if we can execute this function on
6453
    # this machine.
6794
    # this machine.
6454
    #
6795
    #
6455
    if ( "$MachType" ne "sparc" )
6796
    if ( "$MachType" ne "sparc" )
6456
    {
6797
    {
6457
        Verbose("getGenericNameNoVersionForLib() not supported on this machine type.");
6798
        Verbose("getGenericNameNoVersionForLib() not supported on this machine type.");
6458
        return "";
6799
        return "";
6459
    }
6800
    }
6460
 
6801
 
6461
 
6802
 
6462
    my($itemName) = @_;
-
 
6463
 
-
 
6464
    # first we need to check to see if it belongs in this build
6803
    # first we need to check to see if it belongs in this build.
6465
    #
-
 
-
 
6804
    # if we've been told that both P & D are allowed, skip this check.
6466
    my ($gName) = "";
6805
    my ($gName) = "";
6467
    if(excludeItemFromBuild($itemName))
6806
    if( !$installProdAndDebug && excludeItemFromBuild($itemName))
6468
    {
6807
    {
6469
        Verbose("Excluding item [$itemName] from build as not compatible with build type " .
6808
        Verbose("Excluding item [$itemName] from build as not compatible with build type " .
6470
                "[$BuildType].");
6809
                "[$BuildType].");
6471
        return "";  # file should be excluded.
6810
        return "";  # file should be excluded.
6472
    }
6811
    }
Line 7693... Line 8032...
7693
}
8032
}
7694
 
8033
 
7695
#===============================================================================
8034
#===============================================================================
7696
#
8035
#
7697
#   Internal Package
8036
#   Internal Package
7698
#   An attempt to simplify the WildCardinf interface by capturing the parameters
8037
#   An attempt to simplify the WildCarding interface by capturing the parameters
7699
#   in a package. The idea is that storing the arguments can be easier
8038
#   in a package. The idea is that storing the arguments can be easier
7700
#
8039
#
7701
package LocateFiles;
8040
package LocateFiles;
7702
use JatsError;
8041
use JatsError;
7703
 
8042
 
Line 7716... Line 8055...
7716
    $self->{recurse}  = 0;
8055
    $self->{recurse}  = 0;
7717
    $self->{exclude}  = [];
8056
    $self->{exclude}  = [];
7718
    $self->{include}  = [];
8057
    $self->{include}  = [];
7719
    $self->{base_dir} = undef;
8058
    $self->{base_dir} = undef;
7720
    $self->{results}  = [];
8059
    $self->{results}  = [];
-
 
8060
    $self->{dirs_too} = 0;
7721
    bless ($self, $class);
8061
    bless ($self, $class);
7722
 
8062
 
7723
    #
8063
    #
7724
    #   Process user arguments
8064
    #   Process user arguments
7725
    #   These are are a hash
8065
    #   These are are a hash
Line 7732... Line 8072...
7732
    }
8072
    }
7733
    return $self;
8073
    return $self;
7734
}
8074
}
7735
 
8075
 
7736
#-------------------------------------------------------------------------------
8076
#-------------------------------------------------------------------------------
7737
# Function        : recurse
8077
# Function        :  Class accessor fucntions
7738
#                   filter_in
8078
#                   recurse                     - Recurse subdirs
7739
#                   filter_in_re
8079
#                   filter_in                   - Filter in these files
-
 
8080
#                   filter_in_re                - Filter in (Regular Expression)
7740
#                   filter_out
8081
#                   filter_out                  - Filter out these files
7741
#                   filter_out_re
8082
#                   filter_out_re               - Filter out (RE)
7742
#                   base_dir
8083
#                   base_dir                    - Base dir for search
-
 
8084
#                   results                     - Results of the last search
-
 
8085
#                   dirs_too                    - Include dirs in the search
-
 
8086
#                   has_filter                  - Has any filter been defined
7743
#                   results
8087
#                   search                      - Perform the search
7744
#
8088
#
7745
# Description     : Accessor functions
8089
# Description     : Accessor functions
7746
#
8090
#
7747
# Inputs          : class
8091
# Inputs          : class
7748
#                   One argument (optional)
8092
#                   One argument (optional)
Line 7782... Line 8126...
7782
    my $self = shift;
8126
    my $self = shift;
7783
    if (@_) { push @{$self->{exclude}}, shift }
8127
    if (@_) { push @{$self->{exclude}}, shift }
7784
    return $self->{exclude};
8128
    return $self->{exclude};
7785
}
8129
}
7786
 
8130
 
-
 
8131
sub dirs_too
-
 
8132
{
-
 
8133
    my $self = shift;
-
 
8134
    if (@_) { $self->{dirs_too} = shift }
-
 
8135
    return $self->{dirs_too};
-
 
8136
}
-
 
8137
 
7787
sub base_dir
8138
sub base_dir
7788
{
8139
{
7789
    my $self = shift;
8140
    my $self = shift;
7790
    if (@_) { $self->{base_dir} = shift }
8141
    if (@_) { $self->{base_dir} = shift }
7791
    return $self->{base_dir};
8142
    return $self->{base_dir};
Line 7809... Line 8160...
7809
# Returns         : List of files that match the search criteria
8160
# Returns         : List of files that match the search criteria
7810
#
8161
#
7811
 
8162
 
7812
my @search_list;             # Must be global to avoid closure problems
8163
my @search_list;             # Must be global to avoid closure problems
7813
my $search_len;
8164
my $search_len;
-
 
8165
my $search_base_dir;
-
 
8166
my $search_dirs_too;
7814
 
8167
 
7815
sub search
8168
sub search
7816
{
8169
{
7817
    my $self = shift;
8170
    my $self = shift;
7818
    $self->{base_dir} = $_[0] if (defined $_[0] );
8171
    $self->{base_dir} = $_[0] if (defined $_[0] );
Line 7845... Line 8198...
7845
    #       1) Start with a '/'
8198
    #       1) Start with a '/'
7846
    #       2) Are rooted as $dir, but don't include $dir
8199
    #       2) Are rooted as $dir, but don't include $dir
7847
    #
8200
    #
7848
    if ( $self->{recurse} )
8201
    if ( $self->{recurse} )
7849
    {
8202
    {
-
 
8203
        $search_dirs_too = $self->{dirs_too};
-
 
8204
        $search_base_dir = $self->{base_dir};
7850
        sub find_file_wanted
8205
        sub find_file_wanted
7851
        {
8206
        {
7852
            return if ( -d $_ );
8207
            return if ( !$search_dirs_too && -d $_ );               # skip if current is dir and we are not including dirs
-
 
8208
            return if ( $search_base_dir eq $File::Find::name );    # skip if current is base_dir as we dont include it
7853
            my $file = $File::Find::name;
8209
            my $file = $File::Find::name;
7854
            push @search_list, substr($file, $search_len );
8210
            push @search_list, substr($file, $search_len );
7855
        }
8211
        }
7856
 
8212
 
7857
        #
8213
        #
Line 7872... Line 8228...
7872
        opendir DIR, $self->{base_dir} || die ("Cannot open $self->{base_dir}");
8228
        opendir DIR, $self->{base_dir} || die ("Cannot open $self->{base_dir}");
7873
        foreach ( readdir( DIR ) )
8229
        foreach ( readdir( DIR ) )
7874
        {
8230
        {
7875
            next if /^\Q.\E$/;
8231
            next if /^\Q.\E$/;
7876
            next if /^\Q..\E$/;
8232
            next if /^\Q..\E$/;
7877
            next if ( -d "$self->{base_dir}/$_" );
8233
            next if ( !$self->{dirs_too} && -d "$self->{base_dir}/$_" );
7878
            push @search_list, '/' . $_;
8234
            push @search_list, '/' . $_;
7879
 
8235
 
7880
        }
8236
        }
7881
        closedir DIR;
8237
        closedir DIR;
7882
    }
8238
    }