Subversion Repositories DevTools

Rev

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

Rev 1542 Rev 1544
Line 1... Line 1...
1
#==============================================================================
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 $
2
# Copyright (C) 2006 ERG Limited, All rights reserved
7
#
3
#
8
# Program Name        : deploylib.pm
4
# Program Name        : deploylib.pm
9
#
5
#
10
# Program Type        : Perl Module (.pm)
6
# Program Type        : Perl Module (.pm)
11
#
7
#
Line 14... Line 10...
14
# Description / Purpose:
10
# Description / Purpose:
15
#      Deploylib is a set of high-level functions written in Perl (for portability) 
11
#      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 
12
#      that allow a user to quickly setup a deployment configuration and produce a 
17
#      deliverable package.
13
#      deliverable package.
18
#
14
#
-
 
15
# Description:
-
 
16
#
-
 
17
#
19
#==============================================================================
18
#......................................................................#
20
 
19
 
-
 
20
require 5.6.1;
21
 
21
 
22
#------------------------------------------------------------------------------
22
#------------------------------------------------------------------------------
23
# Package definition
23
# Package definition
24
#------------------------------------------------------------------------------
24
#------------------------------------------------------------------------------
25
package deploylib;
25
package deploylib;
26
 
26
 
27
#------------------------------------------------------------------------------
27
#------------------------------------------------------------------------------
28
# Pragmas
28
# Pragmas
29
#------------------------------------------------------------------------------
29
#------------------------------------------------------------------------------
30
require 5.005;
-
 
31
use strict;
30
use strict;
32
use Getopt::Std;
31
use Getopt::Std;
33
use File::Copy;
32
use File::Copy;
34
use File::Find;
33
use File::Find;
35
use File::Basename;
34
use File::Basename;
Line 133... Line 132...
133
 
132
 
134
                    &getErgAfcBaseDir
133
                    &getErgAfcBaseDir
135
                    &getGenericNameNoVersionForLib
134
                    &getGenericNameNoVersionForLib
136
                    &getGenericNameForLib
135
                    &getGenericNameForLib
137
                    &createZip
136
                    &createZip
-
 
137
                    &generateXmlDependancy
138
 
138
 
139
                    %TargetDstDirStructure
139
                    %TargetDstDirStructure
140
                    %LocalSrcDirStructure
140
                    %LocalSrcDirStructure
141
                    %BuildPkgArchive
141
                    %BuildPkgArchive
142
                    $MachType
142
                    $MachType
Line 6979... Line 6979...
6979
    }
6979
    }
6980
 
6980
 
6981
    return 1;
6981
    return 1;
6982
}
6982
}
6983
 
6983
 
-
 
6984
#-------------------------------------------------------------------------------
-
 
6985
# Function        : generateXmlDependancy
-
 
6986
#
-
 
6987
# Description     : Generate an XML file that describes the despendencies of the
-
 
6988
#                   released package.
-
 
6989
#
-
 
6990
#                   The generated file needs to be packaged for deployment. This
-
 
6991
#                   function will only create the file. It needs to be added to the
-
 
6992
#                   files that are deployed into the field. The file is primarily
-
 
6993
#                   to be used by Windows based applications, but its use may be
-
 
6994
#                   extended to other platforms.
-
 
6995
#
-
 
6996
#                   The file 'should' be deployed in the same directory as the main
-
 
6997
#                   application executable, so that the executable may locate it.
-
 
6998
#
-
 
6999
#                   The XML file is named after the package. It is prefixed with
-
 
7000
#                   the string "PkgInfo_".
-
 
7001
#
-
 
7002
#                   By default file will be placed in the 'TargetBaseDir'.
-
 
7003
#                   This behaviour may be modified by the user.
-
 
7004
#
-
 
7005
#                   Refer to package_info.xsd for details on the structure of the
-
 
7006
#                   generated XML file. Do not randomly chnage the structure.
-
 
7007
#                   It is being used.
-
 
7008
#
-
 
7009
#                   This function requires access to Release Manager in order
-
 
7010
#                   to locate the package description and build-time information
-
 
7011
#
-
 
7012
#                   The function will use the current/last version of the package
-
 
7013
#                   in an attempt to locate package information.
-
 
7014
#
-
 
7015
#
-
 
7016
# Inputs          : platform        - Platforms for which the file will be created
-
 
7017
#                                     '*' indicate ALL platforms.
-
 
7018
#                   options         - Options to control the detail of the generated file
-
 
7019
#
-
 
7020
#                   Valid options
-
 
7021
#                       --TargetDir         - Symbolic target directory
-
 
7022
#                                             Default: TargetBaseDir
-
 
7023
#
-
 
7024
#                       --Depth=nn          - Depth to traverse the dependancy tree
-
 
7025
#                                             All packages below this depth will be ignored
-
 
7026
#                                             Default: 0. All packages will be included
-
 
7027
#                       --VisibleDepth=nn   - Package beyond this depth will be marked as invisible
-
 
7028
#                                             Default: 1. Only top level packages will be marked
-
 
7029
#                                             as visible.
-
 
7030
#                       --Ignore=name       - Ignore this package
-
 
7031
#                                             It will not be included in the dependancy list
-
 
7032
#                                             Default: None
-
 
7033
#                       --IgnoreChildren=name   - Do not include children of this package\
-
 
7034
#                                             Default: None
-
 
7035
#                       --Invisible=name    - Mark this package and its dependents as invisible
-
 
7036
#                                             Default: None
-
 
7037
#                       --InvisibleChildren=name
-
 
7038
#                                           - Mark this package as visible, but its dependents as invisible
-
 
7039
#                                             Default: None
-
 
7040
#
-
 
7041
# Example:
-
 
7042
#               generateXmlDependancy('*', '--TargetDir=OcpDir' );
-
 
7043
#               
-
 
7044
#
-
 
7045
# Returns         : Nothing
-
 
7046
#
-
 
7047
sub generateXmlDependancy
-
 
7048
{
-
 
7049
    my ($platforms, @opts) = @_;
-
 
7050
    my %data;
-
 
7051
    my $filename = "PkgInfo_$PkgName" . '.xml';
-
 
7052
    my $targetTag;
-
 
7053
 
-
 
7054
    return if ( ! ActivePlatform($platforms) );
-
 
7055
    Information("Generating XML dependancy information from RM data: $filename");
-
 
7056
 
-
 
7057
    #
-
 
7058
    #   Insert defaults
-
 
7059
    #
-
 
7060
    $data{default_visible} = 1;
-
 
7061
 
-
 
7062
    #
-
 
7063
    #   Parse the user options
-
 
7064
    #
-
 
7065
    foreach ( @opts )
-
 
7066
    {
-
 
7067
        if ( m/^--Depth=(\d+)/ ) {
-
 
7068
            $data{default_depth} = $1;
-
 
7069
 
-
 
7070
        } elsif ( m/^--VisibleDepth=(\d+)/ ) {
-
 
7071
            $data{default_visible} = $1;
-
 
7072
 
-
 
7073
        } elsif ( m/^--Ignore=(.*)/ ) {
-
 
7074
            $data{ignore}{$1} = 1;
-
 
7075
 
-
 
7076
        } elsif ( m/^--IgnoreChildren=(.*)/ ) {
-
 
7077
            $data{ignore_child}{$1} = 1;
-
 
7078
 
-
 
7079
        } elsif ( m/^--Invisible=(.*)/ ) {
-
 
7080
            $data{invisible}{$1} = 1;
-
 
7081
 
-
 
7082
        } elsif ( m/^--InvisibleChildren=(.*)/ ) {
-
 
7083
            $data{invisible_child}{$1} = 1;
-
 
7084
 
-
 
7085
        } elsif ( m/^--TargetDir=(.*)/ ) {
-
 
7086
            $targetTag = $1;
-
 
7087
 
-
 
7088
        } else {
-
 
7089
            Error ("generateXmlDependancy: Unknown option: $_");
-
 
7090
        }
-
 
7091
    }
-
 
7092
 
-
 
7093
    #
-
 
7094
    #   Sanity Tests
-
 
7095
    #
-
 
7096
    if ( $data{default_visible} && $data{default_depth} )
-
 
7097
    {
-
 
7098
        Error ("generateXmlDependancy:Visible depth must be less than total depth")
-
 
7099
            if ( $data{default_visible} > $data{default_depth} );
-
 
7100
    }
-
 
7101
 
-
 
7102
    # lets check to see if the target tag exists
-
 
7103
    # if does not the process with log an error.
-
 
7104
    #
-
 
7105
    my $targetValue;
-
 
7106
    if ( $targetTag )
-
 
7107
    {
-
 
7108
        $targetValue = getTargetDstDirValue($targetTag, "A");
-
 
7109
    }
-
 
7110
    else
-
 
7111
    {
-
 
7112
        $targetValue = "$PkgBaseDir/$TargetBaseDir";
-
 
7113
    }
-
 
7114
    $filename = $targetValue . '/' . $filename;
-
 
7115
    
-
 
7116
 
-
 
7117
    #
-
 
7118
    #   Determine package information.
-
 
7119
    #   Must cater for a number of situations
-
 
7120
    #       1) Package rebuild
-
 
7121
    #       2) Package ripple
-
 
7122
    #       3) New package
-
 
7123
    #
-
 
7124
 
-
 
7125
 
-
 
7126
    # Set defaults for elements in RM if not found
-
 
7127
    DeployUtils::RmPkgInfo->DefaultDescription($PkgDesc);
-
 
7128
    DeployUtils::RmPkgInfo->DefaultLabel($PkgLabel);
-
 
7129
 
-
 
7130
    #
-
 
7131
    #   Try with the current package version. It may be in RM
-
 
7132
    #
-
 
7133
    $RmPkgDetails = DeployUtils::RmPkgInfo->new( {
-
 
7134
                        PKG_NAME => $PkgName,
-
 
7135
                        PKG_VERSION => $PkgVersionUser,
-
 
7136
                        NO_WARN => 1
-
 
7137
                    } );
-
 
7138
 
-
 
7139
    unless ( $RmPkgDetails->foundDetails() && $PkgPreviousVersionStr )
-
 
7140
    {
-
 
7141
        #
-
 
7142
        #   Try with the 'Previous' package
-
 
7143
        #
-
 
7144
        my $RmPkgDetailsPrev = DeployUtils::RmPkgInfo->new( {
-
 
7145
                        PKG_NAME => $PkgName,
-
 
7146
                        PKG_VERSION => $PkgPreviousVersionStr,
-
 
7147
                        NO_WARN => 1
-
 
7148
                    } );
-
 
7149
 
-
 
7150
        if ( $RmPkgDetailsPrev->foundDetails() )
-
 
7151
        {
-
 
7152
            Information ("generateXmlDependancy. Using previous version ($PkgPreviousVersionStr)");
-
 
7153
            $RmPkgDetails = $RmPkgDetailsPrev;
-
 
7154
        }
-
 
7155
    }
-
 
7156
 
-
 
7157
    unless ( $RmPkgDetails->foundDetails() )
-
 
7158
    {
-
 
7159
        Warning ("generateXmlDependancy. Package Information not in RM. Using defaults");
-
 
7160
    }
-
 
7161
 
-
 
7162
 
-
 
7163
    #
-
 
7164
    #   %packages   - information on packages that we have discovered
-
 
7165
    #   @to_process - An array of packages discovered, but not yet processed
-
 
7166
    #
-
 
7167
    my @to_process;
-
 
7168
 
-
 
7169
    #
-
 
7170
    #   Create the initial entry in the packages array
-
 
7171
    #
-
 
7172
    my @deps;
-
 
7173
    foreach my $i ( $BuildFileInfo->getDpkgArchiveList() )
-
 
7174
    {
-
 
7175
        my $moduleInfo = $BuildFileInfo->getDpkgArchiveInfo($i);
-
 
7176
        my $tag = join ($;, $i, $moduleInfo->{versionFull} );
-
 
7177
        push @deps, $tag;
-
 
7178
    }
-
 
7179
 
-
 
7180
    $data{packages}{$PkgName}{$PkgVersionUser}{date} = $RmPkgDetails->pv_modified_time() || localtime() ;
-
 
7181
    $data{packages}{$PkgName}{$PkgVersionUser}{overview} = $RmPkgDetails->pv_description();
-
 
7182
    $data{packages}{$PkgName}{$PkgVersionUser}{deps} = [ @deps ] ;
-
 
7183
 
-
 
7184
 
-
 
7185
    push @to_process, @deps;
-
 
7186
 
-
 
7187
    while ( my $entry = pop @to_process )
-
 
7188
    {
-
 
7189
        my ($package, $version) = split ( $;, $entry );
-
 
7190
 
-
 
7191
        #
-
 
7192
        #   Extract and save information for this package
-
 
7193
        #
-
 
7194
        next if ( exists $data{packages}{$package}{$version} );
-
 
7195
 
-
 
7196
        #
-
 
7197
        #   Some packages need to be totally ignored
-
 
7198
        #
-
 
7199
        next if ( exists $data{ignore}{$package} );
-
 
7200
 
-
 
7201
        my $RmPkgDetails = DeployUtils::RmPkgInfo->new(
-
 
7202
                        {
-
 
7203
                            PKG_NAME => $package,
-
 
7204
                            PKG_VERSION => $version,
-
 
7205
                        } );
-
 
7206
        Error ("generateXmlDependancy: Cannot locate base package: $package, $version")
-
 
7207
            unless ( $RmPkgDetails->foundPkg() );
-
 
7208
 
-
 
7209
        #
-
 
7210
        #   Determine the dependancies, unless we are ignoring the children too
-
 
7211
        #   Do not use the RmPkgInfo class method getDependencyNames to fetch the
-
 
7212
        #   dependancy information as this:
-
 
7213
        #       1) gets it wrong
-
 
7214
        #       2) Extracts a lot of data that we dont want.
-
 
7215
        #
-
 
7216
        my @deps;
-
 
7217
        unless ( exists $data{ignore_child}{$package} )
-
 
7218
        {
-
 
7219
            my $deps = $RmPkgDetails->getDependenciesHash();
-
 
7220
            foreach my $pkg ( keys %{$deps} )
-
 
7221
            {
-
 
7222
                foreach my $ver ( keys %{$deps->{$pkg}}  )
-
 
7223
                {
-
 
7224
                    my $tag = join ($;, $pkg, $ver );
-
 
7225
                    push @deps, $tag;
-
 
7226
                }
-
 
7227
            }
-
 
7228
        }
-
 
7229
 
-
 
7230
        $data{packages}{$package}{$version}{date} = $RmPkgDetails->pv_modified_time();
-
 
7231
        $data{packages}{$package}{$version}{overview} = $RmPkgDetails->pv_description();
-
 
7232
        $data{packages}{$package}{$version}{deps} = [ @deps ] ;
-
 
7233
 
-
 
7234
        push @to_process, @deps;
-
 
7235
    }
-
 
7236
#DebugDumpData ("Packages", \%packages);
-
 
7237
 
-
 
7238
    #
-
 
7239
    #   Now walk the tree and generate XML
-
 
7240
    #
-
 
7241
    sub output_entry
-
 
7242
    {
-
 
7243
        my ($datap, $depth, $package, $version, $vis ) = @_;
-
 
7244
        my $fh = $datap->{fh};
-
 
7245
        $depth++;
-
 
7246
 
-
 
7247
        #
-
 
7248
        #   Skip if too deep or an ignored package
-
 
7249
        #
-
 
7250
        return if ( $datap->{ignore}{$package} );
-
 
7251
        return if ( $datap->{default_depth} && $depth > $datap->{default_depth} );
-
 
7252
 
-
 
7253
        #
-
 
7254
        #   Check for invisible packages
-
 
7255
        #
-
 
7256
        $vis = 0 if ( $datap->{invisible}{$package} );
-
 
7257
 
-
 
7258
 
-
 
7259
        my $indent = "    " x ($depth - 1);
-
 
7260
        my $date = $datap->{packages}{$package}{$version}{date};
-
 
7261
        my $overview = $datap->{packages}{$package}{$version}{overview};
-
 
7262
 
-
 
7263
        #
-
 
7264
        #   Clean up the overview
-
 
7265
        #
-
 
7266
        $overview =~ s~\s+$~~;
-
 
7267
        $overview =~ s~\r\n~\n~g;
-
 
7268
        $overview =~ s~\n\r~\n~g;
-
 
7269
 
-
 
7270
        #
-
 
7271
        #   Determine visibility
-
 
7272
        #
-
 
7273
        $vis = 0 if ( $datap->{default_visible} && $depth > $datap->{default_visible} );
-
 
7274
        my $visible = ( $vis > 0 ) ? 'true' : 'false';
-
 
7275
        $vis = 0 if ( $datap->{invisible_child}{$package} );
-
 
7276
 
-
 
7277
        #
-
 
7278
        #   The top level entry is different
-
 
7279
        #
-
 
7280
        if ( $depth == 0 )
-
 
7281
        {
-
 
7282
            $indent = "    " ;
-
 
7283
            print $fh "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
-
 
7284
            print $fh "<ERG_Package xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"package_info.xsd\" SchemaVersion=\"1.0.0\">\n";
-
 
7285
            print $fh "$indent<Package_Name>$package</Package_Name>\n";
-
 
7286
            print $fh "$indent<Package_Version>$version</Package_Version>\n";
-
 
7287
            print $fh "$indent<Package_Overview>$overview</Package_Overview>\n";
-
 
7288
            print $fh "$indent<Build_Date>$date</Build_Date>\n";
-
 
7289
        }
-
 
7290
        else
-
 
7291
        {
-
 
7292
            print $fh "${indent}<Package Name=\"$package\" Version=\"$version\" BuildDate=\"$date\" Visible=\"$visible\">\n";
-
 
7293
		    print $fh "${indent}    ";
-
 
7294
            print $fh "<Overview>${overview}" if ($overview);
-
 
7295
		    print $fh "</Overview>\n";
-
 
7296
        }
-
 
7297
 
-
 
7298
        #
-
 
7299
        #   Process dependancies
-
 
7300
        #
-
 
7301
        unless ( $datap->{ignore_child}{$package} )
-
 
7302
        {
-
 
7303
            foreach my $entry ( @{ $datap->{packages}{$package}{$version}{deps} } )
-
 
7304
            {
-
 
7305
                my ($package, $version) = split ( $;, $entry );
-
 
7306
                output_entry ( $datap, $depth, $package, $version, $vis );
-
 
7307
            }
-
 
7308
        }
-
 
7309
 
-
 
7310
        if ( $depth == 0 )
-
 
7311
        {
-
 
7312
            print $fh "</ERG_Package>\n";
-
 
7313
        }
-
 
7314
        else
-
 
7315
        {
-
 
7316
		    print $fh "${indent}</Package>\n";
-
 
7317
        }
-
 
7318
    }
-
 
7319
 
-
 
7320
    #
-
 
7321
    #   Output the XML header and information about the first package
-
 
7322
    #
-
 
7323
    Information ( "Creating file $filename" );
-
 
7324
    open ( $data{fh}, ">", $filename ) || Error( "Cannot create $filename");
-
 
7325
    output_entry ( \%data, -1, $PkgName, $PkgVersionUser, 1 );
-
 
7326
    close $data{fh};
-
 
7327
 
-
 
7328
#    DebugDumpData( "DATA", \%data );
-
 
7329
}
6984
 
7330
 
6985
 
7331
 
6986
#------------------------------------------------------------------------------
7332
#------------------------------------------------------------------------------
6987
sub createPerlSvcWin32
7333
sub createPerlSvcWin32
6988
#
7334
#
Line 7301... Line 7647...
7301
    {
7647
    {
7302
        Verbose2 ( "$text: $name [$umask_text] - already exists");
7648
        Verbose2 ( "$text: $name [$umask_text] - already exists");
7303
    }
7649
    }
7304
}
7650
}
7305
 
7651
 
-
 
7652
 
-
 
7653
#-------------------------------------------------------------------------------
-
 
7654
# Function        : ActivePlatform
-
 
7655
#
-
 
7656
# Description     : Determine if the specified platform is currently 'active'
-
 
7657
#                   This is used by all user directives in order to determine
-
 
7658
#                   if the directive should be ignored for the current platform
-
 
7659
#
-
 
7660
# Inputs          : $platform_spec      - A (simple)platform specifier
-
 
7661
#
-
 
7662
# Returns         : TRUE if the platform spec contains the current platform
-
 
7663
#
-
 
7664
sub ActivePlatform
-
 
7665
{
-
 
7666
    my( $platform_spec ) = @_;
-
 
7667
 
-
 
7668
    Error ("No platform specified in some directive") unless ( $platform_spec );
-
 
7669
 
-
 
7670
    #
-
 
7671
    #   Wild card
-
 
7672
    #
-
 
7673
    return 1 if ( $platform_spec eq '*' );
-
 
7674
 
-
 
7675
    #
-
 
7676
    #   Simple test
-
 
7677
    #
-
 
7678
    foreach ( split (',', $platform_spec))
-
 
7679
    {
-
 
7680
        return 1 if ( $_ eq $Platform );
-
 
7681
    }
-
 
7682
 
-
 
7683
    #
-
 
7684
    #   Not for me
-
 
7685
    #
-
 
7686
    return 0;
-
 
7687
}
-
 
7688
 
7306
#------------------------------------------------------------------------------
7689
#------------------------------------------------------------------------------
7307
1;
7690
1;