Subversion Repositories DevTools

Rev

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

Rev 5217 Rev 6088
Line 28... Line 28...
28
#
28
#
29
#                   Transfer it to the users 'BIN' directory, where it is
29
#                   Transfer it to the users 'BIN' directory, where it is
30
#                   available to be packaged.
30
#                   available to be packaged.
31
#
31
#
32
#                 Summary of directives available to the user-script:
32
#                 Summary of directives available to the user-script:
-
 
33
#                       Message                 - Display progress text
33
#                       AddInitScript           - Add an init script
34
#                       AddInitScript           - Add an init script
34
#                       CatFile                 - Append to a file
35
#                       CatFile                 - Append to a file
35
#                       ConvertFile             - Convert file(s) to Unix or Dos Text
36
#                       ConvertFile             - Convert file(s) to Unix or Dos Text
36
#                       CopyDir                 - Copy directory tree
37
#                       CopyDir                 - Copy directory tree
37
#                       CopyFile                - Copy a file
38
#                       CopyFile                - Copy a file
38
#                       CopyBinFile             - Copy an executable file
39
#                       CopyBinFile             - Copy an executable file
39
#                       CopyLibFile             - Copy a library file
40
#                       CopyLibFile             - Copy a library file
-
 
41
#                       CopyDebPackage          - Copy a Debian Package
40
#                       CreateDir               - Create a directory
42
#                       CreateDir               - Create a directory
41
#                       DebianFiles             - Specify control and script files
43
#                       DebianFiles             - Specify control and script files
42
#                       DebianControlFile       - Specify control and script files
44
#                       DebianControlFile       - Specify control and script files
43
#                       DebianDepends           - Add Depends entry to control file
45
#                       DebianDepends           - Add Depends entry to control file
44
#                       EchoFile                - Place text into a file
46
#                       EchoFile                - Place text into a file
Line 49... Line 51...
49
#                       SetVerbose              - Control progress display
51
#                       SetVerbose              - Control progress display
50
#                       IsProduct               - Flow control
52
#                       IsProduct               - Flow control
51
#                       IsPlatform              - Flow control
53
#                       IsPlatform              - Flow control
52
#                       IsTarget                - Flow control
54
#                       IsTarget                - Flow control
53
#                       IsVariant               - Flow control
55
#                       IsVariant               - Flow control
-
 
56
#                       IsAlias                 - Flow control
54
#
57
#
55
#                 Thoughts for expansion:
58
#                 Thoughts for expansion:
56
#                       SrcDir                  - Extend path for resolving local files
59
#                       SrcDir                  - Extend path for resolving local files
57
#
60
#
58
#                   Less used:
61
#                   Less used:
Line 130... Line 133...
130
#
133
#
131
#   Globals
134
#   Globals
132
#
135
#
133
my @ResolveFileList;                    # Cached Package File List
136
my @ResolveFileList;                    # Cached Package File List
134
my @ResolveBinFileList;                 # Cached PackageBin File List
137
my @ResolveBinFileList;                 # Cached PackageBin File List
-
 
138
my @ResolveDebFileList;                 # Cached PackageDeb File List
135
my @ResolveLibFileList;                 # Cached PackageLib File List
139
my @ResolveLibFileList;                 # Cached PackageLib File List
136
my %DebianControlFiles;                 # Control Files
140
my %DebianControlFiles;                 # Control Files
137
my %DebianControlFileNames;             # Control Files by name
141
my %DebianControlFileNames;             # Control Files by name
138
my @DependencyList;                     # Package Dependencies
142
my @DependencyList;                     # Package Dependencies
139
my @ConfigList;                         # Config Files
143
my @ConfigList;                         # Config Files
Line 215... Line 219...
215
    ReadBuildConfig ($opt_interfacedir, $opt_platform, '--NoTest' );
219
    ReadBuildConfig ($opt_interfacedir, $opt_platform, '--NoTest' );
216
 
220
 
217
    #
221
    #
218
    #   Build the package image in a directory based on the target being created
222
    #   Build the package image in a directory based on the target being created
219
    #
223
    #
220
    $DebianWorkDirBase = "$opt_platform$opt_type.image";
224
    $DebianWorkDirBase = uc("$opt_platform$opt_type.image");
221
    $DebianWorkDir = "$DebianWorkDirBase/$opt_name";
225
    $DebianWorkDir = "$DebianWorkDirBase/$opt_name";
222
 
226
 
223
    #
227
    #
224
    #   Configure the System command to fail on any error
228
    #   Configure the System command to fail on any error
225
    #
229
    #
Line 817... Line 821...
817
{
821
{
818
    CopyFileCommon( \&ResolveLibFile, @_ );
822
    CopyFileCommon( \&ResolveLibFile, @_ );
819
}
823
}
820
 
824
 
821
#-------------------------------------------------------------------------------
825
#-------------------------------------------------------------------------------
-
 
826
# Function        : CopyDebianPackage
-
 
827
#
-
 
828
# Description     : Copy a Debian Package to a target dir
-
 
829
#                   Will look in places where Debian Packages are stored.
-
 
830
#
-
 
831
# Inputs          : $src        - BaseName for 'Debian Package' (no version, no extension)
-
 
832
#                   $dst_dir    - Within the output workspace
-
 
833
#                   Optional arguments embedded into the BaseName
-
 
834
#                   --Arch=XXXX         - Architecture - if not current
-
 
835
#                   --Product=XXXX      - Product - if required
-
 
836
#                   --Debug             - If not the current type
-
 
837
#                   --Prod              - If not the current type
-
 
838
#
-
 
839
# Returns         : Full path to destination file
-
 
840
#
-
 
841
# Notes           : Copying Debian Packages from external packages
-
 
842
#
-
 
843
#                   The tool will attempt to copy a well-formed debian packages
-
 
844
#                   These are:
-
 
845
#                   
-
 
846
#                       "BaseName_VersionString[_Product]_Arch${PkgType}.deb";
-
 
847
#                   
-
 
848
#                   Where 'Product' is optional (and rare)
-
 
849
#                   Where 'PkgType' is P or D or nothing
-
 
850
#                   Where 'Arch' may be 'all'
-
 
851
#                   
-
 
852
#                   The routine will locate Debian packages in
-
 
853
#                       - The root of the package
-
 
854
#                       - bin/TARGET[P|D/]
-
 
855
#                       - bin/Arch[P|D]
-
 
856
#
-
 
857
#
-
 
858
sub CopyDebianPackage
-
 
859
{
-
 
860
    CopyFileCommon( \&ResolveDebPackage, @_ );
-
 
861
}
-
 
862
 
-
 
863
#-------------------------------------------------------------------------------
822
# Function        : CopyFileCommon
864
# Function        : CopyFileCommon
823
#
865
#
824
# Description     : Common ( internal File Copy )
866
# Description     : Common ( internal File Copy )
825
#
867
#
826
# Inputs          : $resolver           - Ref to function to resolve source file
868
# Inputs          : $resolver           - Ref to function to resolve source file
Line 1935... Line 1977...
1935
#-------------------------------------------------------------------------------
1977
#-------------------------------------------------------------------------------
1936
# Function        : IsProduct
1978
# Function        : IsProduct
1937
#                   IsPlatform
1979
#                   IsPlatform
1938
#                   IsTarget
1980
#                   IsTarget
1939
#                   IsVariant
1981
#                   IsVariant
-
 
1982
#                   IsAlias
1940
#
1983
#
1941
# Description     : This function allows some level of control in the
1984
# Description     : This function allows some level of control in the
1942
#                   packaging scripts. It will return true if the current
1985
#                   packaging scripts. It will return true if the current
1943
#                   product is listed.
1986
#                   product is listed.
1944
#
1987
#
Line 1985... Line 2028...
1985
        return 1 if ( $opt_variant eq $_ );
2028
        return 1 if ( $opt_variant eq $_ );
1986
    }
2029
    }
1987
    return 0;
2030
    return 0;
1988
}
2031
}
1989
 
2032
 
-
 
2033
my %opt_aliases;
-
 
2034
sub IsAlias
-
 
2035
{
-
 
2036
 
-
 
2037
    #
-
 
2038
    #   Get the aliases from the build info
-
 
2039
    #   This function was introduced late so its not always available
-
 
2040
    #
-
 
2041
    Error("IsAlias not supported in this version of JATS")
-
 
2042
        unless (defined &ReadBuildConfig::getAliases);
-
 
2043
    #
-
 
2044
    #   Create an hash of aliases to simplify testing
-
 
2045
    #   Do it onceand cache the results
-
 
2046
    #
-
 
2047
    unless (%opt_aliases) {
-
 
2048
        %opt_aliases = map { $_ => 1 } getAliases();
-
 
2049
    }
-
 
2050
 
-
 
2051
    foreach ( @_ )
-
 
2052
    {
-
 
2053
        return 1 if ( exists $opt_aliases{$_} );
-
 
2054
    }
-
 
2055
    return 0;
-
 
2056
}
-
 
2057
 
-
 
2058
 
1990
#************ INTERNAL USE ONLY  **********************************************
2059
#************ INTERNAL USE ONLY  **********************************************
1991
# Function        : FindFiles
2060
# Function        : FindFiles
1992
#
2061
#
1993
# Description     : Locate files within a given dir tree
2062
# Description     : Locate files within a given dir tree
1994
#
2063
#
Line 2435... Line 2504...
2435
        splice (@done, 1);
2504
        splice (@done, 1);
2436
    }
2505
    }
2437
    return wantarray ? @done : $done[0];
2506
    return wantarray ? @done : $done[0];
2438
}
2507
}
2439
 
2508
 
-
 
2509
#-------------------------------------------------------------------------------
-
 
2510
# Function        : ResolveDebPackage
-
 
2511
#
-
 
2512
# Description     : Determine where the source for a Debian Package is
-
 
2513
#                   Will look in (default):
-
 
2514
#                       Local directory
-
 
2515
#                       Local Include
-
 
2516
#                   Or  (FromPackage)
-
 
2517
#                       Our Package directory
-
 
2518
#                       Interface directory (BuildPkgArchives)
-
 
2519
#                       Packages (LinkPkgArchive)
-
 
2520
#
-
 
2521
# Inputs          : $from_package   - 0:Local File
-
 
2522
#                   $baseName       - Basename for a 'DebianPackage'
-
 
2523
#                                     Do not provide version info, architecture or suffix
-
 
2524
#                                     May contain embedded options
-
 
2525
#                                       --Arch=XXX      - Specify alternate architcute
-
 
2526
#                                       --Product=YYYY  - Specify product family
-
 
2527
#                                       --Debug         - Use alternate build type
-
 
2528
#                                       --Prod          - Use alternate build type
-
 
2529
#
-
 
2530
# Returns         : Path
-
 
2531
#
-
 
2532
sub ResolveDebPackage
-
 
2533
{
-
 
2534
    my ($from_package, $file) = @_;
-
 
2535
    my @path;
-
 
2536
    my $arch;
-
 
2537
    my $product;
-
 
2538
    my $buildType;
-
 
2539
    my @types;
-
 
2540
    my $baseName;
-
 
2541
    my @options;
-
 
2542
 
-
 
2543
    #
-
 
2544
    #   Extract options from file
-
 
2545
    #
-
 
2546
    ($baseName, @options) = split ( ',', $file);
-
 
2547
    foreach ( @options )
-
 
2548
    {
-
 
2549
        if ( m/^--Arch=(.+)/ ) {
-
 
2550
            $arch=$1;
-
 
2551
        } elsif ( m/^--Product=(.+)/ ) {
-
 
2552
            $product = $1;
-
 
2553
        } elsif ( m/^--Debug/ ) {
-
 
2554
            Error ("ResolveDebPackage: Cannot specify --Prod and --Debug") if defined $buildType;
-
 
2555
            $buildType = 'D';
-
 
2556
        } elsif ( m/^--Prod/ ) {
-
 
2557
            Error ("ResolveDebPackage: Cannot specify --Prod and --Debug") if defined $buildType;
-
 
2558
            $buildType = 'P';
-
 
2559
        } else {
-
 
2560
            Error ("Unknown suboption to ResolveDebPackage: $_" );
-
 
2561
        }
-
 
2562
    }
-
 
2563
 
-
 
2564
    #
-
 
2565
    #   Insert defaults
-
 
2566
    #
-
 
2567
    $buildType = $opt_type unless ($buildType);
-
 
2568
    $arch = $opt_target unless ($arch);
-
 
2569
 
-
 
2570
    #
-
 
2571
    #   Determine the paths to search
-
 
2572
    #
-
 
2573
    if ( $from_package )
-
 
2574
    {
-
 
2575
        unless ( @ResolveDebFileList )
-
 
2576
        {
-
 
2577
            push @ResolveDebFileList,  $opt_pkgdir, $opt_pkgdir . '/bin';
-
 
2578
            foreach my $entry ( getPackageList() )
-
 
2579
            {
-
 
2580
                if ( my $path = $entry->getBase(3) )
-
 
2581
                {
-
 
2582
                    push @ResolveDebFileList, $path if ( -d $path );
-
 
2583
 
-
 
2584
                    $path .= '/bin';
-
 
2585
                    push @ResolveDebFileList, $path if ( -d $path );
-
 
2586
                }
-
 
2587
            }
-
 
2588
        }
-
 
2589
        @path = @ResolveDebFileList;
-
 
2590
        @types = ($opt_type, '');
-
 
2591
    }
-
 
2592
    else
-
 
2593
    {
-
 
2594
        @path = ($opt_bindir, $opt_localbindir);
-
 
2595
        @types = ($opt_type, '');
-
 
2596
    }
-
 
2597
 
-
 
2598
    #
-
 
2599
    #   The debian  package name is
-
 
2600
    #   In packages BIN dir
-
 
2601
    #       (BaseName)_VersionString(_Product)(_Arch).deb
-
 
2602
    #       
-
 
2603
    #   In root of package
-
 
2604
    #       (BaseName)_VersionString(_Product)(_Arch)(_Type).deb
-
 
2605
    #
-
 
2606
    #       
-
 
2607
    #   The package may be found in
-
 
2608
    #       Package Root
-
 
2609
    #       Package bin directory
-
 
2610
    #       
-
 
2611
    $file = $baseName . '_*';
-
 
2612
    if (defined $product) {
-
 
2613
        $file .= ( '_' . $product)
-
 
2614
        }
-
 
2615
    $file .= '_' . $arch;
-
 
2616
 
-
 
2617
    #
-
 
2618
    #   Determine a full list of 'parts' to search
-
 
2619
    #   This is provided within the build information
-
 
2620
    #
-
 
2621
    my @parts = getPlatformParts ();
-
 
2622
    push @parts, '';
-
 
2623
 
-
 
2624
    my @done;
-
 
2625
    foreach my $root (  @path )
-
 
2626
    {
-
 
2627
        foreach my $subdir ( @parts )
-
 
2628
        {
-
 
2629
            foreach my $type ( @types )
-
 
2630
            {
-
 
2631
                my $sfile;
-
 
2632
                $sfile = "$root/$subdir$type/$file";
-
 
2633
                $sfile =~ s~//~/~g;
-
 
2634
                foreach my $type2 ( @types )
-
 
2635
                {
-
 
2636
                    my $tfile = $sfile;
-
 
2637
                    $tfile .= '_' . $type2 if $type2;
-
 
2638
                    $tfile .= '.deb';
-
 
2639
                    Verbose2("ResolveDebPackage: $tfile");
-
 
2640
                    foreach  ( glob ( $tfile ) )
-
 
2641
                    {
-
 
2642
                        push @done, $_;
-
 
2643
                    }
-
 
2644
                }
-
 
2645
            }
-
 
2646
        }
-
 
2647
    }
-
 
2648
 
-
 
2649
    Error ("ResolveDebPackage: Package not found: $file", "Search Path:", @path)
-
 
2650
        unless ( @done );
-
 
2651
 
-
 
2652
    if ( $#done > 0 )
-
 
2653
    {
-
 
2654
        Error ("ResolveDebPackage: Multiple instances of Package found.", @done);
-
 
2655
    }
-
 
2656
    return wantarray ? @done : $done[0];
-
 
2657
}
-
 
2658
 
-
 
2659
 
2440
 
2660
 
2441
#-------------------------------------------------------------------------------
2661
#-------------------------------------------------------------------------------
2442
# Function        : AUTOLOAD
2662
# Function        : AUTOLOAD
2443
#
2663
#
2444
# Description     : Intercept bad user directives and issue a nice error message
2664
# Description     : Intercept bad user directives and issue a nice error message