Subversion Repositories DevTools

Rev

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

Rev 6859 Rev 6861
Line 1... Line 1...
1
########################################################################
1
########################################################################
2
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
3
#
3
#
4
# Module name   : DebianPackager.pl
4
# Module name   : DebianPackager.pl
5
# Module type   : Makefile system
5
# Module type   : Makefile system
6
# Compiler(s)   : Perl
6
# Compiler(s)   : Perl
7
# Environment(s): jats
7
# Environment(s): jats
Line 36... Line 36...
36
#                       Tar Gzip the image
36
#                       Tar Gzip the image
37
#                       Transfer it to the users 'BIN' directory, where it is available to be packaged.
37
#                       Transfer it to the users 'BIN' directory, where it is available to be packaged.
38
#
38
#
39
#                 Summary of directives available to the user-script:
39
#                 Summary of directives available to the user-script:
40
#                       Message                 - Display progress text
40
#                       Message                 - Display progress text
-
 
41
#                       Verbose                 - Display progress text
41
#                       AddInitScript           - Add an init script
42
#                       AddInitScript           - Add an init script
42
#                       CatFile                 - Append to a file
43
#                       CatFile                 - Append to a file
43
#                       ConvertFile             - Convert file(s) to Unix or Dos Text
44
#                       ConvertFile             - Convert file(s) to Unix or Dos Text
44
#                       CopyDir                 - Copy directory tree
45
#                       CopyDir                 - Copy directory tree
45
#                       CopyFile                - Copy a file
46
#                       CopyFile                - Copy a file
46
#                       CopyBinFile             - Copy an executable file
47
#                       CopyBinFile             - Copy an executable file
47
#                       CopyLibFile             - Copy a library file
48
#                       CopyLibFile             - Copy a library file
48
#                       CopyDebPackage          - Copy a Debian Package
49
#                       CopyDebPackage          - Copy a Debian Package
49
#                       CreateDir               - Create a directory
50
#                       CreateDir               - Create a directory
-
 
51
#                       AllFiles                - Specify control and script files 
50
#                       DebianFiles             - Specify control and script files (Debian Only)
52
#                       DebianFiles             - Specify control and script files (Debian Only)
51
#                       RpmFiles                - Specify control and script files (RPM Only)
53
#                       RpmFiles                - Specify control and script files (RPM Only)
-
 
54
#                       AllControlFile          - Specify control and script files
52
#                       DebianControlFile       - Specify control and script files (Debian Only)
55
#                       DebianControlFile       - Specify control and script files (Debian Only)
53
#                       RpmControlFile          - Specify control and script files (RPM Only)
56
#                       RpmControlFile          - Specify control and script files (RPM Only)
54
#                       AllControlFile          - Specify control and script files (Debian and RPM)
57
#                       AllDepends               - Add Depends entry to control file
55
#                       DebianDepends           - Add Depends entry to control file (Debian Only)
58
#                       DebianDepends           - Add Depends entry to control file (Debian Only)
56
#                       RpmDepends              - Add Depends entry to control file (RPM Only)
59
#                       RpmDepends              - Add Depends entry to control file (RPM Only)
57
#                       AllDepends              - Add Depends entry to control file (Debian and RPM)
-
 
58
#                       EchoFile                - Place text into a file
60
#                       EchoFile                - Place text into a file
59
#                       MakeSymLink             - Create a symbolic link
61
#                       MakeSymLink             - Create a symbolic link
60
#                       PackageDescription      - Specify the package description
62
#                       PackageDescription      - Specify the package description
61
#                       ReplaceTags             - Replace Tags on target file
63
#                       ReplaceTags             - Replace Tags on target file
62
#                       SetFilePerms            - Set file permissions
64
#                       SetFilePerms            - Set file permissions
Line 67... Line 69...
67
#                       IsVariant               - Flow control
69
#                       IsVariant               - Flow control
68
#                       IsAlias                 - Flow control
70
#                       IsAlias                 - Flow control
69
#                       RpmSetDefAttr           - Specify default file properties (RPM Only)
71
#                       RpmSetDefAttr           - Specify default file properties (RPM Only)
70
#                       RpmSetAttr              - Specify file properties (RPM Only)    
72
#                       RpmSetAttr              - Specify file properties (RPM Only)    
71
#                       SetBaseDir              - Sets base for installed files (RPM Hint for directory ownership)
73
#                       SetBaseDir              - Sets base for installed files (RPM Hint for directory ownership)
-
 
74
#                       Section                 - Set current section
72
#
75
#
73
#                 Thoughts for expansion:
76
#                 Thoughts for expansion:
74
#                       SrcDir                  - Extend path for resolving local files
77
#                       SrcDir                  - Extend path for resolving local files
75
#
78
#
76
#                   Less used:
79
#                   Less used:
Line 96... Line 99...
96
use ArrayHashUtils;
99
use ArrayHashUtils;
97
use JatsError;
100
use JatsError;
98
use JatsLocateFiles;
101
use JatsLocateFiles;
99
use ReadBuildConfig;
102
use ReadBuildConfig;
100
use JatsCopy ();                            # Don't import anything
103
use JatsCopy ();                            # Don't import anything
-
 
104
use PackagerUtils;
101
 
105
 
102
#
106
#
103
#   Command line options
107
#   Command line options
104
#
108
#
105
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
109
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
Line 122... Line 126...
122
my $opt_pkglibdir;
126
my $opt_pkglibdir;
123
my $opt_pkgbindir;
127
my $opt_pkgbindir;
124
my $opt_pkgpkgdir;
128
my $opt_pkgpkgdir;
125
my $opt_noarch;
129
my $opt_noarch;
126
my $opt_tarFile;
130
my $opt_tarFile;
-
 
131
my $opt_tarOnly;
127
my $opt_rpm = 0;
132
my $opt_rpm = 0;
128
my $opt_debian = 0;
133
my $opt_debian = 0;
129
my $opt_output;
134
my $opt_output;
130
 
135
 
131
#
136
#
Line 166... Line 171...
166
my @ConfigList;                             # Config Files
171
my @ConfigList;                             # Config Files
167
my %opt_aliases;                            # Cached Alias Names
172
my %opt_aliases;                            # Cached Alias Names
168
my @RpmDefAttr = ('-','root','root','-');   # RPM: Default File Attributes
173
my @RpmDefAttr = ('-','root','root','-');   # RPM: Default File Attributes
169
my @RpmAttrList;                            # RPM: File attributes
174
my @RpmAttrList;                            # RPM: File attributes
170
my %OwnedDirs;                              # RPM: Dirs marked as owned
175
my %OwnedDirs;                              # RPM: Dirs marked as owned
171
 
-
 
-
 
176
my $ActiveSection = 1;                      # Indicates if the section is active
172
 
177
 
173
#-------------------------------------------------------------------------------
178
#-------------------------------------------------------------------------------
174
# Function        : Main Entry point
179
# Function        : Main Entry point
175
#
180
#
176
# Description     : This function will be called when the package is initialised
181
# Description     : This function will be called when the package is initialised
Line 211... Line 216...
211
                'PackagePkgDir=s'   => \$opt_pkgpkgdir,
216
                'PackagePkgDir=s'   => \$opt_pkgpkgdir,
212
                'Variant:s'         => \$opt_variant,
217
                'Variant:s'         => \$opt_variant,
213
                'PkgArch:s'         => \$opt_pkgarch,
218
                'PkgArch:s'         => \$opt_pkgarch,
214
                'NoArch'            => \$opt_noarch,
219
                'NoArch'            => \$opt_noarch,
215
                'tarFile=s'         => \$opt_tarFile,
220
                'tarFile=s'         => \$opt_tarFile,
-
 
221
                'tarOnly'           => \$opt_tarOnly,
216
                'genRpm'            => \$opt_rpm,
222
                'genRpm'            => \$opt_rpm,
217
                'genDeb'            => \$opt_debian,
223
                'genDeb'            => \$opt_debian,
218
                'output=s'          => \$opt_output,
224
                'output=s'          => \$opt_output,
219
                'script=s'          => \$opt_package_script,
225
                'script=s'          => \$opt_package_script,
220
                'rpmRelease=s'      => \$opt_rpmRelease,
226
                'rpmRelease=s'      => \$opt_rpmRelease,
Line 264... Line 270...
264
    #   Defaults
270
    #   Defaults
265
    #
271
    #
266
    $opt_pkgarch = $opt_platform unless ( $opt_pkgarch );
272
    $opt_pkgarch = $opt_platform unless ( $opt_pkgarch );
267
 
273
 
268
    #
274
    #
-
 
275
    #   Determine build operations
-
 
276
    #   
-
 
277
    my $genDebian = $opt_debian;
-
 
278
    my $genRpm = $opt_rpm;
-
 
279
    if ($opt_tarOnly) {
-
 
280
        $genDebian = $genRpm = 0; 
-
 
281
    }
-
 
282
     
-
 
283
 
-
 
284
    #
269
    #   Display variables used
285
    #   Display variables used
270
    #
286
    #
271
    Message    ("= Building Installer ================================================");
287
    Message    ("= Building Installer ================================================");
272
    Message    ("        Format: Debian") if ($opt_debian);
288
    Message    ("        Format: Debian") if ($genDebian);
273
    Message    ("        Format: RPM") if ($opt_rpm);
289
    Message    ("        Format: RPM") if ($genRpm);
274
    Message    ("        Format: TGZ") if ($opt_tarFile);
290
    Message    ("        Format: TGZ") if ($opt_tarFile);
275
    Message    ("          Name: $opt_name");
291
    Message    ("          Name: $opt_name");
276
    Message    ("       Package: $opt_buildname");
292
    Message    ("       Package: $opt_buildname");
277
    Message    ("       Variant: $opt_variant") if ($opt_variant);
293
    Message    ("       Variant: $opt_variant") if ($opt_variant);
278
    Message    ("       Version: $opt_buildversion");
294
    Message    ("       Version: $opt_buildversion");
Line 282... Line 298...
282
    Message    ("          Type: $opt_type");
298
    Message    ("          Type: $opt_type");
283
    Message    ("   RPM Release: $opt_rpmRelease") if ($opt_rpmRelease);
299
    Message    ("   RPM Release: $opt_rpmRelease") if ($opt_rpmRelease);
284
    Message    ("      Pkg Arch: $opt_pkgarch") if ($opt_pkgarch);
300
    Message    ("      Pkg Arch: $opt_pkgarch") if ($opt_pkgarch);
285
    Verbose    ("       Verbose: $opt_verbose");
301
    Verbose    ("       Verbose: $opt_verbose");
286
    Verbose    ("  InterfaceDir: $opt_interfacedir");
302
    Verbose    ("  InterfaceDir: $opt_interfacedir");
287
    Message    ("        Output: " . StripDir($opt_output));
303
    Message    ("        Output: " . StripDir($opt_output))  if ($genDebian || $genRpm);
288
    Message    ("        Output: " . StripDir($opt_tarFile)) if $opt_tarFile;
304
    Message    ("        Output: " . StripDir($opt_tarFile)) if $opt_tarFile;
289
    Message    ("======================================================================");
305
    Message    ("======================================================================");
290
 
306
 
291
    #
307
    #
292
    #   Perform Clean up
308
    #   Perform Clean up
Line 335... Line 351...
335
    #   Invoke the user script to do the hard work
351
    #   Invoke the user script to do the hard work
336
    #
352
    #
337
    unless (my $return = do $opt_package_script) {
353
    unless (my $return = do $opt_package_script) {
338
            Error ("Couldn't parse $opt_package_script: $@") if $@;
354
            Error ("Couldn't parse $opt_package_script: $@") if $@;
339
            Error ("Couldn't do $opt_package_script: $!") unless defined $return;
355
            Error ("Couldn't do $opt_package_script: $!") unless defined $return;
340
        }
356
        };
-
 
357
    $ActiveSection = 1;
341
 
358
 
342
    #
359
    #
343
    #   Now have an image of the directory that we wish to package
360
    #   Now have an image of the directory that we wish to package
344
    #   Complete the building of the package
361
    #   Complete the building of the package
345
    #
362
    #
346
    if ($opt_tarFile)
363
    if ($opt_tarFile) {
347
    {
-
 
348
        BuildTarFile();
364
        BuildTarFile();
349
        Message ("Created TGZ file");
365
        Message ("Created TGZ file");
350
    }
366
    }
351
 
367
 
352
    #
368
    #
353
    #   Create an RPM
369
    #   Create an RPM
354
    #
370
    #
355
    if ($opt_rpm)
371
    if ($genRpm) {
356
    {
-
 
357
        BuildRPM ();
372
        BuildRPM ();
358
        Message ("Created RPM");
373
        Message ("Created RPM");
359
    }
374
    }
360
 
375
 
-
 
376
    #
361
    if ($opt_debian)
377
    #   Create a Debian Package
362
    {
378
    #
-
 
379
    if ($genDebian) {
363
        BuildDebianPackage ();
380
        BuildDebianPackage ();
364
        Message ("Created Debian Package");
381
        Message ("Created Debian Package");
365
    }
382
    }
366
}
383
}
367
 
384
 
Line 498... Line 515...
498
            '--file', $opt_tarFile,
515
            '--file', $opt_tarFile,
499
            '.'
516
            '.'
500
            );
517
            );
501
}
518
}
502
 
519
 
-
 
520
#-------------------------------------------------------------------------------
-
 
521
# Function        : Section 
-
 
522
#
-
 
523
# Description     : Allows the Package file to be split into section
-
 
524
#                   This direcive is always active.
-
 
525
#
-
 
526
# Inputs          : Selector
-
 
527
#                       ALL     - Active
-
 
528
#                       RPM     - Active section when building an RPM
-
 
529
#                       DEBIAN  - Active section if build a Debian package
-
 
530
#                       TAR     - Active section if building a TAR
-
 
531
#
-
 
532
# Returns         : Nothing
-
 
533
#                   Will fkag to indicate if directives are active. 
-
 
534
#
-
 
535
sub Section
-
 
536
{
-
 
537
    my $newActiveSection;
-
 
538
    my $flip = sub {
-
 
539
        my ($val, $mode) = @_;
-
 
540
        if ( defined $mode) {
-
 
541
            return $val ? 0 : 1;
-
 
542
        }
-
 
543
        return $val;
-
 
544
    };
-
 
545
 
-
 
546
    $newActiveSection = 1 unless (@_);
-
 
547
    foreach my $arg ( @_)
-
 
548
    {
-
 
549
        if ($arg =~ m/^(!)*DEBIAN/i) {
-
 
550
            $newActiveSection = 1 if  $flip->($opt_debian, $1);
-
 
551
 
-
 
552
        } elsif ($arg =~ m/^(!)*RPM/i) {
-
 
553
            $newActiveSection = 1 if  $flip->($opt_rpm, $1);
-
 
554
 
-
 
555
        } elsif ($arg =~ m/^(!)*TAR/i) {
-
 
556
            $newActiveSection = 1 if $flip->($opt_tarFile, $1);
-
 
557
 
-
 
558
        } elsif (uc($arg) eq 'ALL') {
-
 
559
            $newActiveSection = 1;
-
 
560
 
-
 
561
        } elsif ( $arg eq 1  ) {
-
 
562
                $newActiveSection = 1;
-
 
563
 
-
 
564
        } elsif ( $arg eq 0  ) {
-
 
565
 
-
 
566
        } else {
-
 
567
            Warning ("Section: Unknown argument $arg");
-
 
568
        }
-
 
569
    }
-
 
570
 
-
 
571
    $ActiveSection = $newActiveSection ? 1: 0;
-
 
572
    Verbose ("Section State: $ActiveSection");
-
 
573
 
-
 
574
}
503
 
575
 
504
#-------------------------------------------------------------------------------
576
#-------------------------------------------------------------------------------
505
# Function        : UpdateDebianControlFile
577
# Function        : UpdateDebianControlFile
506
#
578
#
507
# Description     : Update the Debian 'control' file to fix up various fields
579
# Description     : Update the Debian 'control' file to fix up various fields
Line 519... Line 591...
519
# Returns         : Nothing
591
# Returns         : Nothing
520
#
592
#
521
sub UpdateDebianControlFile
593
sub UpdateDebianControlFile
522
{
594
{
523
    my($src) = @_;
595
    my($src) = @_;
-
 
596
    return 1 unless ($ActiveSection);
524
    my $dst = "$WorkDirInit/DEBIAN/control";
597
    my $dst = "$WorkDirInit/DEBIAN/control";
525
 
598
 
526
    unless ( $src )
599
    unless ( $src )
527
    {
600
    {
528
        CreateDebianControlFile();
601
        CreateDebianControlFile();
Line 582... Line 655...
582
#
655
#
583
# Returns         : 
656
# Returns         : 
584
#
657
#
585
sub CreateDebianControlFile
658
sub CreateDebianControlFile
586
{
659
{
-
 
660
    return 1 unless ($ActiveSection);
587
    my $dst = "$WorkDirInit/DEBIAN/control";
661
    my $dst = "$WorkDirInit/DEBIAN/control";
588
 
662
 
589
    Verbose ("CreateDebianControlFile: $dst" );
663
    Verbose ("CreateDebianControlFile: $dst" );
590
 
664
 
591
    my $depData = join (', ', @DependencyList );
665
    my $depData = join (', ', @DependencyList );
Line 627... Line 701...
627
# Returns         : Nothing
701
# Returns         : Nothing
628
#
702
#
629
sub UpdateRedHatControlFile
703
sub UpdateRedHatControlFile
630
{
704
{
631
    my($src) = @_;
705
    my($src) = @_;
-
 
706
    return 1 unless ($ActiveSection);
632
    my $dst = $opt_specFile;
707
    my $dst = $opt_specFile;
633
    unless ( $src )
708
    unless ( $src )
634
    {
709
    {
635
        CreateRedHatControlFile();
710
        CreateRedHatControlFile();
636
        return;
711
        return;
Line 715... Line 790...
715
    print $sf ("# Standard SPEC Tags\n");
790
    print $sf ("# Standard SPEC Tags\n");
716
    print $sf "Summary:        Installer for the $opt_name Package\n";
791
    print $sf "Summary:        Installer for the $opt_name Package\n";
717
    print $sf "Name:           $opt_name\n";
792
    print $sf "Name:           $opt_name\n";
718
    print $sf "Version:        $opt_buildversion\n";
793
    print $sf "Version:        $opt_buildversion\n";
719
    print $sf "Release:        $opt_rpmRelease\n";
794
    print $sf "Release:        $opt_rpmRelease\n";
720
    print $sf "License:        Vix Technology, All rights reserved.\n";
795
    print $sf "License:        COPYRIGHT - VIX IP PTY LTD (\"VIX\"). ALL RIGHTS RESERVED.\n";
721
    print $sf "Source:         None\n";
796
    print $sf "Source:         None\n";
722
    print $sf "BuildArch:      $opt_pkgarch\n";
797
    print $sf "BuildArch:      $opt_pkgarch\n";
723
    print $sf "Group:          VIX/System\n";
798
    print $sf "Group:          VIX/System\n";
724
    print $sf "Vendor:         Vix Technology\n";
799
    print $sf "Vendor:         Vix Technology\n";
725
    print $sf "Autoreq:        No\n";
800
    print $sf "Autoreq:        No\n";
Line 754... Line 829...
754
            close ($cf);
829
            close ($cf);
755
            print $sf "\n";
830
            print $sf "\n";
756
        }
831
        }
757
    };
832
    };
758
    
833
    
759
    #
834
    #   Run the PreInstall script as %pretrans
-
 
835
    #       %pretrans is the only script that can terminate the RPM installation
760
    &$insertRpmControlFile ('pre',   'preinst');
836
    &$insertRpmControlFile ('pretrans', 'preinst');
761
    &$insertRpmControlFile ('post',  'postinst');
837
    &$insertRpmControlFile ('post',     'postinst');
762
    &$insertRpmControlFile ('preun', 'prerm');
838
    &$insertRpmControlFile ('preun',    'prerm');
763
    &$insertRpmControlFile ('postun','postrm');
839
    &$insertRpmControlFile ('postun',   'postrm');
764
 
840
 
765
    #
841
    #
766
    #   Insert the list of files to be processed
842
    #   Insert the list of files to be processed
767
    #       Can't use /* as this will mess with permissions of the root directory. 
843
    #       Can't use /* as this will mess with permissions of the root directory. 
768
    #       Can list Top Level directories and then use *
844
    #       Can list Top Level directories and then use *
Line 907... Line 983...
907
#
983
#
908
# Returns         : 
984
# Returns         : 
909
#
985
#
910
sub SetVerbose
986
sub SetVerbose
911
{
987
{
-
 
988
    return 1 unless ($ActiveSection);
912
    my ($level) = @_;
989
    my ($level) = @_;
913
 
990
 
914
    $level = $opt_verbose unless ( $level );
991
    $level = $opt_verbose unless ( $level );
915
    $opt_verbose = $level;
992
    $opt_verbose = $level;
916
    ErrorConfig( 'verbose' => $level);
993
    ErrorConfig( 'verbose' => $level);
Line 929... Line 1006...
929
#                   Sets $WorkDir
1006
#                   Sets $WorkDir
930
#
1007
#
931
sub SetBaseDir
1008
sub SetBaseDir
932
{
1009
{
933
    my ($path, @opts) = @_;
1010
    my ($path, @opts) = @_;
-
 
1011
    return 1 unless ($ActiveSection);
934
    
1012
    
935
    my $rootdir = $path || '/';
1013
    my $rootdir = $path || '/';
936
    $rootdir = '/' . $rootdir;
1014
    $rootdir = '/' . $rootdir;
937
    $rootdir =~ s~/+~/~g; 
1015
    $rootdir =~ s~/+~/~g; 
938
    Verbose ("Setting RootDir: $rootdir");
1016
    Verbose ("Setting RootDir: $rootdir");
Line 947... Line 1025...
947
}
1025
}
948
 
1026
 
949
#-------------------------------------------------------------------------------
1027
#-------------------------------------------------------------------------------
950
# Function        : DebianFiles
1028
# Function        : DebianFiles
951
#                   RpmFiles
1029
#                   RpmFiles
-
 
1030
#                   AllFiles
952
#
1031
#
953
# Description     : Name Debian and RPM builder control files
1032
# Description     : Name Debian and RPM builder control files
954
#                   May be called multiple times
1033
#                   May be called multiple times
955
#
1034
#
956
# Inputs          :   $fName    - Name under which the function is being called
1035
# Inputs          :   $fName    - Name under which the function is being called
Line 958... Line 1037...
958
#                       --Control=file
1037
#                       --Control=file
959
#                       --PreRm=file
1038
#                       --PreRm=file
960
#                       --PostRm=file
1039
#                       --PostRm=file
961
#                       --PreInst=file
1040
#                       --PreInst=file
962
#                       --PostInst=file
1041
#                       --PostInst=file
-
 
1042
#                       --SimpleSharedLibs
963
#                         
1043
#                         
964
#
1044
#
965
# Returns         : Nothing
1045
# Returns         : Nothing
966
#
1046
#
967
sub MULTI_Files
1047
sub MULTI_Files
968
{
1048
{
969
    my $fName = shift;
1049
    my $fName = shift;
-
 
1050
    return 1 unless ($ActiveSection);
970
    Verbose ("Specify Installer Control Files and Scripts");
1051
    Verbose ("Specify Installer Control Files and Scripts");
971
    foreach  ( @_ )
1052
    foreach  ( @_ )
972
    {
1053
    {
973
        if ( m/^--Control=(.+)/i ) {
1054
        if ( m/^--Control=(.+)/i ) {
974
            MULTI_ControlFile($fName, 'control',$1)
1055
            MULTI_ControlFile($fName, 'control',$1)
Line 983... Line 1064...
983
            MULTI_ControlFile($fName, 'preinst',$1)
1064
            MULTI_ControlFile($fName, 'preinst',$1)
984
 
1065
 
985
        } elsif ( m/^--PostInst=(.+)/i ) {
1066
        } elsif ( m/^--PostInst=(.+)/i ) {
986
            MULTI_ControlFile($fName, 'postinst',$1)
1067
            MULTI_ControlFile($fName, 'postinst',$1)
987
 
1068
 
-
 
1069
        } elsif ( m/^--SimpleSharedLibs/i ) {
-
 
1070
 
-
 
1071
            my $file = catfile($WorkDirBase, 'ldconfig.sh' );
-
 
1072
 
-
 
1073
            open (my $df, '>', $file) || Error ("$fName: Cannot create:$file");
-
 
1074
            print $df "#!/bin/sh\n";
-
 
1075
            print $df "/sbin/ldconfig\n";
-
 
1076
            print $df "exit 0\n";
-
 
1077
            close $df;
-
 
1078
 
-
 
1079
            MULTI_ControlFile($fName, 'postinst',$file);
-
 
1080
            MULTI_ControlFile($fName, 'postrm',$file);
-
 
1081
 
988
        } else {
1082
        } else {
989
            Error ("$fName: Unknown option: $_");
1083
            Error ("$fName: Unknown option: $_");
990
        }
1084
        }
991
    }
1085
    }
992
}
1086
}
993
 
1087
 
994
#-------------------------------------------------------------------------------
1088
#-------------------------------------------------------------------------------
995
# Function        : DebianControlFile
1089
# Function        : DebianControlFile
996
#                   RpmControlFile 
1090
#                   RpmControlFile 
-
 
1091
#                   AllControlFile
997
#
1092
#
998
# Description     : Add special control files to the Debian/RedHat Installer 
1093
# Description     : Add special control files to the Debian/RedHat Installer 
999
#                   Not useful for embedded installers
1094
#                   Not useful for embedded installers
1000
#
1095
#
1001
#                   More general than DebianFiles() or RpmFiles
1096
#                   More general than DebianFiles() or RpmFiles
Line 1011... Line 1106...
1011
# Returns         : 
1106
# Returns         : 
1012
#
1107
#
1013
sub MULTI_ControlFile
1108
sub MULTI_ControlFile
1014
{
1109
{
1015
    my ($fName, $name, $file, @options) = @_;
1110
    my ($fName, $name, $file, @options) = @_;
-
 
1111
    return 1 unless ($ActiveSection);
1016
    my $fromPackage = 0;
1112
    my $fromPackage = 0;
1017
 
1113
 
1018
    #
1114
    #
1019
    #   Process options
1115
    #   Process options
1020
    foreach ( @options)
1116
    foreach ( @options)
Line 1051... Line 1147...
1051
}
1147
}
1052
 
1148
 
1053
#-------------------------------------------------------------------------------
1149
#-------------------------------------------------------------------------------
1054
# Function        : DebianDepends 
1150
# Function        : DebianDepends 
1055
#                   RpmDepends
1151
#                   RpmDepends
-
 
1152
#                   AllDepends
1056
#
1153
#
1057
# Description     : This directive allows simple dependency information to be  
1154
# Description     : This directive allows simple dependency information to be  
1058
#                   inserted into the control file
1155
#                   inserted into the control file
-
 
1156
#                   
-
 
1157
#                   Names will be massaged into conforming names.
1059
#
1158
#
1060
#                   Not useful in embedded system
1159
#                   Not useful in embedded system
1061
#
1160
#
1062
# Inputs          : Entry             - A dependency entry
1161
# Inputs          : Entry             - A dependency entry
1063
#                   ...               - More entries
1162
#                   ...               - More entries
-
 
1163
#                   Options
-
 
1164
#                       --Raw          - Prevent name modification
-
 
1165
#                       --NoRaw        - Enable name modification
1064
#                   
1166
#                   
1065
#
1167
#
1066
# Returns         : Nothing
1168
# Returns         : Nothing
1067
#
1169
#
1068
sub MULTI_Depends
1170
sub MULTI_Depends
1069
{
1171
{
-
 
1172
    return 1 unless ($ActiveSection);
1070
    shift;
1173
    shift;
-
 
1174
    my $raw = 0;
-
 
1175
 
-
 
1176
    #
-
 
1177
    #   Convert the provided name into a canonical name
-
 
1178
    #   Simplifies use when using both RPM and Debian
-
 
1179
    foreach ( @_)
-
 
1180
    {
-
 
1181
        if (m~^--(No)?Raw~i) {
-
 
1182
            $raw = ! defined($1);
-
 
1183
            next;
-
 
1184
        }
-
 
1185
        my $name = $_;
-
 
1186
        $name = canonicalName($_, $opt_rpm ? 'RPM' : 'DEBIAN' , 1) unless $raw;
1071
    push @DependencyList, @_;
1187
        push @DependencyList, $name;
-
 
1188
    }
-
 
1189
    
1072
}
1190
}
1073
 
1191
 
1074
#-------------------------------------------------------------------------------
1192
#-------------------------------------------------------------------------------
1075
# Function        : PackageDescription
1193
# Function        : PackageDescription
1076
#
1194
#
Line 1081... Line 1199...
1081
#
1199
#
1082
# Returns         : 
1200
# Returns         : 
1083
#
1201
#
1084
sub PackageDescription
1202
sub PackageDescription
1085
{
1203
{
-
 
1204
    return 1 unless ($ActiveSection);
1086
    ($opt_description) = @_;
1205
    ($opt_description) = @_;
1087
}
1206
}
1088
 
1207
 
1089
#-------------------------------------------------------------------------------
1208
#-------------------------------------------------------------------------------
1090
# Function        : MakeSymLink
1209
# Function        : MakeSymLink
Line 1106... Line 1225...
1106
sub MakeSymLink
1225
sub MakeSymLink
1107
{
1226
{
1108
    my $no_clean;
1227
    my $no_clean;
1109
    my $no_dot;
1228
    my $no_dot;
1110
    my @args;
1229
    my @args;
-
 
1230
    return 1 unless ($ActiveSection);
1111
 
1231
 
1112
    #
1232
    #
1113
    #   Extract options
1233
    #   Extract options
1114
    #
1234
    #
1115
    foreach ( @_ )
1235
    foreach ( @_ )
Line 1170... Line 1290...
1170
#
1290
#
1171
# Returns         : Full path to destination file
1291
# Returns         : Full path to destination file
1172
#
1292
#
1173
sub CopyFile
1293
sub CopyFile
1174
{
1294
{
-
 
1295
    return 1 unless ($ActiveSection);
1175
    CopyFileCommon( \&ResolveFile, @_ );
1296
    CopyFileCommon( \&ResolveFile, @_ );
1176
}
1297
}
1177
 
1298
 
1178
#-------------------------------------------------------------------------------
1299
#-------------------------------------------------------------------------------
1179
# Function        : CopyBinFile
1300
# Function        : CopyBinFile
Line 1189... Line 1310...
1189
#                   Options:
1310
#                   Options:
1190
#                       --FromPackage
1311
#                       --FromPackage
1191
#                       --SoftLink=xxxx
1312
#                       --SoftLink=xxxx
1192
#                       --LinkFile=xxxx
1313
#                       --LinkFile=xxxx
1193
#
1314
#
1194
#
-
 
1195
# Returns         : Full path to destination file
1315
# Returns         : Full path to destination file
1196
#
1316
#
1197
sub CopyBinFile
1317
sub CopyBinFile
1198
{
1318
{
-
 
1319
    return 1 unless ($ActiveSection);
1199
    CopyFileCommon( \&ResolveBinFile, @_ );
1320
    CopyFileCommon( \&ResolveBinFile, @_ );
1200
}
1321
}
1201
 
1322
 
1202
#-------------------------------------------------------------------------------
1323
#-------------------------------------------------------------------------------
1203
# Function        : CopyLibFile
1324
# Function        : CopyLibFile
Line 1238... Line 1359...
1238
#                   The routine will also recognize Windows DLLs
1359
#                   The routine will also recognize Windows DLLs
1239
#                   These are of the form fred[P|D|].nnnnn.dll
1360
#                   These are of the form fred[P|D|].nnnnn.dll
1240
#
1361
#
1241
sub CopyLibFile
1362
sub CopyLibFile
1242
{
1363
{
-
 
1364
    return 1 unless ($ActiveSection);
1243
    CopyFileCommon( \&ResolveLibFile, @_ );
1365
    CopyFileCommon( \&ResolveLibFile, @_ );
1244
}
1366
}
1245
 
1367
 
1246
#-------------------------------------------------------------------------------
1368
#-------------------------------------------------------------------------------
1247
# Function        : CopyDebianPackage
1369
# Function        : CopyDebianPackage
Line 1276... Line 1398...
1276
#                       - bin/Arch[P|D]
1398
#                       - bin/Arch[P|D]
1277
#
1399
#
1278
#
1400
#
1279
sub CopyDebianPackage
1401
sub CopyDebianPackage
1280
{
1402
{
-
 
1403
    return 1 unless ($ActiveSection);
1281
    CopyFileCommon( \&ResolveDebPackage, '--FromPackage', @_ );
1404
    CopyFileCommon( \&ResolveDebPackage, '--FromPackage', @_ );
1282
}
1405
}
1283
 
1406
 
1284
#-------------------------------------------------------------------------------
1407
#-------------------------------------------------------------------------------
1285
# Function        : CopyFileCommon
1408
# Function        : CopyFileCommon
Line 1295... Line 1418...
1295
#                       --FromPackage
1418
#                       --FromPackage
1296
#                       --FromBuild
1419
#                       --FromBuild
1297
#                       --SoftLink=xxxx
1420
#                       --SoftLink=xxxx
1298
#                       --LinkFile=xxxx
1421
#                       --LinkFile=xxxx
1299
#                       --ConfFile
1422
#                       --ConfFile
-
 
1423
#                       --Platform=xxxx[,yyyyy]
1300
#
1424
#
1301
# Returns         : 
1425
# Returns         : 
1302
#
1426
#
1303
sub CopyFileCommon
1427
sub CopyFileCommon
1304
{
1428
{
1305
    my $from_package = 0;
1429
    my $from_package = 0;
1306
    my $isa_linkfile = 0;
1430
    my $isa_linkfile = 0;
1307
    my $isa_configFile = 0;
1431
    my $isa_configFile = 0;
1308
    my @llist;
1432
    my @llist;
1309
    my @args;
1433
    my @args;
-
 
1434
    my @platforms;
1310
 
1435
 
1311
    #
1436
    #
1312
    #   Parse options
1437
    #   Parse options
1313
    #
1438
    #
1314
    foreach ( @_ )
1439
    foreach ( @_ )
Line 1326... Line 1451...
1326
            $isa_configFile = 1;
1451
            $isa_configFile = 1;
1327
 
1452
 
1328
        } elsif ( m/^--SoftLink=(.+)/ ) {
1453
        } elsif ( m/^--SoftLink=(.+)/ ) {
1329
            push @llist, $1;
1454
            push @llist, $1;
1330
 
1455
 
-
 
1456
        } elsif ( m/^--Platform=(.+)/ ) {
-
 
1457
            push @platforms, split(',', $1 );
-
 
1458
 
1331
        } elsif ( m/^--/ ) {
1459
        } elsif ( m/^--/ ) {
1332
            Error ("FileCopy: Unknown option: $_");
1460
            Error ("FileCopy: Unknown option: $_");
1333
 
1461
 
1334
        } else {
1462
        } else {
1335
            push @args, $_;
1463
            push @args, $_;
Line 1348... Line 1476...
1348
    $dst_dir = "/$dst_dir/";
1476
    $dst_dir = "/$dst_dir/";
1349
    $dst_dir =~ s~/+~/~g;
1477
    $dst_dir =~ s~/+~/~g;
1350
    $dst_dir =~ s~/$~~;
1478
    $dst_dir =~ s~/$~~;
1351
 
1479
 
1352
    Verbose ("CopyFile: $src, $dst_dir, " . ($dst_name || ''));
1480
    Verbose ("CopyFile: $src, $dst_dir, " . ($dst_name || ''));
1353
    foreach $src ( &$resolver( $from_package, $src ) )
1481
    foreach $src ( &$resolver( $from_package, $src, \@platforms ) )
1354
    {
1482
    {
1355
        my $dst_fname = $dst_name ? $dst_name : StripDir($src);
1483
        my $dst_fname = $dst_name ? $dst_name : StripDir($src);
1356
        my $dst_file = "$dst_dir/$dst_fname";
1484
        my $dst_file = "$dst_dir/$dst_fname";
1357
        Verbose ("CopyFile: Copy $src, $dst_file" );
1485
        Verbose ("CopyFile: Copy $src, $dst_file" );
1358
        
1486
        
Line 1427... Line 1555...
1427
    my $user_src_dir = $src_dir;
1555
    my $user_src_dir = $src_dir;
1428
    my $opt_source;
1556
    my $opt_source;
1429
    my $opt_package;
1557
    my $opt_package;
1430
    my @fileList;
1558
    my @fileList;
1431
    my $isFiltered;
1559
    my $isFiltered;
-
 
1560
    return 1 unless ($ActiveSection);
1432
 
1561
 
1433
    #
1562
    #
1434
    #   Setup the basic copy options
1563
    #   Setup the basic copy options
1435
    #       May be altered as we parse user options
1564
    #       May be altered as we parse user options
1436
    #
1565
    #
Line 1675... Line 1804...
1675
{
1804
{
1676
    my $no_copy;
1805
    my $no_copy;
1677
    my $basedir = "";
1806
    my $basedir = "";
1678
    my @args;
1807
    my @args;
1679
    my $from_package = 0;
1808
    my $from_package = 0;
-
 
1809
    return 1 unless ($ActiveSection);
1680
 
1810
 
1681
    # This directive is only available on the VIX platforms
1811
    # This directive is only available on the VIX platforms
1682
    #   Kludgey test - at the moment
1812
    #   Kludgey test - at the moment
1683
    #
1813
    #
1684
    if ($opt_pkgarch =~ m~i386~)
1814
    if ($opt_pkgarch =~ m~i386~)
Line 1745... Line 1875...
1745
# Returns         :
1875
# Returns         :
1746
#
1876
#
1747
sub CatFile
1877
sub CatFile
1748
{
1878
{
1749
    my ($src, $dst) = @_;
1879
    my ($src, $dst) = @_;
-
 
1880
    return 1 unless ($ActiveSection);
1750
 
1881
 
1751
    $dst = $WorkDir . '/' . $dst;
1882
    $dst = $WorkDir . '/' . $dst;
1752
    $dst =~ s~//~/~;
1883
    $dst =~ s~//~/~;
1753
    Verbose ("CatFile: $src, $dst");
1884
    Verbose ("CatFile: $src, $dst");
1754
    $src = ResolveFile(0, $src );
1885
    $src = ResolveFile(0, $src );
Line 1774... Line 1905...
1774
# Returns         : 
1905
# Returns         : 
1775
#
1906
#
1776
sub EchoFile
1907
sub EchoFile
1777
{
1908
{
1778
    my ($file, $text) = @_;
1909
    my ($file, $text) = @_;
-
 
1910
    return 1 unless ($ActiveSection);
1779
    Verbose ("EchoFile: $file");
1911
    Verbose ("EchoFile: $file");
1780
 
1912
 
1781
    $file = $WorkDir . '/' . $file;
1913
    $file = $WorkDir . '/' . $file;
1782
    $file =~ s~//~/~;
1914
    $file =~ s~//~/~;
1783
 
1915
 
Line 1818... Line 1950...
1818
# Returns         : 1
1950
# Returns         : 1
1819
#
1951
#
1820
sub ConvertFiles
1952
sub ConvertFiles
1821
{
1953
{
1822
    my @uargs;
1954
    my @uargs;
-
 
1955
    return 1 unless ($ActiveSection);
1823
    my $lineEnding = "\n";
1956
    my $lineEnding = "\n";
1824
    my ($dosSet, $unixSet);
1957
    my ($dosSet, $unixSet);
1825
    my $search =  JatsLocateFiles->new( '--NoRecurse' );
1958
    my $search =  JatsLocateFiles->new( '--NoRecurse' );
1826
 
1959
 
1827
    #
1960
    #
Line 1972... Line 2105...
1972
#
2105
#
1973
# Returns         : 1
2106
# Returns         : 1
1974
#
2107
#
1975
sub ReplaceTags
2108
sub ReplaceTags
1976
{
2109
{
-
 
2110
    return 1 unless ($ActiveSection);
1977
    my @uargs;
2111
    my @uargs;
1978
    my $search =  JatsLocateFiles->new( '--NoRecurse' );
2112
    my $search =  JatsLocateFiles->new( '--NoRecurse' );
1979
    my @tagsList;
2113
    my @tagsList;
1980
    my $tagSep = ',';
2114
    my $tagSep = ',';
1981
    my @tagOrder;
2115
    my @tagOrder;
Line 2142... Line 2276...
2142
# Returns         : 
2276
# Returns         : 
2143
#
2277
#
2144
sub SetFilePerms
2278
sub SetFilePerms
2145
{
2279
{
2146
 
2280
 
-
 
2281
    return 1 unless ($ActiveSection);
2147
    my @args;
2282
    my @args;
2148
    my $perms;
2283
    my $perms;
2149
    my $recurse = 0;
2284
    my $recurse = 0;
2150
 
2285
 
2151
    #
2286
    #
Line 2232... Line 2367...
2232
#                               the filter will be applied when it comes time to chmod the dir 
2367
#                               the filter will be applied when it comes time to chmod the dir 
2233
#
2368
#
2234
#------------------------------------------------------------------------------
2369
#------------------------------------------------------------------------------
2235
sub SetPermissions
2370
sub SetPermissions
2236
{
2371
{
-
 
2372
    return 1 unless ($ActiveSection);
2237
    my ( $path, $filePerms, $dirPerms, $someDone );
2373
    my ( $path, $filePerms, $dirPerms, $someDone );
2238
    my ( $rootOnly, $skipRoot ) = ( 0, 0 );
2374
    my ( $rootOnly, $skipRoot ) = ( 0, 0 );
2239
    
2375
    
2240
    my $search =  JatsLocateFiles->new( '--Recurse', '--DirsToo' );
2376
    my $search =  JatsLocateFiles->new( '--Recurse', '--DirsToo' );
2241
 
2377
 
Line 2396... Line 2532...
2396
# Returns         : Nothing
2532
# Returns         : Nothing
2397
#
2533
#
2398
sub CreateDir
2534
sub CreateDir
2399
{
2535
{
2400
    my ($path, @opts) = @_;
2536
    my ($path, @opts) = @_;
-
 
2537
    return 1 unless ($ActiveSection);
2401
    Verbose ("Create Dir: $path");
2538
    Verbose ("Create Dir: $path");
2402
    my $owner  = 0;
2539
    my $owner  = 0;
2403
    foreach ( @opts) {
2540
    foreach ( @opts) {
2404
        if (m~^--Owner~i ) {
2541
        if (m~^--Owner~i ) {
2405
            $owner = 1;
2542
            $owner = 1;
Line 2426... Line 2563...
2426
#                       The default group id.
2563
#                       The default group id.
2427
#                       The default permissions, or "mode" for directories.
2564
#                       The default permissions, or "mode" for directories.
2428
#                   
2565
#                   
2429
sub RpmSetDefAttr
2566
sub RpmSetDefAttr
2430
{
2567
{
-
 
2568
    return 1 unless ($ActiveSection);
2431
    return 1 unless $opt_rpm;
2569
    return 1 unless $opt_rpm;
2432
    my @args = @_;
2570
    my @args = @_;
2433
    Error ("RpmSetDefAttr: Expecting 4 arguments") if (scalar @args ne 4);
2571
    Error ("RpmSetDefAttr: Expecting 4 arguments") if (scalar @args ne 4);
2434
    @RpmDefAttr = @_;
2572
    @RpmDefAttr = @_;
2435
    return 1;
2573
    return 1;
Line 2445... Line 2583...
2445
#                   $user - user name to place on the file  (optional)
2583
#                   $user - user name to place on the file  (optional)
2446
#                   $group  - group name to place eon the file (optional)
2584
#                   $group  - group name to place eon the file (optional)
2447
#
2585
#
2448
sub RpmSetAttr
2586
sub RpmSetAttr
2449
{
2587
{
-
 
2588
    return 1 unless ($ActiveSection);
2450
    return 1 unless $opt_rpm;
2589
    return 1 unless $opt_rpm;
2451
    my ($file, $mode, $user, $group, @extra) = @_;
2590
    my ($file, $mode, $user, $group, @extra) = @_;
2452
    Error ("RpmSetAttr: Too many arguments") if @extra;
2591
    Error ("RpmSetAttr: Too many arguments") if @extra;
2453
 
2592
 
2454
    #
2593
    #
Line 2473... Line 2612...
2473
# Function        : IsProduct
2612
# Function        : IsProduct
2474
#                   IsPlatform
2613
#                   IsPlatform
2475
#                   IsTarget
2614
#                   IsTarget
2476
#                   IsVariant
2615
#                   IsVariant
2477
#                   IsAlias
2616
#                   IsAlias
-
 
2617
#                   IsDebian
-
 
2618
#                   IsRpm
-
 
2619
#                   IsTar
2478
#
2620
#
2479
# Description     : This function allows some level of control in the
2621
# Description     : This function allows some level of control in the
2480
#                   packaging scripts. It will return true if the current
2622
#                   packaging scripts. It will return true if the current
2481
#                   product is listed.
2623
#                   product is listed.
2482
#
2624
#
Line 2534... Line 2676...
2534
    #
2676
    #
2535
    Error("IsAlias not supported in this version of JATS")
2677
    Error("IsAlias not supported in this version of JATS")
2536
        unless (defined &ReadBuildConfig::getAliases);
2678
        unless (defined &ReadBuildConfig::getAliases);
2537
    #
2679
    #
2538
    #   Create an hash of aliases to simplify testing
2680
    #   Create an hash of aliases to simplify testing
2539
    #   Do it onceand cache the results
2681
    #   Do it once and cache the results
2540
    #
2682
    #
2541
    unless (%opt_aliases) {
2683
    unless (%opt_aliases) {
2542
        %opt_aliases = map { $_ => 1 } getAliases();
2684
        %opt_aliases = map { $_ => 1 } getAliases();
2543
    }
2685
    }
2544
 
2686
 
Line 2547... Line 2689...
2547
        return 1 if ( exists $opt_aliases{$_} );
2689
        return 1 if ( exists $opt_aliases{$_} );
2548
    }
2690
    }
2549
    return 0;
2691
    return 0;
2550
}
2692
}
2551
 
2693
 
-
 
2694
sub IsDebian()
-
 
2695
{
-
 
2696
    return $opt_debian ? 1 : 0;
-
 
2697
}
-
 
2698
 
-
 
2699
sub IsRpm()
-
 
2700
{
-
 
2701
    return $opt_rpm ? 1 : 0;
-
 
2702
}
-
 
2703
 
-
 
2704
sub IsTar()
-
 
2705
{
-
 
2706
    return $opt_tarFile ? 1 : 0;
-
 
2707
}
-
 
2708
 
2552
 
2709
 
2553
#************ INTERNAL USE ONLY  **********************************************
2710
#************ INTERNAL USE ONLY  **********************************************
2554
# Function        : FindFiles
2711
# Function        : FindFiles
2555
#
2712
#
2556
# Description     : Locate files within a given dir tree
2713
# Description     : Locate files within a given dir tree
Line 2647... Line 2804...
2647
# Returns         : Nothing
2804
# Returns         : Nothing
2648
#                   Will remove .LINKS files that are processed
2805
#                   Will remove .LINKS files that are processed
2649
#
2806
#
2650
sub ExpandLinkFiles
2807
sub ExpandLinkFiles
2651
{
2808
{
-
 
2809
    return 1 unless ($ActiveSection);
2652
    foreach my $linkfile ( FindFiles( $WorkDir, ".LINKS" ))
2810
    foreach my $linkfile ( FindFiles( $WorkDir, ".LINKS" ))
2653
    {
2811
    {
2654
        next if ( $linkfile =~ m~/\.svn/~ );
2812
        next if ( $linkfile =~ m~/\.svn/~ );
2655
        my $BASEDIR = StripFileExt( $linkfile );
2813
        my $BASEDIR = StripFileExt( $linkfile );
2656
        $BASEDIR =~ s~^$WorkDir/~~;
2814
        $BASEDIR =~ s~^$WorkDir/~~;
Line 2685... Line 2843...
2685
#
2843
#
2686
#                   Will scan 'parts' subdirs
2844
#                   Will scan 'parts' subdirs
2687
#
2845
#
2688
# Inputs          : $from_package       - 0 - Local File
2846
# Inputs          : $from_package       - 0 - Local File
2689
#                   $file
2847
#                   $file
-
 
2848
#                   $refPlatforms       - Not used
2690
#
2849
#
2691
# Returns         : Path
2850
# Returns         : Path
2692
#
2851
#
2693
#************ INTERNAL USE ONLY  **********************************************
2852
#************ INTERNAL USE ONLY  **********************************************
2694
sub ResolveFile
2853
sub ResolveFile
2695
{
2854
{
2696
    my ($from_package, $file) = @_;
2855
    my ($from_package, $file,$refPlatforms) = @_;
2697
    my $wildcard = ($file =~ /[*?]/);
2856
    my $wildcard = ($file =~ /[*?]/);
2698
    my @path;
2857
    my @path;
2699
 
2858
 
2700
    #
2859
    #
2701
    #   Determine the paths to search
2860
    #   Determine the paths to search
Line 2715... Line 2874...
2715
    else
2874
    else
2716
    {
2875
    {
2717
        @path = ('.', $opt_localincdir);
2876
        @path = ('.', $opt_localincdir);
2718
    }
2877
    }
2719
 
2878
 
2720
    #
-
 
2721
    #   Determine a full list of 'parts' to search
2879
    #   Determine a full list of 'parts' to search
2722
    #   This is provided within the build information
2880
    #       Default: Provided within the build information
2723
    #
2881
    #       User   : Can provide a list
2724
    my @parts = getPlatformParts ();
2882
    my @parts = getPlatformPartsList($refPlatforms);
2725
    push @parts, '';
-
 
2726
 
2883
 
2727
    my @done;
2884
    my @done;
2728
    foreach my $root (  @path )
2885
    foreach my $root (  @path )
2729
    {
2886
    {
2730
        foreach my $subdir ( @parts )
2887
        foreach my $subdir ( @parts )
Line 2743... Line 2900...
2743
                push @done, $sfile if ( -f $sfile || -l $sfile )
2900
                push @done, $sfile if ( -f $sfile || -l $sfile )
2744
            }
2901
            }
2745
        }
2902
        }
2746
    }
2903
    }
2747
 
2904
 
2748
    Error ("ResolveFile: File not found: $file", "Search Path:", @path)
2905
    DisplaySearchPath('ResolveFile', $file, \@parts, undef, \@path) unless (@done) ;
2749
        unless ( @done );
-
 
2750
 
2906
 
2751
    Warning ("ResolveFile: Multiple instances of file found. Only first is used", @done)
2907
    Warning ("ResolveFile: Multiple instances of file found. Only first is used", @done)
2752
        if ( $#done > 0 && ! $wildcard && !wantarray );
2908
        if ( $#done > 0 && ! $wildcard && !wantarray );
2753
 
2909
 
2754
    return wantarray ? @done : $done[0];
2910
    return wantarray ? @done : $done[0];
Line 2763... Line 2919...
2763
#                       Local Include
2919
#                       Local Include
2764
#                   Or  (FromPackage)
2920
#                   Or  (FromPackage)
2765
#                       Our Package directory
2921
#                       Our Package directory
2766
#                       Interface directory (BuildPkgArchives)
2922
#                       Interface directory (BuildPkgArchives)
2767
#                       Packages (LinkPkgArchive)
2923
#                       Packages (LinkPkgArchive)
2768
#                   Will scan 'parts' subdirs
2924
#                   Will scan 'parts' subdirs (default)
-
 
2925
#                   May scan user-provided parts (cross platform packaging)
2769
#
2926
#
2770
# Inputs          : $from_package       - 0 - Local File
2927
# Inputs          : $from_package       - 0 - Local File
2771
#                   $file
2928
#                   $file
-
 
2929
#                   $refPlatforms       - (optional) Ref to an array of platforms to scan
2772
#
2930
#
2773
# Returns         : Path
2931
# Returns         : Path
2774
#
2932
#
2775
sub ResolveBinFile
2933
sub ResolveBinFile
2776
{
2934
{
2777
    my ($from_package, $file) = @_;
2935
    my ($from_package, $file, $refPlatforms) = @_;
2778
    my @path;
2936
    my @path;
2779
    my @types;
2937
    my @types;
2780
    my $wildcard = ($file =~ /[*?]/);
2938
    my $wildcard = ($file =~ /[*?]/);
2781
 
2939
 
2782
    #
2940
    #
Line 2805... Line 2963...
2805
        @types = '';
2963
        @types = '';
2806
    }
2964
    }
2807
 
2965
 
2808
    #
2966
    #
2809
    #   Determine a full list of 'parts' to search
2967
    #   Determine a full list of 'parts' to search
2810
    #   This is provided within the build information
2968
    #       Default: Provided within the build information
-
 
2969
    #       User   : Can provide a list
2811
    #
2970
    #
2812
    my @parts = getPlatformParts ();
2971
    my @parts = getPlatformPartsList($refPlatforms);
2813
    push @parts, '';
-
 
2814
 
2972
 
2815
    my @done;
2973
    my @done;
2816
    foreach my $root (  @path )
2974
    foreach my $root (  @path )
2817
    {
2975
    {
2818
        foreach my $subdir ( @parts )
2976
        foreach my $subdir ( @parts )
Line 2839... Line 2997...
2839
                }
2997
                }
2840
            }
2998
            }
2841
        }
2999
        }
2842
    }
3000
    }
2843
 
3001
 
-
 
3002
    #
2844
    Error ("ResolveBinFile: File not found: $file", "Search Path:", @path)
3003
    #   Pretty display the search path - on error
2845
        unless ( @done );
3004
    #       Will not return.
-
 
3005
    #
-
 
3006
    DisplaySearchPath('ResolveBinFile', $file, \@parts, \@types, \@path) unless (@done) ;
2846
 
3007
 
2847
    if ( $#done > 0 && ! $wildcard )
3008
    if ( $#done > 0 && ! $wildcard )
2848
    {
3009
    {
2849
        Warning ("ResolveBinFile: Multiple instances of file found. Only first is used", @done);
3010
        Warning ("ResolveBinFile: Multiple instances of file found. Only first is used", @done);
2850
        splice (@done, 1);
3011
        splice (@done, 1);
Line 2871... Line 3032...
2871
#                                     Do not provide 'lib' or '.so' or version info
3032
#                                     Do not provide 'lib' or '.so' or version info
2872
#                                     May contain embedded options
3033
#                                     May contain embedded options
2873
#                                       --Dll           - Use Windows style versioned DLL
3034
#                                       --Dll           - Use Windows style versioned DLL
2874
#                                       --VersionDll    - Use the versioned DLL
3035
#                                       --VersionDll    - Use the versioned DLL
2875
#                                       --3rdParty      - Use exact name provided
3036
#                                       --3rdParty      - Use exact name provided
-
 
3037
#                   $refPlatforms       - Ref to an array of platforms to scan
2876
#
3038
#
2877
# Returns         : Path
3039
# Returns         : Path
2878
#
3040
#
2879
sub ResolveLibFile
3041
sub ResolveLibFile
2880
{
3042
{
2881
    my ($from_package, $file) = @_;
3043
    my ($from_package, $file, $refPlatforms) = @_;
2882
    my $wildcard = ($file =~ /[*?]/);
3044
    my $wildcard = ($file =~ /[*?]/);
2883
    my @options;
3045
    my @options;
2884
    my $num_dll;
3046
    my $num_dll;
-
 
3047
    my @types;
2885
    my @path;
3048
    my @path;
2886
    #
3049
    #
2887
    #   Extract options from file
3050
    #   Extract options from file
2888
    #
3051
    #
2889
    $num_dll = 0;
3052
    $num_dll = 0;
Line 2919... Line 3082...
2919
    else
3082
    else
2920
    {
3083
    {
2921
        @path = ($opt_libdir, $opt_locallibdir);
3084
        @path = ($opt_libdir, $opt_locallibdir);
2922
    }
3085
    }
2923
 
3086
 
2924
    #
-
 
2925
    #   Determine a full list of 'parts' to search
3087
    #   Determine a full list of 'parts' to search
2926
    #   This is provided within the build information
3088
    #       Default: Provided within the build information
2927
    #
3089
    #       User   : Can provide a list
2928
    my @parts = getPlatformParts ();
3090
    my @parts = getPlatformPartsList($refPlatforms);
-
 
3091
 
2929
    push @parts, '';
3092
    @types = ( $opt_type, '');
2930
 
3093
 
2931
    my @done;
3094
    my @done;
2932
    foreach my $root (  @path )
3095
    foreach my $root (  @path )
2933
    {
3096
    {
2934
        foreach my $type ( $opt_type, '' )
3097
        foreach my $type ( @types )
2935
        {
3098
        {
2936
            foreach my $subdir ( @parts )
3099
            foreach my $subdir ( @parts )
2937
            {
3100
            {
2938
                my $sfile;
3101
                my $sfile;
2939
                my $exact;
3102
                my $exact;
Line 2987... Line 3150...
2987
                }
3150
                }
2988
            }
3151
            }
2989
        }
3152
        }
2990
    }
3153
    }
2991
 
3154
 
2992
    Error ("ResolveLibFile: File not found: $file", "Search Path:", @path)
3155
    DisplaySearchPath('ResolveLibFile', $file, \@parts, \@types, \@path) unless (@done) ;
2993
        unless ( @done );
-
 
2994
 
3156
 
2995
    if ( $#done > 0 && ! $wildcard )
3157
    if ( $#done > 0 && ! $wildcard )
2996
    {
3158
    {
2997
        Warning ("ResolveLibFile: Multiple instances of file found. Only first is used", @done);
3159
        Warning ("ResolveLibFile: Multiple instances of file found. Only first is used", @done);
2998
        splice (@done, 1);
3160
        splice (@done, 1);
Line 3014... Line 3176...
3014
#
3176
#
3015
# Inputs          : $from_package   - 0:Local File
3177
# Inputs          : $from_package   - 0:Local File
3016
#                   $baseName       - Basename for a 'DebianPackage'
3178
#                   $baseName       - Basename for a 'DebianPackage'
3017
#                                     Do not provide version info, architecture or suffix
3179
#                                     Do not provide version info, architecture or suffix
3018
#                                     May contain embedded options
3180
#                                     May contain embedded options
3019
#                                       --Arch=XXX      - Specify alternate architcute
3181
#                                       --Arch=XXX      - Specify alternate architcuture
3020
#                                       --Product=YYYY  - Specify product family
3182
#                                       --Product=YYYY  - Specify product family
3021
#                                       --Debug         - Use alternate build type
3183
#                                       --Debug         - Use alternate build type
3022
#                                       --Prod          - Use alternate build type
3184
#                                       --Prod          - Use alternate build type
-
 
3185
#                   $refPlatforms       - Ref to an array of platforms to scan
3023
#
3186
#
3024
# Returns         : Path
3187
# Returns         : Path
3025
#
3188
#
3026
sub ResolveDebPackage
3189
sub ResolveDebPackage
3027
{
3190
{
3028
    my ($from_package, $file) = @_;
3191
    my ($from_package, $file, $refPlatforms) = @_;
3029
    my @path;
3192
    my @path;
3030
    my $arch;
3193
    my $arch;
3031
    my $product;
3194
    my $product;
3032
    my $buildType;
3195
    my $buildType;
3033
    my @types;
3196
    my @types;
Line 3106... Line 3269...
3106
    if (defined $product) {
3269
    if (defined $product) {
3107
        $file .= ( '_' . $product)
3270
        $file .= ( '_' . $product)
3108
        }
3271
        }
3109
    $file .= '_' . $arch;
3272
    $file .= '_' . $arch;
3110
 
3273
 
3111
    #
-
 
3112
    #   Determine a full list of 'parts' to search
3274
    #   Determine a full list of 'parts' to search
3113
    #   This is provided within the build information
3275
    #       Default: Provided within the build information
3114
    #
3276
    #       User   : Can provide a list
3115
    my @parts = getPlatformParts ();
3277
    my @parts = getPlatformPartsList($refPlatforms);
3116
    push @parts, '';
-
 
3117
 
3278
 
3118
    my @done;
3279
    my @done;
3119
    foreach my $root (  @path )
3280
    foreach my $root (  @path )
3120
    {
3281
    {
3121
        foreach my $subdir ( @parts )
3282
        foreach my $subdir ( @parts )
Line 3138... Line 3299...
3138
                }
3299
                }
3139
            }
3300
            }
3140
        }
3301
        }
3141
    }
3302
    }
3142
 
3303
 
3143
    Error ("ResolveDebPackage: Package not found: $file", "Search Path:", @path)
3304
    DisplaySearchPath('ResolveDebPackage', $file, \@parts, \@types, \@path) unless (@done) ;
3144
        unless ( @done );
-
 
3145
 
3305
 
3146
    if ( $#done > 0 )
3306
    if ( $#done > 0 )
3147
    {
3307
    {
3148
        Error ("ResolveDebPackage: Multiple instances of Package found.", @done);
3308
        Error ("ResolveDebPackage: Multiple instances of Package found.", @done);
3149
    }
3309
    }
3150
    return wantarray ? @done : $done[0];
3310
    return wantarray ? @done : $done[0];
3151
}
3311
}
3152
 
3312
 
3153
#-------------------------------------------------------------------------------
3313
#-------------------------------------------------------------------------------
-
 
3314
# Function        : prettyArray 
-
 
3315
#
-
 
3316
# Description     : Generate a quoted string from an array
-
 
3317
#
-
 
3318
# Inputs          : Array Ref
-
 
3319
#
-
 
3320
# Returns         : A string
-
 
3321
#
-
 
3322
sub prettyArray
-
 
3323
{
-
 
3324
    my ($arrayRef) = @_;
-
 
3325
    return join(',', map { qq!"$_"! }  @{$arrayRef})
-
 
3326
}
-
 
3327
 
-
 
3328
#-------------------------------------------------------------------------------
-
 
3329
# Function        : DisplaySearchPath 
-
 
3330
#
-
 
3331
# Description     : Pretty display of the search path
-
 
3332
#                   Error display
-
 
3333
#
-
 
3334
# Inputs          : $name   - Function Name
-
 
3335
#                   $file   - Base filename being searched
-
 
3336
#                   $parts  - Ref to array of parts searched
-
 
3337
#                   $types  - Ref to array of types searched - may be undef
-
 
3338
#                   $path   - Ref to array of paths searched
-
 
3339
#
-
 
3340
# Returns         : Will not return
-
 
3341
#
-
 
3342
sub DisplaySearchPath
-
 
3343
{
-
 
3344
    my ($name, $file, $parts, $types, $path) = @_;
-
 
3345
    my @text;
-
 
3346
 
-
 
3347
    push @text, $name . ': File not found: ' . $file;
-
 
3348
    push @text, 'Search Platforms: ' . prettyArray($parts);
-
 
3349
    push @text, 'Search Types: ' . prettyArray($types) if defined $types;
-
 
3350
    push @text, 'Search Path:', @$path;
-
 
3351
    Error (@text);
-
 
3352
}
-
 
3353
 
-
 
3354
#-------------------------------------------------------------------------------
-
 
3355
# Function        : getPlatformPartsList  
-
 
3356
#
-
 
3357
# Description     : Determine a full list of 'parts' to search
-
 
3358
#                       Default: Provided within the build information
-
 
3359
#                       User   : Can provide a list
-
 
3360
#
-
 
3361
# Inputs          : $refPlatforms - Ref to an array of user provided platforms
-
 
3362
#                                   If provided will override the internal list
-
 
3363
#
-
 
3364
# Returns         : An array 
-
 
3365
#
-
 
3366
sub getPlatformPartsList
-
 
3367
{
-
 
3368
    my ($refPlatforms) = @_;
-
 
3369
    my @parts;
-
 
3370
 
-
 
3371
    if ($refPlatforms && scalar @{$refPlatforms}) {
-
 
3372
        @parts = @{$refPlatforms};
-
 
3373
 
-
 
3374
    } else {
-
 
3375
        @parts = getPlatformParts ();
-
 
3376
    }
-
 
3377
    push @parts, '';
-
 
3378
    return @parts;
-
 
3379
}
-
 
3380
 
-
 
3381
#-------------------------------------------------------------------------------
3154
# Function        : AUTOLOAD
3382
# Function        : AUTOLOAD
3155
#
3383
#
3156
# Description     : Intercept unknown user directives and issue a nice error message
3384
# Description     : Intercept unknown user directives and issue a nice error message
3157
#                   This is a simple routine to report unknown user directives
3385
#                   This is a simple routine to report unknown user directives
3158
#                   It does not attempt to distinguish between user errors and
3386
#                   It does not attempt to distinguish between user errors and