Subversion Repositories DevTools

Rev

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

Rev 4147 Rev 4152
Line 175... Line 175...
175
                "PackagePkgDir=s"   => \$opt_pkgpkgdir,
175
                "PackagePkgDir=s"   => \$opt_pkgpkgdir,
176
                "Output=s"          => \$opt_output,
176
                "Output=s"          => \$opt_output,
177
                "Variant:s"         => \$opt_variant,
177
                "Variant:s"         => \$opt_variant,
178
                "PkgArch:s"         => \$opt_pkgarch,
178
                "PkgArch:s"         => \$opt_pkgarch,
179
    );
179
    );
180
 
-
 
181
    $opt_verbose++ unless ( $opt_vargs eq '@' );
180
    $opt_verbose++ unless ( $opt_vargs eq '@' );
182
 
181
 
183
    ErrorConfig( 'name'    => 'DebianUtils',
182
    ErrorConfig( 'name'    => 'DebianUtils',
184
                 'verbose' => $opt_verbose,
183
                 'verbose' => $opt_verbose,
185
                 'debug'   => $opt_debug );
184
                 'debug'   => $opt_debug );
Line 749... Line 748...
749
#                   $dst_dir    - Within the output workspace
748
#                   $dst_dir    - Within the output workspace
750
#                   Options
749
#                   Options
751
#                       --Merge             - Don't delete first
750
#                       --Merge             - Don't delete first
752
#                       --Source=Name       - Source via Symbolic Name
751
#                       --Source=Name       - Source via Symbolic Name
753
#                       --FromPackage       - Source via package roots
752
#                       --FromPackage       - Source via package roots
754
#                       --IgnoreDbgFiles    - Ignore .dbg and .debug files in dir copy
753
#                       --NoIgnoreDbgFiles  - Do not ignore .dbg and .debug files in dir copy
-
 
754
#                       --IfPresent         - Not an error if the path cannot be found
755
#
755
#
756
# Returns         :
756
# Returns         :
757
#
757
#
758
sub CopyDir
758
sub CopyDir
759
{
759
{
760
    my ($src_dir, $dst_dir, @opts) = @_;
760
    my ($src_dir, $dst_dir, @opts) = @_;
761
    my $opt_merge;
761
    my $opt_merge;
762
    my $opt_base;
762
    my $opt_base;
763
    my $from_interface = 0;
763
    my $from_interface = 0;
764
    my $ignoreDbg;
764
    my $ignoreDbg = 1;
-
 
765
    my $ignoreNoDir;
-
 
766
    my $user_src_dir = $src_dir;
-
 
767
    my $opt_source;
-
 
768
    my $opt_package;
765
 
769
 
766
    $dst_dir = $DebianWorkDir . '/' . $dst_dir;
770
    $dst_dir = $DebianWorkDir . '/' . $dst_dir;
767
    $dst_dir =~ s~//~/~;
771
    $dst_dir =~ s~//~/~;
768
 
772
 
769
    #
773
    #
770
    #   Detect and expand Symbolic names in the Source Directory
774
    #   Scan and collect user options
771
    #
775
    #
772
    foreach  ( @opts )
776
    foreach  ( @opts )
773
    {
777
    {
-
 
778
        Verbose2 ("CopyDir: $_");
774
        if ( m/^--Merge/ ) {
779
        if ( m/^--Merge/ ) {
775
            $opt_merge = 1;
780
            $opt_merge = 1;
-
 
781
 
776
        } elsif ( m/^--Source=(.+)/ ) {
782
        } elsif ( m/^--Source=(.+)/ ) {
777
            my $name = $1;
-
 
778
            Verbose2 ("CopyDir: Source: $name");
-
 
779
            Error ("Source directory can only be specified once")
783
            Error ("Source directory can only be specified once")
-
 
784
                if ( defined $opt_source );
-
 
785
            $opt_source = $1;
-
 
786
 
-
 
787
        } elsif ( m/^--FromPackage/ ) {
-
 
788
            Error ("FromPackage can only be specified once")
780
                if ( defined $opt_base );
789
                if ( defined $opt_package );
-
 
790
            $opt_package = 1;
781
 
791
 
782
            $name = lc($name);
792
        } elsif ( m/^--NoIgnoreDbgFiles/ ) {
783
            my %CopyDirSymbolic = (
793
            $ignoreDbg = 0;
784
                'interfaceincdir'   => $opt_interfaceincdir,
-
 
785
                'interfacelibdir'   => $opt_interfacelibdir,
-
 
786
                'interfacebindir'   => $opt_interfacebindir,
-
 
-
 
794
 
787
                'libdir'            => $opt_libdir,
795
        } elsif ( m/^--IfPresent/ ) {
788
                'bindir'            => $opt_bindir,
-
 
789
                'localincdir'       => $opt_localincdir,
-
 
790
                'locallibdir'       => $opt_locallibdir,
-
 
791
                'localbindir'       => $opt_localbindir,
-
 
792
                'packagebindir'     => $opt_pkgbindir,
-
 
793
                'packagelibdir'     => $opt_pkglibdir,
-
 
794
                'packagepkgdir'     => $opt_pkgpkgdir,
-
 
795
                'packagedir'        => $opt_pkgdir,
-
 
796
            );
796
            $ignoreNoDir = 1;
797
            
797
            
-
 
798
        } else {
798
            if ( exists $CopyDirSymbolic{$name} )
799
            Error ("CopyDir: Unknown option: $_" );
799
            {
800
        }
800
                $opt_base = $CopyDirSymbolic{$name};
801
    }
801
 
802
 
802
                #
803
    #
803
                #   If sourceing from interface, then follow
804
    #   All options have been gathered. Now process some of them
804
                #   symlinks in the copy. All files will be links anyway
-
 
805
                #
-
 
806
                $from_interface = 1
-
 
807
                    if ( $name =~ m~^interface~ );
-
 
808
            }
-
 
809
            else
-
 
810
            {
805
    #
811
                DebugDumpData ("CopyDirSymbolic", \%CopyDirSymbolic);
-
 
812
                Error ("CopyDir: Unknown Source Name: $name" );
806
    Error ("CopyDir: Cannot use both --Source and --FromPackage: $src_dir") if ($opt_source && $opt_package);
813
            }
-
 
814
 
807
 
815
        } elsif ( m/^--FromPackage/ ) {
808
    #
816
            Verbose2 ("CopyDir: FromPackage: $src_dir");
809
    #   Convert a symbolic path into a physical path
-
 
810
    #
817
            Error ("Source directory can only be specified once")
811
    if ($opt_source)
-
 
812
    {
818
                if ( defined $opt_base );
813
        Verbose2 ("CopyDir: Determine Source: $opt_source");
819
 
814
 
-
 
815
        $opt_source = lc($opt_source);
820
            my @path;
816
        my %CopyDirSymbolic = (
821
            foreach my $entry ( getPackageList() )
817
            'interfaceincdir'   => $opt_interfaceincdir,
822
            {
818
            'interfacelibdir'   => $opt_interfacelibdir,
823
                my $base = $entry->getBase(3);
819
            'interfacebindir'   => $opt_interfacebindir,
824
                next unless ( defined $base );
820
            'libdir'            => $opt_libdir,
825
                if ( -d $base . '/' . $src_dir )
821
            'bindir'            => $opt_bindir,
826
                {
822
            'localincdir'       => $opt_localincdir,
827
                    push @path, $base;
823
            'locallibdir'       => $opt_locallibdir,
828
                    $from_interface = 1
824
            'localbindir'       => $opt_localbindir,
829
                        if ( $entry->{'TYPE'} eq 'interface' );
825
            'packagebindir'     => $opt_pkgbindir,
-
 
826
            'packagelibdir'     => $opt_pkglibdir,
-
 
827
            'packagepkgdir'     => $opt_pkgpkgdir,
830
                }
828
            'packagedir'        => $opt_pkgdir,
831
            }
829
        );
832
 
830
 
833
            Error ("CopyDir: Cannot find source dir in any package: $src_dir")
831
        if ( exists $CopyDirSymbolic{$opt_source} )
834
                if ( $#path < 0 );
832
        {
835
            Error ("CopyDir: Requested path found in mutiple packages: $src_dir",
-
 
836
                    @path ) if ( $#path > 0 );
-
 
837
            $opt_base = pop @path;
833
            $opt_base = $CopyDirSymbolic{$opt_source};
838
 
834
 
839
            #
835
            #
840
            #   If sourceing from interface, then follow symlinks in the copy.
836
            #   If sourceing from interface, then follow
841
            #   All files will be links anyway
837
            #   symlinks in the copy. All files will be links anyway
842
            #
-
 
843
            #   This is a very ugly test for 'interface'
-
 
844
            #
838
            #
845
            $from_interface = 1
839
            $from_interface = 1
846
                if ( $opt_base =~ m~/interface/~ );
840
                if ( $opt_source =~ m~^interface~ );
-
 
841
        }
-
 
842
        else
-
 
843
        {
-
 
844
            DebugDumpData ("CopyDirSymbolic", \%CopyDirSymbolic);
-
 
845
            Error ("CopyDir: Unknown Source Name: $opt_source" );
-
 
846
        }
-
 
847
    }
847
 
848
 
-
 
849
    #
848
        } elsif ( m/^--IgnoreDbgFiles/ ) {
850
    #   Locate the path within an external package
-
 
851
    #
849
            Verbose2 ("CopyDir: Ignore Debug Files");
852
    if ($opt_package)
-
 
853
    {
850
            $ignoreDbg = 1;
854
        Verbose2 ("CopyDir: FromPackage: $src_dir");
851
 
855
 
-
 
856
        my @path;
-
 
857
        foreach my $entry ( getPackageList() )
-
 
858
        {
-
 
859
            my $base = $entry->getBase(3);
-
 
860
            next unless ( defined $base );
-
 
861
            if ( -d $base . '/' . $src_dir )
852
        } else {
862
            {
-
 
863
                push @path, $base;
-
 
864
                $from_interface = 1
853
            Error ("CopyDir: Unknown option: $_" );
865
                    if ( $entry->{'TYPE'} eq 'interface' );
-
 
866
            }
854
        }
867
        }
-
 
868
 
-
 
869
        if ( $#path < 0 )
-
 
870
        {
-
 
871
            Error ("CopyDir: Cannot find source dir in any package: $user_src_dir") unless ($ignoreNoDir);
-
 
872
            Message ("CopyDir: Optional path not found: $user_src_dir");
-
 
873
            return;
-
 
874
        }
-
 
875
 
-
 
876
        Error ("CopyDir: Requested path found in mutiple packages: $user_src_dir",
-
 
877
                @path ) if ( $#path > 0 );
-
 
878
        $opt_base = pop @path;
-
 
879
 
-
 
880
        #
-
 
881
        #   If sourceing from interface, then follow symlinks in the copy.
-
 
882
        #   All files will be links anyway
-
 
883
        #
-
 
884
        #   This is a very ugly test for 'interface'
-
 
885
        #
-
 
886
        $from_interface = 1
-
 
887
            if ( $opt_base =~ m~/interface/~ );
-
 
888
 
855
    }
889
    }
856
 
890
 
-
 
891
    #
-
 
892
    #   Create the full source path
-
 
893
    #   May be: from a package, from a known directoru, from a local directory
-
 
894
    #
-
 
895
 
857
    $src_dir = $opt_base . '/' . $src_dir if ( $opt_base );
896
    $src_dir = $opt_base . '/' . $src_dir if ( $opt_base );
858
    $src_dir =~ s~//~/~g;
897
    $src_dir =~ s~//~/~g;
859
    $src_dir =~ s~/$~~;
898
    $src_dir =~ s~/$~~;
860
 
899
 
861
    Verbose ("CopyDir: $src_dir, $dst_dir");
900
    Verbose ("CopyDir: $src_dir, $dst_dir");
-
 
901
    unless ( -d $src_dir )
-
 
902
    {
862
    Error ("CopyDir: Directory not found: $src_dir") unless ( -d $src_dir );
903
        Error ("CopyDir: Directory not found: $user_src_dir") unless ($ignoreNoDir);
-
 
904
        Message ("CopyDir: Optional path not found: $user_src_dir");
-
 
905
        return;
-
 
906
    }
863
 
907
 
864
    #
908
    #
865
    #   Setup the copy options
909
    #   Setup the copy options
866
    #
910
    #
867
    my %copyOpts;
911
    my %copyOpts;