Subversion Repositories DevTools

Rev

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

Rev 5233 Rev 5247
Line 126... Line 126...
126
#
126
#
127
$Config->{'releaseAge'} = 0;
127
$Config->{'releaseAge'} = 0;
128
$Config->{'packageAge'} = 0;
128
$Config->{'packageAge'} = 0;
129
$Config->{'logAge'} = 0;
129
$Config->{'logAge'} = 0;
130
$Config->{'verbose'} = 0;
130
$Config->{'verbose'} = 0;
-
 
131
$Config->{GBE_RM_LOCATION} = $ENV{GBE_RM_LOCATION};
-
 
132
$Config->{GBE_RM_USERNAME} = $ENV{GBE_RM_USERNAME};
-
 
133
$Config->{GBE_RM_PASSWORD} = $ENV{GBE_RM_PASSWORD};
131
readConfig();
134
readConfig();
132
 
135
 
133
#
136
#
134
#   Start logging
137
#   Start logging
135
#
138
#
Line 189... Line 192...
189
    push @addressList, inet_ntoa($_); 
192
    push @addressList, inet_ntoa($_); 
190
}
193
}
191
Message("IpAddress: @addressList");
194
Message("IpAddress: @addressList");
192
 
195
 
193
#
196
#
-
 
197
#   Use local Database config - if provided
-
 
198
#
-
 
199
$ENV{GBE_RM_LOCATION} = $Config->{GBE_RM_LOCATION};
-
 
200
$ENV{GBE_RM_USERNAME} = $Config->{GBE_RM_USERNAME};
-
 
201
$ENV{GBE_RM_PASSWORD} = $Config->{GBE_RM_PASSWORD};
-
 
202
 
-
 
203
#
194
#   Perform the hard work
204
#   Perform the hard work
195
#
205
#
196
getReleaseData();
206
getReleaseData();
197
updateReleaseViews() if $opt_createVersions;
207
updateReleaseViews() if $opt_createVersions;
198
cleanReleaseViews();
208
cleanReleaseViews();
199
rebuildLxrConfig()  if $opt_index;
209
rebuildLxrConfig()  if $opt_index;
200
buildIndexes() if $opt_index;
210
buildIndexes() if $opt_index;
-
 
211
updateReleaseManager();
201
cleanPackageStore() if $opt_purge;
212
cleanPackageStore() if $opt_purge;
202
cleanupLogFiles() if $opt_purge;
213
cleanupLogFiles() if $opt_purge;
203
 
214
 
204
#
215
#
205
#   All done
216
#   All done
Line 699... Line 710...
699
        next unless ( -d $vdirName );
710
        next unless ( -d $vdirName );
700
        unless(exists $ReleaseData{$rdirEntry} && $ReleaseData{$rdirEntry}{release}{ACTIVE} )
711
        unless(exists $ReleaseData{$rdirEntry} && $ReleaseData{$rdirEntry}{release}{ACTIVE} )
701
        {
712
        {
702
            #   Release is no longer configured - age it out
713
            #   Release is no longer configured - age it out
703
            #   Assume $rdirEntry is an rtag_id
714
            #   Assume $rdirEntry is an rtag_id
-
 
715
            $ReleaseData{$rdirEntry}{release}{LXRSTATE} = 'C';
704
            if (processAgeMarker($vdirName, $Config->{'releaseAge'} ))
716
            if (processAgeMarker($vdirName, $Config->{'releaseAge'} ))
705
            {
717
            {
-
 
718
                $ReleaseData{$rdirEntry}{release}{LXRSTATE} = 'D';
706
                Message("Delete Release: $rdirEntry");
719
                Message("Delete Release: $rdirEntry");
707
                RmDirTree($vdirName);
720
                RmDirTree($vdirName);
708
                System('--NoExit', '--NoShell', catfile($scriptDir, 'lxr.dropdb.sh'), genDatabaseName($rdirEntry));
721
                System('--NoExit', '--NoShell', catfile($scriptDir, 'lxr.dropdb.sh'), genDatabaseName($rdirEntry));
709
                if ( defined $Config->{glimpseDir} )
722
                if ( defined $Config->{glimpseDir} )
710
                {
723
                {
Line 713... Line 726...
713
                }
726
                }
714
            }
727
            }
715
        }
728
        }
716
        else
729
        else
717
        {
730
        {
-
 
731
            $ReleaseData{$rdirEntry}{release}{LXRSTATE} = 'I';
718
            deleteAgeMarker($vdirName);
732
            deleteAgeMarker($vdirName);
719
 
733
 
720
            #   Release is configured
734
            #   Release is configured
721
            #   Keep the last x created
735
            #   Keep the last x created
722
            #   Note: Create time is a kludge
736
            #   Note: Create time is a kludge
Line 947... Line 961...
947
 
961
 
948
    #
962
    #
949
    # Determine which Releases need LXR support
963
    # Determine which Releases need LXR support
950
    #
964
    #
951
    my $m_sqlstr = 
965
    my $m_sqlstr = 
952
        "SELECT rtag_id, " .
966
        "SELECT rt.rtag_id," .
953
        "  rt.proj_id, " .
967
        "  rt.proj_id," .
954
        "  p.PROJ_NAME, " .
968
        "  p.PROJ_NAME," .
955
        "  rtag_name, " .
969
        "  rt.rtag_name," .
956
        "  official, " .
970
        "  rt.official," .
957
        "  NVL(TRUNC (SYSDATE - rt.official_stamp),0) AS OFFICIAL_STAMP_DAYS, " .
971
        "  NVL(TRUNC (SYSDATE - rt.official_stamp),0) AS OFFICIAL_STAMP_DAYS," .
958
        "  rt.lxr " .
972
        "  rt.lxr,".
-
 
973
        "  lxr.lxrserver" .
959
        "FROM release_tags rt, " .
974
        " FROM release_manager.release_tags rt," .
-
 
975
        "  release_manager.lxr_state lxr," .
960
        "  projects p " .
976
        "  release_manager.projects p" .
-
 
977
        " WHERE lxr.RTAG_ID(+) = rt.RTAG_ID" .
961
        "WHERE ( rt.lxr  = 'Y'" . $partSql . ")" .
978
        " AND (rt.lxr = 'Y'" . $partSql . ")" .
962
        " AND p.PROJ_ID = rt.proj_id ";
979
        " AND p.PROJ_ID = rt.proj_id";
963
 
980
 
-
 
981
    Verbose2('$m_sqlstr',$m_sqlstr);
964
    my $sth = $RM_DB->prepare($m_sqlstr);
982
    my $sth = $RM_DB->prepare($m_sqlstr);
965
    if ( defined($sth) )
983
    if ( defined($sth) )
966
    {
984
    {
967
        if ( $sth->execute( ) )
985
        if ( $sth->execute( ) )
968
        {
986
        {
Line 975... Line 993...
975
                    $data->{Project} = $row[2];
993
                    $data->{Project} = $row[2];
976
                    $data->{Name} = $row[3];
994
                    $data->{Name} = $row[3];
977
                    $data->{official} = substr($row[4],0,1);
995
                    $data->{official} = substr($row[4],0,1);
978
                    $data->{official_stamp_days} = $row[5];
996
                    $data->{official_stamp_days} = $row[5];
979
                    $data->{lxr} = $row[6];
997
                    $data->{lxr} = $row[6];
-
 
998
                    $data->{lxr_state} = $row[7] || 'N';
980
 
999
 
981
                    #
1000
                    #
982
                    #   Determine if this request for an LXR release is OK
1001
                    #   Determine if this request for an LXR release is OK
983
                    #   Ok If the release is Open, CCB or Restricted
1002
                    #   Ok If the release is Open, CCB or Restricted
984
                    #   Ok If closed and has been closed to < 10 days
1003
                    #   Ok If closed and has been closed to < 10 days
Line 1074... Line 1093...
1074
        Error("getReleasePakageData:Prepare failure" );
1093
        Error("getReleasePakageData:Prepare failure" );
1075
    }
1094
    }
1076
}
1095
}
1077
 
1096
 
1078
#-------------------------------------------------------------------------------
1097
#-------------------------------------------------------------------------------
-
 
1098
# Function        : updateReleaseManager 
-
 
1099
#
-
 
1100
# Description     : Feed the state of the releases back into the Release
-
 
1101
#                   manager database
-
 
1102
#                   
-
 
1103
#                   Assumes that the user has write access to ONE table
-
 
1104
#
-
 
1105
# Inputs          : 
-
 
1106
#
-
 
1107
# Returns         : 
-
 
1108
#
-
 
1109
sub updateReleaseManager
-
 
1110
{
-
 
1111
    foreach my $rtagid ( keys %ReleaseData)
-
 
1112
    {
-
 
1113
        my $rentry = $ReleaseData{$rtagid}{release}; 
-
 
1114
        Verbose3("updateReleaseManager:", $rtagid, $rentry->{lxr_state}, $rentry->{LXRSTATE});
-
 
1115
 
-
 
1116
        #
-
 
1117
        #   Only update those that have changed
-
 
1118
        #
-
 
1119
        if ($rentry->{lxr_state} ne $rentry->{LXRSTATE})
-
 
1120
        {
-
 
1121
            my $m_sqlstr;
-
 
1122
            #
-
 
1123
            #   Have just deleted the entry
-
 
1124
            #
-
 
1125
            if ($rentry->{LXRSTATE} eq 'D')
-
 
1126
            {
-
 
1127
                simpleSqlExecute('updateReleaseManager',"DELETE from release_manager.lxr_state where rtag_id = " . $rtagid);
-
 
1128
            }
-
 
1129
            elsif ($rentry->{LXRSTATE} eq 'C')
-
 
1130
            {
-
 
1131
                my $state = 'C';
-
 
1132
                simpleSqlExecute('updateReleaseManager',"begin insert into release_manager.lxr_state (rtag_id, lxrserver) values ($rtagid, '$state'); exception when dup_val_on_index then update release_manager.lxr_state set lxrserver = '$state' where  rtag_id = $rtagid; end; ");
-
 
1133
            }
-
 
1134
            elsif ($rentry->{LXRSTATE} eq 'I')
-
 
1135
            {
-
 
1136
                my $state = 'I';
-
 
1137
                simpleSqlExecute('updateReleaseManager',"begin insert into release_manager.lxr_state (rtag_id, lxrserver) values ($rtagid, '$state'); exception when dup_val_on_index then update release_manager.lxr_state set lxrserver = '$state' where  rtag_id = $rtagid; end; ");
-
 
1138
            }
-
 
1139
            else
-
 
1140
            {
-
 
1141
                Warning("updateReleaseManager. No entry for $rtagid");
-
 
1142
            }
-
 
1143
        }
-
 
1144
    }
-
 
1145
}
-
 
1146
 
-
 
1147
#-------------------------------------------------------------------------------
-
 
1148
# Function        : simpleSqlExecute 
-
 
1149
#
-
 
1150
# Description     : Perform a simple SQL statement that does not return anything
-
 
1151
#                   Used to update the RM database 
-
 
1152
#
-
 
1153
# Inputs          : $pname          - proceedure name ( for logging)
-
 
1154
#                   $m_sqlstr       - Sql to process
-
 
1155
#                    
-
 
1156
#
-
 
1157
# Returns         : 
-
 
1158
#
-
 
1159
sub simpleSqlExecute
-
 
1160
{
-
 
1161
    my ($pname,$m_sqlstr) = @_;
-
 
1162
    my (@row);
-
 
1163
 
-
 
1164
    connectRM(\$RM_DB) unless $RM_DB;
-
 
1165
 
-
 
1166
    Verbose2($pname,$m_sqlstr);
-
 
1167
    my $sth = $RM_DB->prepare($m_sqlstr);
-
 
1168
    if ( defined($sth) )
-
 
1169
    {
-
 
1170
        if ( $sth->execute( ) )
-
 
1171
        {
-
 
1172
            $sth->finish();
-
 
1173
        }
-
 
1174
        else
-
 
1175
        {
-
 
1176
            Warning("$pname.Execute failure: $m_sqlstr", $sth->errstr() );
-
 
1177
        }
-
 
1178
    }
-
 
1179
    else
-
 
1180
    {
-
 
1181
        Error("$pname:Prepare failure" );
-
 
1182
    }
-
 
1183
}
-
 
1184
 
-
 
1185
#-------------------------------------------------------------------------------
1079
# Function        : genDatabaseName 
1186
# Function        : genDatabaseName 
1080
#
1187
#
1081
# Description     : Genertate the name of a database
1188
# Description     : Genertate the name of a database
1082
#
1189
#
1083
# Inputs          : rtag_id 
1190
# Inputs          : rtag_id