Subversion Repositories DevTools

Rev

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

Rev 5211 Rev 5212
Line 146... Line 146...
146
 
146
 
147
#
147
#
148
#   Perform the hard work
148
#   Perform the hard work
149
#
149
#
150
getReleaseData();
150
getReleaseData();
151
determineDataToExtract();
151
extractPackages();
152
createReleaseViews() if $opt_createVersions;
152
createReleaseViews() if $opt_createVersions;
153
cleanReleaseViews();
153
cleanReleaseViews();
154
rebuildLxrConfig();
154
rebuildLxrConfig();
155
buildIndexes() if $opt_index;
155
buildIndexes() if $opt_index;
156
cleanPackageStore() if $opt_purge;
156
cleanPackageStore() if $opt_purge;
Line 161... Line 161...
161
#
161
#
162
Message ("End of LXR. " . localtime(time) ) if $opt_logfile;
162
Message ("End of LXR. " . localtime(time) ) if $opt_logfile;
163
exit 0;
163
exit 0;
164
 
164
 
165
#-------------------------------------------------------------------------------
165
#-------------------------------------------------------------------------------
166
# Function        : determineDataToExtract 
166
# Function        : extractPackages 
167
#
167
#
168
# Description     : Determine the packages that need to be extracted
168
# Description     : Extract Packages from VCS
169
#                   Don't extract them if they already exist
169
#                   Don't extract them if they already exist
-
 
170
#   
-
 
171
#                   Kludge: Prevent extraction from MASS_Dev_Crypto Repo
170
#
172
#
171
# Inputs          : 
173
# Inputs          : 
172
#
174
#
173
# Returns         : 
175
# Returns         : 
174
#
176
#
175
sub determineDataToExtract
177
sub extractPackages
176
{
178
{
177
    foreach my $pvid ( keys{%Packages})
179
    foreach my $pvid ( keys{%Packages})
178
    {
180
    {
179
        my $entry = $Packages{$pvid};
181
        my $entry = $Packages{$pvid};
180
        #DebugDumpData("Entry", \$entry);
182
        #DebugDumpData("Entry", \$entry);
Line 186... Line 188...
186
        {
188
        {
187
            Message("Need to extract: $entry->{name}, $entry->{ver}");
189
            Message("Need to extract: $entry->{name}, $entry->{ver}");
188
            if ($opt_extract)
190
            if ($opt_extract)
189
            {
191
            {
190
                Verbose0("Extracting into: $fullPath");
192
                Verbose0("Extracting into: $fullPath");
191
                if ($entry->{vcs} ~= m~/MASS_Dev_Crypto/~)
193
                if ($entry->{vcs} =~ m~/MASS_Dev_Crypto/~)
192
                {
194
                {
193
                    print "$fullName : SUPPRESSED\n";
195
                    print "$fullName : SUPPRESSED\n";
194
                }
196
                }
195
                else
197
                else
196
                {
198
                {
Line 220... Line 222...
220
#
222
#
221
# Returns         : 
223
# Returns         : 
222
#
224
#
223
sub createReleaseViews
225
sub createReleaseViews
224
{
226
{
-
 
227
    my $latestView;
-
 
228
    my $needNewView;
-
 
229
 
225
    #
230
    #
226
    #   Create a name for the releases - based on a date-time
231
    #   Create a name for the releases - based on a date-time
227
    #   Will be unqiue(ish)
232
    #   Will be unqiue(ish)
228
    #
233
    #
229
    my $dateTag = localtime($stamptime);
234
    my $dateTag = localtime($stamptime);
230
 
235
 
231
    foreach my $rtagid (keys \%ReleaseData)
236
    foreach my $rtagid (keys \%ReleaseData)
232
    {
237
    {
-
 
238
        $latestView = undef;
-
 
239
        $needNewView = 0;
-
 
240
 
233
        my $entry = $ReleaseData{$rtagid};
241
        my $entry = $ReleaseData{$rtagid};
-
 
242
        if ($entry->{data} )
-
 
243
        {
234
        my $latestView = getLatestVersion(catdir($ReleaseStore, $rtagid));
244
            $latestView = getLatestVersion(catdir($ReleaseStore, $rtagid));
235
        my  $needNewView = 1;
245
            $needNewView = 1;
-
 
246
        }
236
 
247
 
237
        #
248
        #
238
        #   Check to see if we really need to create a new view
249
        #   Check to see if we really need to create a new view
239
        #   If the LATEST view contins all the package-versions that we need then
250
        #   If the LATEST view contains all the package-versions that we need then
240
        #   don't create a new one.
251
        #   don't create a new one.
241
        #
252
        #
242
        #   Scan each entry within the Last View
253
        #   Scan each entry within the Last View
243
        #
254
        #
244
        if ($latestView)
255
        if ($latestView)
Line 302... Line 313...
302
            Message("Creating LXR View: $rtagid, $dateTag");
313
            Message("Creating LXR View: $rtagid, $dateTag");
303
            my $releaseDir = catdir($ReleaseStore, $rtagid, $dateTag);
314
            my $releaseDir = catdir($ReleaseStore, $rtagid, $dateTag);
304
            mkpath($releaseDir);
315
            mkpath($releaseDir);
305
            if (-d $releaseDir)
316
            if (-d $releaseDir)
306
            {
317
            {
307
                #
-
 
308
                #   Insert metadata
-
 
309
                #   Used to allow ordering and aging of the releases
-
 
310
                #    
-
 
311
                my $metaDataName = catfile( $releaseDir, '.jatslxr');
-
 
312
                open (my $md, '>' , $metaDataName) || Error ("Cannot create $metaDataName, $!");
-
 
313
                print $md $stamptime;
-
 
314
                close $md;
-
 
315
 
-
 
316
                #
-
 
317
                #   Populate with symlinks to the actual package-versions
-
 
318
                #
-
 
319
                foreach my $pvid (keys $entry->{data})
318
                foreach my $pvid (keys $entry->{data})
320
                {
319
                {
321
                    my $entry = $Packages{$pvid};
320
                    my $entry = $Packages{$pvid};
322
                    my $alias = join('', $entry->{name}, $entry->{ext});
321
                    my $alias = join('', $entry->{name}, $entry->{ext});
323
                    my $fullName = join('_', $entry->{name}, $entry->{ver});
322
                    my $fullName = join('_', $entry->{name}, $entry->{ver});
Line 376... Line 375...
376
        return $rv;
375
        return $rv;
377
    }
376
    }
378
 
377
 
379
    #
378
    #
380
    #   Process configured releases
379
    #   Process configured releases
381
    #   Generate inthe order we wich to display the Releases
380
    #   Generate in the order we wish to display the Releases
382
    #
381
    #
383
    #DebugDumpData("ReleaseData", \%ReleaseData);
382
    #DebugDumpData("ReleaseData", \%ReleaseData);
384
    foreach my $rtagid ( sort ReleaseDataSort keys %ReleaseData )
383
    foreach my $rtagid ( sort ReleaseDataSort keys %ReleaseData )
385
    {
384
    {
386
        my $entry = $ReleaseData{$rtagid};
385
        my $entry = $ReleaseData{$rtagid};
Line 556... Line 555...
556
    {
555
    {
557
        #   Skip hidden files and directories
556
        #   Skip hidden files and directories
558
        next if ($rdirEntry =~ m~^\.~);
557
        next if ($rdirEntry =~ m~^\.~);
559
        my $vdirName = catdir($ReleaseStore, $rdirEntry );
558
        my $vdirName = catdir($ReleaseStore, $rdirEntry );
560
        next unless ( -d $vdirName );
559
        next unless ( -d $vdirName );
561
        unless(exists $ReleaseData{$rdirEntry} && $ReleaseData{$rdirEntry}{release}{LXR} )
560
        unless(exists $ReleaseData{$rdirEntry} && $ReleaseData{$rdirEntry}{release}{ACTIVE} )
562
        {
561
        {
563
            #   Release is no longer configured - age it out
562
            #   Release is no longer configured - age it out
564
            #   Assume $rdirEntry is an rtag_id
563
            #   Assume $rdirEntry is an rtag_id
565
            if (processAgeMarker($vdirName, $config->{'releaseAge'} ))
564
            if (processAgeMarker($vdirName, $config->{'releaseAge'} ))
566
            {
565
            {
Line 569... Line 568...
569
                System('--NoExit', '--NoShell', catfile($scriptDir, 'lxr.dropdb.sh'), genDatabaseName($rdirEntry));
568
                System('--NoExit', '--NoShell', catfile($scriptDir, 'lxr.dropdb.sh'), genDatabaseName($rdirEntry));
570
            }
569
            }
571
        }
570
        }
572
        else
571
        else
573
        {
572
        {
574
            $ReleaseData{$rdirEntry}{release}{root} = $vdirName;
-
 
575
            deleteAgeMarker($vdirName);
573
            deleteAgeMarker($vdirName);
576
 
574
 
577
            #   Release is configured
575
            #   Release is configured
578
            #   Keep the last x created
576
            #   Keep the last x created
579
            #   Note: Create time is a kludge
577
            #   Note: Create time is a kludge
Line 624... Line 622...
624
#
622
#
625
# Description     : For a specified directory return the newest subdir
623
# Description     : For a specified directory return the newest subdir
626
#
624
#
627
#                   Used to determine the most recent version
625
#                   Used to determine the most recent version
628
#
626
#
629
# Inputs          : Dir to process - expecting a Release directory
627
# Inputs          : $vdirName - Dir to process - expecting a Release directory
630
#
628
#
631
# Returns         : 
629
# Returns         : 
632
#
630
#
633
sub getLatestVersion
631
sub getLatestVersion
634
{
632
{
Line 763... Line 761...
763
#
761
#
764
sub getReleaseData
762
sub getReleaseData
765
{
763
{
766
    my ($rtagid) = @_;
764
    my ($rtagid) = @_;
767
    my (@row);
765
    my (@row);
-
 
766
    my @releaseList;
-
 
767
    my $partSql = '';
768
 
768
 
769
    Information("getReleaseData");
769
    Information("getReleaseData");
770
    connectRM(\$RM_DB) unless $RM_DB;
770
    connectRM(\$RM_DB) unless $RM_DB;
771
 
771
 
-
 
772
    #
-
 
773
    #   Determine list of existing Releases
-
 
774
    #   Build up a Clause for the extraction SQL
-
 
775
    #   This is used to get data for Releases that exist in the Store but may have been
-
 
776
    #   deconfigured.
-
 
777
    #
-
 
778
    if ( opendir (my $rdir, $ReleaseStore) )
-
 
779
    {
-
 
780
        while (my $rdirEntry = readdir($rdir))
-
 
781
        {
-
 
782
            #   Skip hidden files and directories
-
 
783
            next if ($rdirEntry =~ m~^\.~);
-
 
784
            my $vdirName = catdir($ReleaseStore, $rdirEntry );
-
 
785
            next unless ( -d $vdirName );
-
 
786
            push @releaseList, $rdirEntry;
-
 
787
        }
-
 
788
        close $rdir;
-
 
789
    }
-
 
790
 
-
 
791
    if (@releaseList)
-
 
792
    {
-
 
793
        $partSql = ' OR rt.rtag_id in (' . join(',', @releaseList ) . ')' 
-
 
794
    }
-
 
795
 
772
 
796
 
773
    #
797
    #
774
    # Determine which Releases need LXR support
798
    # Determine which Releases need LXR support
775
    #
799
    #
776
    my $m_sqlstr = 
800
    my $m_sqlstr = 
777
        "SELECT rtag_id, " .
801
        "SELECT rtag_id, " .
778
        "  rt.proj_id, " .
802
        "  rt.proj_id, " .
779
        "  p.PROJ_NAME, " .
803
        "  p.PROJ_NAME, " .
780
        "  rtag_name, " .
804
        "  rtag_name, " .
781
        "  official, " .
805
        "  official, " .
782
        "  NVL(TRUNC (SYSDATE - rt.official_stamp),0) AS OFFICIAL_STAMP_DAYS " .
806
        "  NVL(TRUNC (SYSDATE - rt.official_stamp),0) AS OFFICIAL_STAMP_DAYS, " .
-
 
807
        "  rt.lxr " .
783
        "FROM release_tags rt, " .
808
        "FROM release_tags rt, " .
784
        "  projects p " .
809
        "  projects p " .
785
        "WHERE rt.lxr  = 'Y' " .
810
        "WHERE ( rt.lxr  = 'Y'" . $partSql . ")" .
786
        "AND p.PROJ_ID = rt.proj_id ";
811
        " AND p.PROJ_ID = rt.proj_id ";
787
 
812
 
788
    my $sth = $RM_DB->prepare($m_sqlstr);
813
    my $sth = $RM_DB->prepare($m_sqlstr);
789
    if ( defined($sth) )
814
    if ( defined($sth) )
790
    {
815
    {
791
        if ( $sth->execute( ) )
816
        if ( $sth->execute( ) )
Line 798... Line 823...
798
                    my $data;
823
                    my $data;
799
                    $data->{Project} = $row[2];
824
                    $data->{Project} = $row[2];
800
                    $data->{Name} = $row[3];
825
                    $data->{Name} = $row[3];
801
                    $data->{official} = substr($row[4],0,1);
826
                    $data->{official} = substr($row[4],0,1);
802
                    $data->{official_stamp_days} = $row[5];
827
                    $data->{official_stamp_days} = $row[5];
-
 
828
                    $data->{lxr} = $row[6];
803
 
829
 
804
                    #
830
                    #
805
                    #   Determine if this request for an LXR release is OK
831
                    #   Determine if this request for an LXR release is OK
806
                    #   Ok If the release is Open, CCB or Restricted
832
                    #   Ok If the release is Open, CCB or Restricted
807
                    #   Ok if closed and has been closed to < 10 days
833
                    #   Ok If closed and has been closed to < 10 days
808
                    #
834
                    #
809
                    if (index('NRC', $data->{official}) >= 0)
835
                    if ($data->{lxr} eq 'Y')
810
                    {
836
                    {
-
 
837
                        if (index('NRC', $data->{official}) >= 0)
-
 
838
                        {
811
                        $data->{LXR} = 1;
839
                            $data->{ACTIVE} = 1;
812
                    }
840
                        }
813
                    elsif ($data->{official} eq 'Y' && $data->{official_stamp_days} < 10)
841
                        elsif ($data->{official} eq 'Y' && $data->{official_stamp_days} < 10 )
814
                    {
842
                        {
815
                        $data->{LXR} = 2;
843
                            $data->{ACTIVE} = 2;
-
 
844
                        }
816
                    }
845
                    }
817
 
846
 
-
 
847
                    $data->{root} = catdir($ReleaseStore, $rtagid );
818
                    $ReleaseData{$rtagid}{release} = $data;
848
                    $ReleaseData{$rtagid}{release} = $data;
819
                }
849
                }
820
            }
850
            }
821
            $sth->finish();
851
            $sth->finish();
822
        }
852
        }
Line 824... Line 854...
824
    else
854
    else
825
    {
855
    {
826
        Error("getReleaseData:Prepare failure" );
856
        Error("getReleaseData:Prepare failure" );
827
    }
857
    }
828
 
858
 
-
 
859
 
829
    DebugDumpData("ReleaseData", \%ReleaseData);
860
    DebugDumpData("ReleaseData", \%ReleaseData);
830
    foreach my $rtagid ( keys %ReleaseData)
861
    foreach my $rtagid ( keys %ReleaseData)
831
    {
862
    {
832
        next unless $ReleaseData{$rtagid}{release}{LXR};
863
        next unless $ReleaseData{$rtagid}{release}{ACTIVE};
833
        Information("Entry: RtagId $rtagid");
864
        Information("Active Release: RtagId $rtagid");
834
        getOneRelease($rtagid);
865
        getOneRelease($rtagid);
835
    }
866
    }
836
}
867
}
837
 
868
 
838
#-------------------------------------------------------------------------------
869
#-------------------------------------------------------------------------------
839
# Function        : getOneRelease
870
# Function        : getOneRelease
840
#
871
#
841
# Description     : Get data for one Release
872
# Description     : Get PackgeVersion information for one Release
842
#
873
#
843
# Inputs          : rtagid
874
# Inputs          : rtagid
844
#
875
#
845
# Returns         : 
876
# Returns         : 
846
#
877
#
Line 875... Line 906...
875
                        $data->{ver} = $row[2];
906
                        $data->{ver} = $row[2];
876
                        $data->{ext} = $row[3] || '';
907
                        $data->{ext} = $row[3] || '';
877
                        $data->{vcs} = $row[4] || '';
908
                        $data->{vcs} = $row[4] || '';
878
                        $Packages{$pvid} = $data;
909
                        $Packages{$pvid} = $data;
879
                    }
910
                    }
880
                    my $rdata;
-
 
881
                    $rdata->{required} = 1;
-
 
882
                    $ReleaseData{$rtagid}{data}{$pvid} = $rdata;
911
                    $ReleaseData{$rtagid}{data}{$pvid} = 1;
883
                }
912
                }
884
            }
913
            }
885
            $sth->finish();
914
            $sth->finish();
886
        }
915
        }
887
    }
916
    }