Subversion Repositories DevTools

Rev

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

Rev 2413 Rev 2424
Line 67... Line 67...
67
my $opt_postimage = 1;
67
my $opt_postimage = 1;
68
my $opt_workDir = '/work';
68
my $opt_workDir = '/work';
69
my $opt_vobMap;
69
my $opt_vobMap;
70
my $opt_preserveProjectBase;
70
my $opt_preserveProjectBase;
71
my $opt_ignoreProjectBaseErrors;
71
my $opt_ignoreProjectBaseErrors;
-
 
72
my $opt_ignoreMakeProjectErrors;
72
my $opt_delete;
73
my $opt_delete;
73
my $opt_recentAge = 14;             # Days
74
my $opt_recentAge = 14;             # Days
74
my $opt_relabel = 0;
75
my $opt_relabel = 0;
75
 
76
 
76
################################################################################
77
################################################################################
Line 153... Line 154...
153
    'web-cd-client',
154
    'web-cd-client',
154
 
155
 
155
 
156
 
156
    # 05-Nov-12: Pending fixup for include.txt files that escape the VOB
157
    # 05-Nov-12: Pending fixup for include.txt files that escape the VOB
157
    #
158
    #
158
    'ddu_app_manager',
159
#    'ddu_app_manager',
159
    'ddu_dog',
160
#    'ddu_dog',
160
    'ddu_dog_lib',
161
#    'ddu_dog_lib',
161
    'ddu_fim',
162
#    'ddu_fim',
162
    'ddu_logging_lib',
163
#    'ddu_logging_lib',
163
    'ddu_management',
164
#    'ddu_management',
164
    'ddu_mccain',
165
#    'ddu_mccain',
165
    'ddu_mon',
166
#    'ddu_mon',
166
    'ddu_rcu',
167
#    'ddu_rcu',
167
    'ddu_status_logging',
168
#    'ddu_status_logging',
168
    
169
    
169
);
170
);
170
 
171
 
171
my %specialPackages = (
172
my %specialPackages = (
172
    'core_devl'           =>  ',all,protected,',
173
    'core_devl'           =>  ',all,protected,',
Line 197... Line 198...
197
    'DBA-Common'                => ',protected,',
198
    'DBA-Common'                => ',protected,',
198
    'DBA-DatabaseInstall'       => ',protected,',
199
    'DBA-DatabaseInstall'       => ',protected,',
199
    'DBA-ExternalPerlModules'   => ',protected,',
200
    'DBA-ExternalPerlModules'   => ',protected,',
200
    'DBA-OraUserBuild'          => ',protected,',
201
    'DBA-OraUserBuild'          => ',protected,',
201
    'DBA-OST'                   => ',protected,',
202
    'DBA-OST'                   => ',protected,',
202
    'orahops-install'           => ',protected,',
203
#    'orahops-install'           => ',protected,',
203
    'orahops-patch'             => ',protected,',
204
#    'orahops-patch'             => ',protected,',
204
    'orahops-ssw-install'       => ',protected,',
205
#    'orahops-ssw-install'       => ',protected,',
205
    'orahops-ssw-patch'         => ',protected,',
206
#    'orahops-ssw-patch'         => ',protected,',
206
# End of ukHops migration exclussion
207
# End of ukHops migration exclussion
207
 
208
 
208
    'ftp'                   => 'SetProjectBase,',
209
    'ftp'                   => 'SetProjectBase,',
-
 
210
    'ddu_app_manager'       => 'SetProjectBase,',
209
 
211
 
210
    'icl'                   => 'IgnoreProjectBase,',
212
    'icl'                   => 'IgnoreProjectBase,',
211
    'itso'                  => 'IgnoreProjectBase,',
213
    'itso'                  => 'IgnoreProjectBase,',
212
    'daf_osa_mos'           => 'IgnoreProjectBase,',
214
    'daf_osa_mos'           => 'IgnoreProjectBase,',
213
    'daf_utils_mos'         => 'IgnoreProjectBase,',
215
    'daf_utils_mos'         => 'IgnoreProjectBase,',
Line 282... Line 284...
282
my @multiplePaths;
284
my @multiplePaths;
283
my @badEssentials;
285
my @badEssentials;
284
my %svnData;
286
my %svnData;
285
my $cwd;
287
my $cwd;
286
my $mustConvertFileNames;
288
my $mustConvertFileNames;
-
 
289
my $workDir;
287
 
290
 
288
my $packageNames;
291
my $packageNames;
289
my @packageNames;
292
my @packageNames;
290
my $multiPackages = -1;
293
my $multiPackages = -1;
291
my $visitId = 0;
294
my $visitId = 0;
Line 487... Line 490...
487
    }
490
    }
488
 
491
 
489
    #
492
    #
490
    #   Perform all the work in a package specific subdirectory
493
    #   Perform all the work in a package specific subdirectory
491
    #
494
    #
492
    my $workDir = $opt_workDir . '/' . $packageNames;
495
    $workDir = $opt_workDir . '/' . $packageNames;
493
    mkdir $workDir unless ( -d $workDir );
496
    mkdir $workDir unless ( -d $workDir );
494
    chdir $workDir || Error ("Cannot cd to $workDir");
497
    chdir $workDir || Error ("Cannot cd to $workDir");
495
 
498
 
496
    #
499
    #
497
    #   Process all packages
500
    #   Process all packages
Line 675... Line 678...
675
        if ( index( $data, 'IgnoreProjectBase,' ) >= 0) {
678
        if ( index( $data, 'IgnoreProjectBase,' ) >= 0) {
676
            $opt_ignoreProjectBaseErrors = 1;
679
            $opt_ignoreProjectBaseErrors = 1;
677
            Message ("Ignore ProjectBase Errors");
680
            Message ("Ignore ProjectBase Errors");
678
        }
681
        }
679
 
682
 
-
 
683
        if ( index( $data, 'IgnoreMakeProject,' ) >= 0) {
-
 
684
            $opt_ignoreMakeProjectErrors = 1;
-
 
685
            Message ("Ignore MakeProject Usage");
-
 
686
        }
-
 
687
        
-
 
688
 
680
        if ( index( $data, 'utf8,' ) >= 0) {
689
        if ( index( $data, 'utf8,' ) >= 0) {
681
            $mustConvertFileNames = 1;
690
            $mustConvertFileNames = 1;
682
            Message ("Convert filenames to UTF8");
691
            Message ("Convert filenames to UTF8");
683
        }
692
        }
684
    }
693
    }
Line 1818... Line 1827...
1818
    #
1827
    #
1819
    $rv = extractFilesFromClearCase( $data, $cc_path, $cc_label );
1828
    $rv = extractFilesFromClearCase( $data, $cc_path, $cc_label );
1820
    return $rv if ( $rv );
1829
    return $rv if ( $rv );
1821
 
1830
 
1822
    #
1831
    #
1823
    #   Some really ugly packages make use of a Jats feature called 'SetProjectBase'
-
 
1824
    #   Detect such packages as we will need to handle them differently
-
 
1825
    #   Can't really handle it on the fly
-
 
1826
    #   All we can do is detect it and report it - at the moment
-
 
1827
    #
-
 
1828
    if (detectProjectBaseUsage($data, $cc_path) )
-
 
1829
    {
-
 
1830
        unless ( $opt_ignoreProjectBaseErrors )
-
 
1831
        {
-
 
1832
            $data->{BadProjectBase}++;
-
 
1833
            $data->{errStr} = 'Bad usage of ProjectBase detected';
-
 
1834
            return 4;           # Lets see what the others look like too
-
 
1835
#            return 14;
-
 
1836
        }
-
 
1837
    }
-
 
1838
 
-
 
1839
 
-
 
1840
    #
-
 
1841
    #   Developers have been slack
1832
    #   Developers have been slack
1842
    #       Sometime the mark the source path as 'GMTPE2005'
1833
    #       Sometime the mark the source path as 'GMTPE2005'
1843
    #       Sometimes as 'GMTPE2005/Package/Fred/Jill/Harry'
1834
    #       Sometimes as 'GMTPE2005/Package/Fred/Jill/Harry'
1844
    #
1835
    #
1845
    #   Attempt to suck up empty directories below the specified
1836
    #   Attempt to suck up empty directories below the specified
Line 1858... Line 1849...
1858
            Message ("Adjust Base Dir: $testDir");
1849
            Message ("Adjust Base Dir: $testDir");
1859
            $data->{adjustedPath} = $data->{ViewPath};
1850
            $data->{adjustedPath} = $data->{ViewPath};
1860
            $data->{ViewPath} = $testDir;
1851
            $data->{ViewPath} = $testDir;
1861
        }
1852
        }
1862
    }
1853
    }
-
 
1854
    
-
 
1855
    #
-
 
1856
    #   Some really ugly packages make use of a Jats feature called 'SetProjectBase'
-
 
1857
    #   Detect such packages as we will need to handle them differently
-
 
1858
    #   Can't really handle it on the fly
-
 
1859
    #   All we can do is detect it and report it - at the moment
-
 
1860
    #
-
 
1861
    if (detectProjectBaseUsage($data, $cc_path) )
-
 
1862
    {
-
 
1863
        unless ( $opt_ignoreProjectBaseErrors )
-
 
1864
        {
-
 
1865
            $data->{BadProjectBase}++;
-
 
1866
            $data->{errStr} = 'Bad usage of ProjectBase detected';
-
 
1867
            return 4;           # Lets see what the others look like too
-
 
1868
#            return 14;
-
 
1869
        }
-
 
1870
    }
-
 
1871
 
-
 
1872
    #
-
 
1873
    #   Some really really ugly packgaes make use of the MakeProject directive
-
 
1874
    #   and then use an 'include.txt file to access paths all over the VOB
-
 
1875
    #   The problem is with lines like
-
 
1876
    #           /I ..\..\..\..\..\..\DPG_SWCode\projects\seattle\ddu\component\DTIApp\dsi\inc
-
 
1877
    #   Two problems:
-
 
1878
    #       Vob Name is not a part of the migration
-
 
1879
    #       If we 'SuckUp' empty directories then this may break
-
 
1880
    #       the pathing.
-
 
1881
    #   All we can do is detect it and report it - at the moment
-
 
1882
    #
-
 
1883
    if (detectMakeProjectUsage($data, $cc_path) )
-
 
1884
    {
-
 
1885
        unless ( $opt_ignoreMakeProjectErrors )
-
 
1886
        {
-
 
1887
            $data->{BadMakeProject}++;
-
 
1888
            $data->{errStr} = 'Use of MakeProject detected';
-
 
1889
            return 4;           # Lets see what the others look like too
-
 
1890
#            return 14;
-
 
1891
        }
-
 
1892
    }
1863
 
1893
 
1864
    #
1894
    #
1865
    #   Some packages have filenames that are need to be converted
1895
    #   Some packages have filenames that are need to be converted
1866
    #
1896
    #
1867
    if ( $mustConvertFileNames  )
1897
    if ( $mustConvertFileNames  )
Line 2463... Line 2493...
2463
    return 2;
2493
    return 2;
2464
 
2494
 
2465
}
2495
}
2466
 
2496
 
2467
#-------------------------------------------------------------------------------
2497
#-------------------------------------------------------------------------------
-
 
2498
# Function        : detectMakeProjectUsage
-
 
2499
#
-
 
2500
# Description     : etect and report usage of the MakeProject directive
-
 
2501
#
-
 
2502
# Inputs          : $data               - Ref to a hash of bits
-
 
2503
#                   $cc_path            - Packages cc_path
-
 
2504
#
-
 
2505
# Returns         : true    - Bad usage (Really good usage not detected)
-
 
2506
#                   false   - Good usage detected
-
 
2507
#
-
 
2508
sub detectMakeProjectUsage
-
 
2509
{
-
 
2510
    my ($data, $cc_path) = @_;
-
 
2511
    my $retval = 0;
-
 
2512
    my $eSuf = $opt_ignoreMakeProjectErrors ? '' : 'Error';
-
 
2513
 
-
 
2514
    #
-
 
2515
    #   Find makefile.pl
-
 
2516
    #
-
 
2517
    Message ("Locate JATS makefiles");
-
 
2518
    my $usesMakeProject = 0;
-
 
2519
    my $badIncludeFile = 0;
-
 
2520
 
-
 
2521
    my $search = JatsLocateFiles->new("--Recurse=1",
-
 
2522
                                       "--FilterIn=makefile.pl",
-
 
2523
                                       );
-
 
2524
    my @makefiles = $search->search($data->{ViewRoot});
-
 
2525
    foreach my $file ( @makefiles )
-
 
2526
    {
-
 
2527
#print "---Reading: $workDir/$data->{ViewRoot}/$file\n";
-
 
2528
        if ( open( my $fh, '<', "$data->{ViewRoot}/$file" ) )
-
 
2529
        {
-
 
2530
            my $eof = 0;
-
 
2531
            my $line = '';
-
 
2532
            until ( $eof )
-
 
2533
            {
-
 
2534
                my $in = <$fh>;
-
 
2535
                unless ( defined $in )
-
 
2536
                {
-
 
2537
                    $eof = 1;
-
 
2538
                }
-
 
2539
                else
-
 
2540
                {
-
 
2541
                $in =~ s~\s+$~~;
-
 
2542
                $in =~ s~^\s+~~;
-
 
2543
                $in =~ s~^#.*$~~;
-
 
2544
                $in =~ s~\s*[^\$]#.*$~~;
-
 
2545
                $line .= ' ' if ( $line );
-
 
2546
                $line .= $in;
-
 
2547
                $line =~ s~\s+~ ~g;
-
 
2548
#print "====== '$line'\n";
-
 
2549
                redo unless ( $line =~ m~;$~  );
-
 
2550
                }
-
 
2551
#print "---- $line\n";
-
 
2552
                if ( $line =~ m~^MakeProject~ )
-
 
2553
                {
-
 
2554
                    $usesMakeProject++;
-
 
2555
                    $data->{UsesMakeProject}++;
-
 
2556
                    Warning ("Package uses MakeProject:",
-
 
2557
                             "Line: " . $line,
-
 
2558
                             "Root: " . "$data->{ViewRoot}",
-
 
2559
                             "File: " . "$data->{ViewRoot}/$file",
-
 
2560
                            );
-
 
2561
 
-
 
2562
                    #
-
 
2563
                    #   Extract out the project name
-
 
2564
                    #
-
 
2565
                    my @myArgs;
-
 
2566
                    my $myProjectDir;
-
 
2567
                    my $myProject = "$data->{ViewRoot}/$file";
-
 
2568
                    $myProject =~ s~/[^/]+$~~;
-
 
2569
                    $line =~ s~MakeProject~push \@myArgs,~;
-
 
2570
                    eval $line;
-
 
2571
                    Error("Line did not compiler: $line", "Err: $@" ) if ($@);
-
 
2572
                    shift @myArgs;
-
 
2573
                    foreach ( @myArgs )
-
 
2574
                    {
-
 
2575
                        next if ( m~^--~ );
-
 
2576
                        $myProject .= '/' . $_;
-
 
2577
                        $myProjectDir = $myProject;
-
 
2578
                        $myProjectDir =~ s~/[^/]+$~~;
-
 
2579
                        last;
-
 
2580
                    }
-
 
2581
                    Error ("No project Found") unless ( defined $myProjectDir);
-
 
2582
                    if ( -f "$myProjectDir/include.txt" )
-
 
2583
                    {
-
 
2584
                        Warning ("Co-located 'include.txt' file also found");
-
 
2585
                    }
-
 
2586
 
-
 
2587
                    # The only problem is if the include.txt file
-
 
2588
                    # escapes from the VOB - or even uses the vob root
-
 
2589
                    #
-
 
2590
                    # Examine the include file
-
 
2591
                    # Expect it to look like
-
 
2592
                    #   /I Path
-
 
2593
                    #
-
 
2594
 
-
 
2595
                    #
-
 
2596
                    #   Determine safe level
-
 
2597
                    #   Relative to the include file
-
 
2598
                    #
-
 
2599
                    my $depthPath = $myProjectDir;
-
 
2600
                    my $depth = 0;
-
 
2601
                    Error ("Expect this to work") unless ( $depthPath =~ s~^$data->{ViewRoot}/~~ );
-
 
2602
                    foreach ( split('/', $depthPath) )
-
 
2603
                    {
-
 
2604
                        if ( $_ eq '..' ) {
-
 
2605
                            $depth--;
-
 
2606
                        } else {
-
 
2607
                            $depth++;
-
 
2608
                        }
-
 
2609
                    }
-
 
2610
#print "Depth: $depth, $depthPath\n";
-
 
2611
 
-
 
2612
                    if ( open( my $if, '<', "$myProjectDir/include.txt" ) )
-
 
2613
                    {
-
 
2614
                        while ( <$if> )
-
 
2615
                        {
-
 
2616
                            s~\s+$~~;
-
 
2617
                            s~^\s+~~;
-
 
2618
                            next unless ( $_ );
-
 
2619
                            if ( m~/I\s+(.*)~ )
-
 
2620
                            {
-
 
2621
                                my $path = $1;
-
 
2622
                                $path =~ tr~\\/~/~s;
-
 
2623
                                $path =~ s~\\~/~g;
-
 
2624
#print "Examine: $path\n";
-
 
2625
                                my $minLevel = 0;
-
 
2626
                                my $level = 0;
-
 
2627
                                foreach ( split('/', $path) )
-
 
2628
                                {
-
 
2629
                                    if ( $_ eq '..' )
-
 
2630
                                    {
-
 
2631
                                        $level--;
-
 
2632
                                        $minLevel = $level if ($level < $minLevel);
-
 
2633
                                    }
-
 
2634
                                    else
-
 
2635
                                    {
-
 
2636
                                        $level++;
-
 
2637
                                    }
-
 
2638
                                }
-
 
2639
#print "Min: $minLevel, $level, ($depth + $minLevel)\n";
-
 
2640
                                if ( $depth + $minLevel <= 0)
-
 
2641
                                {
-
 
2642
                                    $badIncludeFile++;
-
 
2643
                                    Warning ("Included path escapes package:",
-
 
2644
                                             "Line: " . $_,
-
 
2645
                                             "File: " . "$myProjectDir/include.txt",
-
 
2646
                                            );
-
 
2647
                                    last;
-
 
2648
                                }
-
 
2649
                            }
-
 
2650
                        }
-
 
2651
                        close $if;
-
 
2652
                    }
-
 
2653
 
-
 
2654
                }
-
 
2655
                $line = '';
-
 
2656
            }
-
 
2657
            close $fh;
-
 
2658
        }
-
 
2659
        else
-
 
2660
        {
-
 
2661
            Warning ("MakeProject$eSuf - Cannot open makefile: $file");
-
 
2662
            $retval = 1;
-
 
2663
        }
-
 
2664
    }
-
 
2665
 
-
 
2666
    #
-
 
2667
    #   Used
-
 
2668
    #   May be improved latter
-
 
2669
    #
-
 
2670
    if ( $usesMakeProject && $badIncludeFile)
-
 
2671
    {
-
 
2672
        Warning ("MakeProject$eSuf - Problem detected");
-
 
2673
        $retval = 1;
-
 
2674
    }
-
 
2675
 
-
 
2676
    #
-
 
2677
    #   Until we have more faith in the detection algorithm
-
 
2678
    #
-
 
2679
    if ( $usesMakeProject )
-
 
2680
    {
-
 
2681
        Warning ("MakeProject$eSuf - Makeproject used. Must check manually");
-
 
2682
        $retval = 1;
-
 
2683
    }
-
 
2684
    
-
 
2685
    return $retval;
-
 
2686
}
-
 
2687
 
-
 
2688
#-------------------------------------------------------------------------------
2468
# Function        : detectProjectBaseUsage
2689
# Function        : detectProjectBaseUsage
2469
#
2690
#
2470
# Description     : Detect and report usage of the SetProjectBase directive
2691
# Description     : Detect and report usage of the SetProjectBase directive
2471
#
2692
#
2472
# Inputs          : $data               - Ref to a hash of bits
2693
# Inputs          : $data               - Ref to a hash of bits