Subversion Repositories DevTools

Rev

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

Rev 7155 Rev 7163
Line 1... Line 1...
1
package com.erggroup.buildtool.ripple;
1
package com.erggroup.buildtool.ripple;
2
 
2
 
3
import java.sql.SQLException;
3
import java.sql.SQLException;
4
import java.util.ArrayList;
4
import java.util.ArrayList;
5
import java.util.Collections;
5
import java.util.Collections;
-
 
6
import java.util.HashMap;
6
import java.util.Iterator;
7
import java.util.Iterator;
7
import java.util.List;
8
import java.util.List;
8
import java.util.ListIterator;
9
import java.util.ListIterator;
9
 
10
 
10
import org.slf4j.Logger;
11
import org.slf4j.Logger;
11
import org.slf4j.LoggerFactory;
12
import org.slf4j.LoggerFactory;
12
 
13
 
13
import com.erggroup.buildtool.ripple.BuildFile.BuildFileState;
14
import com.erggroup.buildtool.ripple.BuildFile.BuildFileState;
-
 
15
import com.erggroup.buildtool.ripple.Package.PkgDependency;
14
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
16
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
15
import com.erggroup.buildtool.smtp.CreateUrls;
17
import com.erggroup.buildtool.smtp.CreateUrls;
16
import com.erggroup.buildtool.smtp.Smtpsend;
18
import com.erggroup.buildtool.smtp.Smtpsend;
17
import com.erggroup.buildtool.utilities.StringAppender;
19
import com.erggroup.buildtool.utilities.StringAppender;
18
import com.erggroup.buildtool.utilities.XmlBuilder;
20
import com.erggroup.buildtool.utilities.XmlBuilder;
Line 118... Line 120...
118
    /** List of packages that we plan to build
120
    /** List of packages that we plan to build
119
     * Used to provide feedback into RM
121
     * Used to provide feedback into RM
120
     * Only the first entry is about to be built as we re-plan every cycle
122
     * Only the first entry is about to be built as we re-plan every cycle
121
     */
123
     */
122
    private ArrayList<PlannedPackage> mBuildOrder = new ArrayList  <PlannedPackage>();
124
    private ArrayList<PlannedPackage> mBuildOrder = new ArrayList  <PlannedPackage>();
-
 
125
 
-
 
126
    /**
-
 
127
     * Used to convert an alias to a package
-
 
128
     * Must be initialized before use
-
 
129
     */
-
 
130
    private  HashMap<String, Package> pkgMap = new HashMap<String, Package>();
-
 
131
 
123
    /**Warning message
132
    /**Warning message
124
     * @attribute
133
     * @attribute
125
     */
134
     */
126
    private static final String mAnyBuildPlatforms = "Warning. The following package versions are not reproducible on any build platform: ";
135
    private static final String mAnyBuildPlatforms = "Warning. The following package versions are not reproducible on any build platform: ";
127
 
136
 
Line 229... Line 238...
229
        mBuildCollection.clear();
238
        mBuildCollection.clear();
230
        mPackageCollection.clear();
239
        mPackageCollection.clear();
231
        mPackageCollectionRipple.clear();
240
        mPackageCollectionRipple.clear();
232
        mPackageCollectionTest.clear();
241
        mPackageCollectionTest.clear();
233
        mPackageCollectionWip.clear();
242
        mPackageCollectionWip.clear();
-
 
243
        mPackageCollectionAll.clear();
234
        mBuildOrder.clear();
244
        mBuildOrder.clear();
235
        mEscrowRawData = "";
245
        mEscrowRawData = "";
236
        mEscrowSetup = "";
246
        mEscrowSetup = "";
237
        Phase phase = new Phase("Plan");
247
        Phase phase = new Phase("Plan");
238
 
248
 
Line 380... Line 390...
380
        //
390
        //
381
        mPackageCollection.clear();
391
        mPackageCollection.clear();
382
        mPackageCollectionRipple.clear();
392
        mPackageCollectionRipple.clear();
383
        mPackageCollectionTest.clear();
393
        mPackageCollectionTest.clear();
384
        mPackageCollectionWip.clear();
394
        mPackageCollectionWip.clear();
-
 
395
        mPackageCollectionAll.clear();
385
        mBuildOrder.clear();
396
        mBuildOrder.clear();
386
        
397
        
387
        mLogger.warn("planRelease mDaemon {} returned", mDaemon);
398
        mLogger.warn("planRelease mDaemon {} returned", mDaemon);
388
        phase.setPhase("EndPlan");
399
        phase.setPhase("EndPlan");
389
    }
400
    }
Line 439... Line 450...
439
        mLogger.debug("planRelease setup setPackageDependencyCollection");
450
        mLogger.debug("planRelease setup setPackageDependencyCollection");
440
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
451
        for (Iterator<Package> it = mPackageCollectionAll.iterator(); it.hasNext(); )
441
        {
452
        {
442
            Package p = it.next();
453
            Package p = it.next();
443
 
454
 
444
            for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
455
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
445
            {
456
            {
446
                String alias = it2.next();
457
                PkgDependency depEntry = it2.next();
447
                Package dependency = findPackage(alias);
458
                Package dependency = findPackage(depEntry.alias);
448
                p.mPackageDependencyCollection.add(dependency);
459
                depEntry.pkg = dependency;
449
            }
460
            }
450
        }    
461
        }    
451
 
462
 
452
        // Detect and deal with circular dependencies
463
        // Detect and deal with circular dependencies
453
        // Examine all packages under consideration
464
        // Examine all packages under consideration
Line 492... Line 503...
492
                {
503
                {
493
                    continue;
504
                    continue;
494
                }
505
                }
495
            }
506
            }
496
 
507
 
497
            for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
508
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
498
            {
509
            {
499
                String alias = it2.next();
510
                PkgDependency depEntry = it2.next();
500
                Package dependency = findPackage(alias);
511
                Package dependency = findPackage(depEntry.alias);
501
 
512
 
502
                if (dependency == ReleaseManager.NULL_PACKAGE)
513
                if (dependency == ReleaseManager.NULL_PACKAGE)
503
                {
514
                {
504
                    mLogger.info("planRelease dependency is not in the baseline {}", alias);
515
                    mLogger.info("planRelease dependency is not in the baseline {}", depEntry);
505
                    // Exclude the package
516
                    // Exclude the package
506
                    // max 50 chars
517
                    // max 50 chars
507
                    rippleBuildExclude(p, p.mId, "Package build dependency not in the release", -4);
518
                    rippleBuildExclude(p, p.mId, "Package build dependency not in the release", -4);
508
 
519
 
509
                    // take the package out of the build
520
                    // take the package out of the build
Line 636... Line 647...
636
 
647
 
637
                    //    Examine this packages dependencies
648
                    //    Examine this packages dependencies
638
                    //    If one of them does not exist in the 'official release' set then
649
                    //    If one of them does not exist in the 'official release' set then
639
                    //    the package needs to be built against the official release set
650
                    //    the package needs to be built against the official release set
640
                    //    and we can't build any of its dependent packages
651
                    //    and we can't build any of its dependent packages
641
                    Iterator<Integer> it2 = p.mDependencyIDCollection.iterator();
652
                    Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator();
642
                    Iterator<Package> it3 = p.mPackageDependencyCollection.iterator();
-
 
643
                    while ( it2.hasNext() && it3.hasNext() )
653
                    while ( it2.hasNext() )
644
                    {
654
                    {
645
                        Integer dpvId = it2.next();
-
 
646
                        Package dependency = it3.next();
655
                        PkgDependency depEntry = it2.next();
647
 
656
 
648
                        if ( !dependency.mAdvisoryRipple )
657
                        if ( !depEntry.pkg.mAdvisoryRipple )
649
                        {
658
                        {
650
                            // not advisory, ie: has ripple build impact
659
                            // not advisory, ie: has ripple build impact
651
                            if ( !isInRelease(dpvId) )
660
                            if ( !isInRelease(depEntry.pvId) )
652
                            {
661
                            {
653
                                // the package is out of date
662
                                // the package is out of date
654
                                // exclude all dependent package versions
663
                                // exclude all dependent package versions
655
                                mLogger.info("planRelease package out of date {}", p.mName);
664
                                mLogger.info("planRelease package out of date {}", p.mName);
656
                                p.mBuildReason = BuildReason.Ripple;
665
                                p.mBuildReason = BuildReason.Ripple;
Line 730... Line 739...
730
                                {
739
                                {
731
                                    //  [JATS-331] Unable to rebuild package with Advisory Ripple dependencies
740
                                    //  [JATS-331] Unable to rebuild package with Advisory Ripple dependencies
732
                                    //    Examine this packages dependencies
741
                                    //    Examine this packages dependencies
733
                                    //    If one of them does not exist in the 'official release' set then
742
                                    //    If one of them does not exist in the 'official release' set then
734
                                    //    the package cannot be rebuilt in this release.
743
                                    //    the package cannot be rebuilt in this release.
735
                                    for (Iterator<Integer> it2 = p.mDependencyIDCollection.iterator() ; it2.hasNext() ;)
744
                                    for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator() ; it2.hasNext() ;)
736
                                    {
745
                                    {
737
                                        Integer dpvId = it2.next();
746
                                        PkgDependency dpvId = it2.next();
738
                                        if ( !isInRelease(dpvId) )
747
                                        if ( !isInRelease(dpvId.pvId) )
739
                                        {
748
                                        {
740
                                            // This package cannot be rebuilt as one of its dependents is NOT in this release
749
                                            // This package cannot be rebuilt as one of its dependents is NOT in this release
741
                                            // exclude all dependent package versions
750
                                            // exclude all dependent package versions
742
                                            
751
                                            
743
                                            mLogger.info("planRelease package not found in archive. Cannot be rebuilt due to {}", p.mName);
752
                                            mLogger.info("planRelease package not found in archive. Cannot be rebuilt due to {}", p.mName);
Line 827... Line 836...
827
                    {
836
                    {
828
                        mLogger.info("planRelease {} not built in this release {}", reason, p.mName);
837
                        mLogger.info("planRelease {} not built in this release {}", reason, p.mName);
829
                    }
838
                    }
830
                }
839
                }
831
            }
840
            }
832
 
-
 
833
            //  Daemon Mode Only
-
 
834
            //  Locate Test Build Requests that cannot be satisfied - will not be built due to
-
 
835
            //  errors in dependent packages. Report the error to the user and remove the request
-
 
836
            //
-
 
837
            phase.setPhase("Scan unsatisfied test build requests");
-
 
838
            for (Iterator<Package> it = mPackageCollectionTest.iterator(); it.hasNext(); )
-
 
839
            {
-
 
840
                Package p = it.next();
-
 
841
 
-
 
842
                if (p.mBuildFile < 0)
-
 
843
                {
-
 
844
                    String reason;
-
 
845
                    switch (p.mBuildFile)
-
 
846
                    {
-
 
847
                    case -1:  reason = "Not reproducible"; break;
-
 
848
                    case -2:  reason = "Not reproducible on configured build platforms"; break;
-
 
849
                    case -3:  reason = "Marked as 'Do not ripple'"; break;
-
 
850
                    case -4:  reason = "Dependent on a package not in the release"; break;
-
 
851
                    case -5:  reason = "Indirectly dependent on a package not reproducible in the release"; break;
-
 
852
                    case -6:  reason = "Has a circular dependency"; break;
-
 
853
                    case -7:  reason = "Pegged or SDK package not in dpkg_archive"; break;
-
 
854
                    case -8:  reason = "Is a Pegged or SDK package"; break;
-
 
855
                    case -9:  reason = "Rejected Daemon Instruction"; break;
-
 
856
                    case -10: reason = "Unbuildable package not in dpkg_archive"; break;
-
 
857
                    case -11: reason = "Marked as 'RippleStop'"; break;
-
 
858
                    default:  reason = "Unknown reason. Code:" + p.mBuildFile; break;
-
 
859
                    }
-
 
860
                    mLogger.error("planRelease Test Build of an unbuildable of package deleted: {}", p.mName);
-
 
861
                    mReleaseManager.markDaemonInstCompleted( p.mTestBuildInstruction );
-
 
862
                    emailRejectedDaemonInstruction(reason,p);
-
 
863
                }
-
 
864
            }
-
 
865
        }
841
        }
866
        else
842
        else
867
        {
843
        {
868
            // escrow reporting only
844
            // escrow reporting only
869
            // Report packages that are not reproducible
845
            // Report packages that are not reproducible
Line 974... Line 950...
974
                //  Otherwise we use basic plan FOLLOWED by the a MODIFIED full plan (one without the natural ripples)
950
                //  Otherwise we use basic plan FOLLOWED by the a MODIFIED full plan (one without the natural ripples)
975
                //  Add the planned packages into the buildOrder
951
                //  Add the planned packages into the buildOrder
976
    
952
    
977
                if( !basicPlan.planCollection.isEmpty() && !fullPlan.planCollection.isEmpty() )
953
                if( !basicPlan.planCollection.isEmpty() && !fullPlan.planCollection.isEmpty() )
978
                {
954
                {
979
                    mLogger.error("Two plan selection: {} {}, {} <= {}", basicPlan.planTime,fullPlan.planTime, basicPlan.planTime * 12, fullPlan.planTime * 10);
955
                    mLogger.error("Two plan selection: {} {}, {} <= {} = {}", basicPlan.planTime,fullPlan.planTime, basicPlan.planTime * 1.2, fullPlan.planTime, (basicPlan.planTime * 12) <= (fullPlan.planTime * 10) );
980
                    
956
                    
981
                    //
957
                    //
982
                    //  Report numbers for Bryan - can be removed after Aug-2019
958
                    //  Report numbers for Bryan - can be removed after Aug-2019
983
                    //  See PX-14283
959
                    //  See PX-14283
984
                    //
960
                    //
Line 1131... Line 1107...
1131
 
1107
 
1132
                //
1108
                //
1133
                //  Report packages that are indirectly excluded
1109
                //  Report packages that are indirectly excluded
1134
                //  ie: They will not be built because one, or more, of their dependents is not buildable
1110
                //  ie: They will not be built because one, or more, of their dependents is not buildable
1135
                //
1111
                //
1136
                mLogger.debug("planBuildOrder process packages which are not ripple buildable");
1112
                mLogger.warn("planBuildOrder process packages which are not ripple buildable");
1137
 
1113
 
1138
                Package.resetCircularDependency (mPackageCollection);
1114
                Package.resetCircularDependency (mPackageCollection);
1139
                 for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
1115
                 for (ListIterator<BuildExclusion> it = mBuildExclusionCollection.listIterator(); it.hasNext(); )
1140
                 {
1116
                 {
1141
                     BuildExclusion be = it.next();
1117
                     BuildExclusion be = it.next();
Line 1146... Line 1122...
1146
 
1122
 
1147
                         // ensure only root cause, non test build, build exclusions are excluded
1123
                         // ensure only root cause, non test build, build exclusions are excluded
1148
                         // mBuildExclusionCollection is at this point based on
1124
                         // mBuildExclusionCollection is at this point based on
1149
                         // relevant (direct and indirect) excluded pv's in the database
1125
                         // relevant (direct and indirect) excluded pv's in the database
1150
                         
1126
                         
1151
                         if ( be.compare(p.mId) && be.isARootCause() && p.mTestBuildInstruction == 0 && p.mForcedRippleInstruction == 0 )
1127
                         // TODO - Do we need && p.mTestBuildInstruction == 0 && p.mForcedRippleInstruction == 0
-
 
1128
                         
-
 
1129
                         if ( be.compare(p.mId) && be.isARootCause()  )
1152
                         {
1130
                         {
1153
                             // package is not reproducible, discard it and its consumers
1131
                             // package is not reproducible, discard it and its consumers
1154
                             //
1132
                             //
1155
                             mLogger.info("Excluded Package {}, {}", p.mAlias, be );                                     
1133
                             mLogger.warn("Excluded Package {}, {}", p.mAlias, be );                                     
1156
                             
1134
                             
1157
                             ArrayList<Package> toExclude = new ArrayList<Package>();
1135
                             ArrayList<Package> toExclude = new ArrayList<Package>();
1158
                             toExclude.addAll(usedByAnyPackages(p, mPackageCollectionAll ));
1136
                             toExclude.addAll(usedByAnyPackages(p, mPackageCollectionAll ));
1159
                             
1137
                             
1160
                             //  Process packages that we need to exclude indirectly
1138
                             //  Process packages that we need to exclude indirectly
Line 1187... Line 1165...
1187
                                 
1165
                                 
1188
                                 if (!found)
1166
                                 if (!found)
1189
                                 {
1167
                                 {
1190
                                     BuildExclusion buildExclusion = new BuildExclusion(pkg.mId, p.mId, null, p.mTestBuildInstruction);
1168
                                     BuildExclusion buildExclusion = new BuildExclusion(pkg.mId, p.mId, null, p.mTestBuildInstruction);
1191
                                     it.add(buildExclusion);
1169
                                     it.add(buildExclusion);
1192
                                     mLogger.info("Indirectly Excluded Package {}", pkg.mAlias);
1170
                                     mLogger.warn("Indirectly Excluded Package {}", pkg.mAlias);
1193
                                     pkg.mBuildFile = -5; 
1171
                                     pkg.mBuildFile = -5; 
1194
                                 }
1172
                                 }
1195
                                 
1173
                                 
1196
                                 // Determine all packages that use this excluded package
1174
                                 // Determine all packages that use this excluded package
1197
                                 // THAT WE HAVE NOT ALREADY PROCESSED - circular dependencies are a killer
1175
                                 // THAT WE HAVE NOT ALREADY PROCESSED - circular dependencies are a killer
Line 1210... Line 1188...
1210
                         }
1188
                         }
1211
                     }
1189
                     }
1212
                 }
1190
                 }
1213
                 
1191
                 
1214
                 //
1192
                 //
-
 
1193
                 // Handle daemon Instructions that cannot be satisfied
-
 
1194
                 // Need to be rejected to prevent continuous planning
-
 
1195
                 //
-
 
1196
                 mLogger.warn("Handle unsatisfied Daemon Instructions");
-
 
1197
                 reportUnsatisfiedDaemonInstructions();
-
 
1198
                 
-
 
1199
                 //
1215
                 //  Examine the build order and 'delete' entries with a -ve mBuildFile
1200
                 //  Examine the build order and 'delete' entries with a -ve mBuildFile
1216
                 //  These will be the product of pvApply errors and the packages that depend on them
1201
                 //  These will be the product of pvApply errors and the packages that depend on them
1217
                 //
1202
                 //
1218
                 //     Insert a dummy marker between build plans
1203
                 //  Insert a dummy marker between build plans
-
 
1204
                 //     Detect the index of the insertion point
1219
                 //
1205
                 //
1220
                 int lastLevel = -1;
1206
                 int lastLevel = -1;
1221
                 int listIndex = 0;
1207
                 int listIndex = 0;
1222
                 int insertMarker = -1;
1208
                 int insertMarker = -1;
1223
                 for (Iterator<PlannedPackage> it = mBuildOrder.listIterator(); it.hasNext(); )
1209
                 for (Iterator<PlannedPackage> it = mBuildOrder.listIterator(); it.hasNext(); )
Line 1336... Line 1322...
1336
        PlanResults results = new PlanResults();
1322
        PlanResults results = new PlanResults();
1337
 
1323
 
1338
        //  Reset flags used in the calculations
1324
        //  Reset flags used in the calculations
1339
        Package.resetProcessed(packageCollection);
1325
        Package.resetProcessed(packageCollection);
1340
        
1326
        
-
 
1327
        
1341
        //  Exclude all packages that cannot be built and all packages that depend on them
1328
        //  Exclude all packages that cannot be built and all packages that depend on them
1342
        //      First find packages to be directly excluded
1329
        //      First find packages to be directly excluded
1343
        ArrayList<Package>exclude = new ArrayList<Package>();
1330
        ArrayList<Package>exclude = new ArrayList<Package>();
1344
        phase.setPhase("Exclude Unbuildable");
1331
        phase.setPhase("Exclude Unbuildable");
1345
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1332
        for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
Line 1391... Line 1378...
1391
            mLogger.info("planCollection package not buildable {}. {},{}", p, p.mProcessed, p.mIsProcessed);
1378
            mLogger.info("planCollection package not buildable {}. {},{}", p, p.mProcessed, p.mIsProcessed);
1392
            
1379
            
1393
            p.mProcessed = true;                        // Used to indicate pkg has had its dependencies scanned
1380
            p.mProcessed = true;                        // Used to indicate pkg has had its dependencies scanned
1394
            p.mIsProcessed = true;                      // Used to indicate pkg has been added to list to process 
1381
            p.mIsProcessed = true;                      // Used to indicate pkg has been added to list to process 
1395
 
1382
 
1396
            
1383
 
1397
            for (Iterator<Package> it1 = packageCollection.iterator(); it1.hasNext(); )
1384
            for (Iterator<Package> it1 = packageCollection.iterator(); it1.hasNext(); )
1398
            {
1385
            {
1399
                Package pkg = it1.next();
1386
                Package pkg = it1.next();
1400
                if (pkg.mProcessed) {
1387
                if (pkg.mProcessed) {
1401
                    continue;
1388
                    continue;
1402
                }
1389
                }
1403
                
1390
                
1404
                for (Iterator<String> it = pkg.mDependencyCollection.iterator(); it.hasNext(); )
1391
                for (Iterator<PkgDependency> it = pkg.mDependencyCollection.iterator(); it.hasNext(); )
1405
                {
1392
                {
1406
                    String alias = it.next();
1393
                    PkgDependency depEntry = it.next();
1407
                    if ( p.mAlias.compareTo( alias ) == 0 ) {
1394
                    if ( p.mAlias.compareTo( depEntry.alias ) == 0 ) {
1408
                        if (!pkg.mIsProcessed) {
1395
                        if (!pkg.mIsProcessed) {
1409
                            pkg.mIsProcessed = true;
1396
                            pkg.mIsProcessed = true;
1410
                            exclude.add(pkg);
1397
                            exclude.add(pkg);
1411
                        }
1398
                        }
1412
                    }
1399
                    }
Line 1422... Line 1409...
1422
        {
1409
        {
1423
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
1410
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
1424
            
1411
            
1425
            //
1412
            //
1426
            //  Daemon Mode
1413
            //  Daemon Mode
1427
            //  Generate the ripplePlan - collection of packages that we need to build inthe current ripple
1414
            //  Generate the ripplePlan - collection of packages that we need to build in the current ripple
1428
            //
1415
            //
1429
            //  Determine if we have a reason to build anything in this collection of buildable packages
1416
            //  Determine if we have a reason to build anything in this collection of buildable packages
1430
            //      Reset the mCheckedCircularDependency - it will be used to detect  that we have processed a package
1417
            //      Reset the mCheckedCircularDependency - it will be used to detect  that we have processed a package
1431
            
1418
            
1432
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1419
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
Line 1468... Line 1455...
1468
                    {
1455
                    {
1469
                        ripplePlan.add(pkg);
1456
                        ripplePlan.add(pkg);
1470
                        results.planTime += pkg.mPkg.mBuildTime;
1457
                        results.planTime += pkg.mPkg.mBuildTime;
1471
                        pkg.mPkg.mCheckedCircularDependency = true;
1458
                        pkg.mPkg.mCheckedCircularDependency = true;
1472
                        
1459
                        
-
 
1460
                        // TODO - Used the mUsedBy stuff
-
 
1461
                        // How do we handle duplicates ?
1473
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
1462
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
1474
                        toBuild.addAll(usedBy);
1463
                        toBuild.addAll(usedBy);
1475
                    }
1464
                    }
1476
                }
1465
                }
1477
            }
1466
            }
Line 1514... Line 1503...
1514
            {
1503
            {
1515
                PlannedPackage p = it.next();
1504
                PlannedPackage p = it.next();
1516
                if ( p.mPkg.mCheckedCircularDependency )
1505
                if ( p.mPkg.mCheckedCircularDependency )
1517
                {
1506
                {
1518
                    boolean found = false;
1507
                    boolean found = false;
1519
                    for (Iterator<String> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
1508
                    for (Iterator<PkgDependency> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
1520
                    {
1509
                    {
1521
                        String alias = it2.next();
1510
                        PkgDependency depEntry = it2.next();
1522
                        for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
1511
                        for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
1523
                        {
1512
                        {
1524
                            PlannedPackage pkg = it3.next();
1513
                            PlannedPackage pkg = it3.next();
1525
                            if (pkg.mPkg.mAlias.compareTo( alias ) == 0)
1514
                            if (pkg.mPkg.mAlias.compareTo( depEntry.alias ) == 0)
1526
                            {
1515
                            {
1527
                                found = pkg.mPkg.mCheckedCircularDependency ;
1516
                                found = pkg.mPkg.mCheckedCircularDependency ;
1528
                                break;
1517
                                break;
1529
                            }
1518
                            }
1530
                        }
1519
                        }
Line 1608... Line 1597...
1608
                        {
1597
                        {
1609
                            PlannedPackage pkg = it1.next();
1598
                            PlannedPackage pkg = it1.next();
1610
                            if (pkg.mPkg == p)
1599
                            if (pkg.mPkg == p)
1611
                            {
1600
                            {
1612
                                mLogger.error("Test Plan without {}", p.mAlias);
1601
                                mLogger.error("Test Plan without {}", p.mAlias);
1613
                                continue;
1602
                                break;
1614
                            }
1603
                            }
1615
                        }
1604
                        }
1616
                    }
1605
                    }
1617
                    
1606
                    
1618
                    mLogger.error("Test Plan with {}", p.mAlias);
1607
                    mLogger.error("Test Plan with {}", p.mAlias);
Line 1668... Line 1657...
1668
            PlannedPackage p = it.next();
1657
            PlannedPackage p = it.next();
1669
            
1658
            
1670
            //  Is this package 'actively used' in the current build
1659
            //  Is this package 'actively used' in the current build
1671
            if (p.mPkg.mBuildFile >= 0)
1660
            if (p.mPkg.mBuildFile >= 0)
1672
            {
1661
            {
1673
                for (Iterator<String> it2 = p.mPkg.mDependencyCollection.iterator(); it2.hasNext(); )
1662
                for (Iterator<PkgDependency> it2 = p.mPkg.mDependencyCollection.iterator(); it2.hasNext(); )
1674
                {
1663
                {
1675
                    String alias = it2.next();
1664
                    PkgDependency depEntry = it2.next();
1676
                    if (  pkg.mPkg.mAlias.compareTo( alias ) == 0  ) {
1665
                    if (  pkg.mPkg.mAlias.compareTo( depEntry.alias ) == 0  ) {
1677
                        //  Have found a consumer of 'pkg'
1666
                        //  Have found a consumer of 'pkg'
1678
                        usedBy.add(p);
1667
                        usedBy.add(p);
1679
                        break;
1668
                        break;
1680
                    }
1669
                    }
1681
                }
1670
                }
Line 1700... Line 1689...
1700
        
1689
        
1701
        for (Iterator<Package> it = pkgCollection.iterator(); it.hasNext(); )
1690
        for (Iterator<Package> it = pkgCollection.iterator(); it.hasNext(); )
1702
        {
1691
        {
1703
            Package p = it.next();
1692
            Package p = it.next();
1704
            
1693
            
1705
            for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
1694
            for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
1706
            {
1695
            {
1707
                String alias = it2.next();
1696
                PkgDependency depEntry = it2.next();
1708
                if (  pkg.mAlias.compareTo( alias ) == 0  ) {
1697
                if (  pkg.mAlias.compareTo( depEntry.alias ) == 0  ) {
1709
                    usedBy.add(p);
1698
                    usedBy.add(p);
1710
                    break;
1699
                    break;
1711
                }
1700
                }
1712
            }
1701
            }
1713
        }
1702
        }
1714
        
1703
        
1715
        return usedBy;
1704
        return usedBy;
1716
    }
1705
    }
-
 
1706
    
-
 
1707
    /**
-
 
1708
     *  Locate Daemon Instructions ( TEST and RIPPLE ) Requests that cannot be satisfied - will not be built due to
-
 
1709
     *  errors in dependent packages. Report the error to the user and remove the request
-
 
1710
     *  
-
 
1711
     *  These need o be rejected now as the the Master logic will plan a build a build if there is a daemon instruction
-
 
1712
     *  present. If an instruction cannot be processed and is not removed, then the daemon will continuously 'plan'
-
 
1713
     */
-
 
1714
    private void reportUnsatisfiedDaemonInstructions() throws SQLException, Exception {
-
 
1715
        ArrayList<Package> toProcess = new ArrayList<Package>();
-
 
1716
        toProcess.addAll(mPackageCollectionTest);
-
 
1717
        toProcess.addAll(mPackageCollectionRipple);
-
 
1718
    
-
 
1719
        for (Iterator<Package> it = toProcess.iterator(); it.hasNext(); )
-
 
1720
        {
-
 
1721
            Package p = it.next();
-
 
1722
    
-
 
1723
            //
-
 
1724
            //  If the package is in the 'plan, then its not excluded
-
 
1725
            //
-
 
1726
            boolean isPlanned = false;
-
 
1727
            for (Iterator<PlannedPackage> it1 = mBuildOrder.listIterator(); it1.hasNext(); )
-
 
1728
            {
-
 
1729
                PlannedPackage pkg = it1.next();
-
 
1730
                if (pkg.mPkg == p)
-
 
1731
                {
-
 
1732
                    isPlanned = true;
-
 
1733
                    break;
-
 
1734
                }
-
 
1735
            }
-
 
1736
    
-
 
1737
            if (! isPlanned) 
-
 
1738
            {
-
 
1739
    
-
 
1740
                // If this package has been excluded, then we can't build it
-
 
1741
                //
-
 
1742
                boolean excluded = false;
-
 
1743
                for (ListIterator<BuildExclusion> it1 = mBuildExclusionCollection.listIterator(); it1.hasNext(); )
-
 
1744
                {
-
 
1745
                    BuildExclusion be = it1.next();
-
 
1746
                    if (be.compare(p.mId))
-
 
1747
                    {
-
 
1748
                        excluded = true;
-
 
1749
                        if (p.mBuildFile >= 0)
-
 
1750
                            p.mBuildFile = -5;
-
 
1751
                        break;
-
 
1752
                    }
-
 
1753
                }
-
 
1754
    
-
 
1755
    
-
 
1756
                if (excluded)
-
 
1757
                {
-
 
1758
                    String reason;
-
 
1759
                    switch (p.mBuildFile)
-
 
1760
                    {
-
 
1761
                    case -1:  reason = "Not reproducible"; break;
-
 
1762
                    case -2:  reason = "Not reproducible on configured build platforms"; break;
-
 
1763
                    case -3:  reason = "Marked as 'Do not ripple'"; break;
-
 
1764
                    case -4:  reason = "Dependent on a package not in the release"; break;
-
 
1765
                    case -5:  reason = "Indirectly dependent on a package not reproducible in the release"; break;
-
 
1766
                    case -6:  reason = "Has a circular dependency"; break;
-
 
1767
                    case -7:  reason = "Pegged or SDK package not in dpkg_archive"; break;
-
 
1768
                    case -8:  reason = "Is a Pegged or SDK package"; break;
-
 
1769
                    case -9:  reason = "Rejected Daemon Instruction"; break;
-
 
1770
                    case -10: reason = "Unbuildable package not in dpkg_archive"; break;
-
 
1771
                    case -11: reason = "Marked as 'RippleStop'"; break;
-
 
1772
                    case -12: reason = "Cannot generate next version number"; break;
-
 
1773
                    default:  reason = "Unknown reason. Code:" + p.mBuildFile; break;
-
 
1774
                    }
-
 
1775
                    mLogger.warn("planRelease Test Build of an unbuildable of package deleted: {}", p);
-
 
1776
    
-
 
1777
                    int daemonInstruction = p.mTestBuildInstruction > 0  ? p.mTestBuildInstruction : p.mForcedRippleInstruction; 
-
 
1778
                    if ( daemonInstruction <= 0)
-
 
1779
                    {
-
 
1780
                        mLogger.error("Daemon Instruction number not found for {}", p);
-
 
1781
                    }
-
 
1782
    
-
 
1783
                    mReleaseManager.markDaemonInstCompleted( daemonInstruction );
-
 
1784
                    emailRejectedDaemonInstruction(reason,p);
-
 
1785
                }
-
 
1786
            }
-
 
1787
        }
-
 
1788
    
-
 
1789
    }
1717
 
1790
 
1718
    /** Determine if a given PVID is a member of the current release.
1791
    /** Determine if a given PVID is a member of the current release.
1719
     *  Used to determine if a package dependency is out of date
1792
     *  Used to determine if a package dependency is out of date
1720
     * 
1793
     * 
1721
     * @param dpvId
1794
     * @param dpvId
Line 2275... Line 2348...
2275
                    element.addProperty("abt_package_build_info", buildInfoText(p));
2348
                    element.addProperty("abt_package_build_info", buildInfoText(p));
2276
 
2349
 
2277
                    // depends in the form 'cs','25.1.0000.cr';'Dinkumware_STL','1.0.0.cots'
2350
                    // depends in the form 'cs','25.1.0000.cr';'Dinkumware_STL','1.0.0.cots'
2278
                    StringAppender depends = new StringAppender(";");
2351
                    StringAppender depends = new StringAppender(";");
2279
 
2352
 
2280
                    for (Iterator<Package> it3 = p.mPackageDependencyCollection.iterator(); it3.hasNext(); )
2353
                    for (Iterator<PkgDependency> it3 = p.mDependencyCollection.iterator(); it3.hasNext(); )
2281
                    {
2354
                    {
2282
                        Package depend = it3.next();
2355
                        PkgDependency depEntry = it3.next();
2283
                        depends.append( quoteString(depend.mName, depend.mVersion + depend.mExtension) );
2356
                        depends.append( quoteString(depEntry.pkg.mName, depEntry.pkg.mVersion + depEntry.pkg.mExtension) );
2284
                    }
2357
                    }
2285
 
2358
 
2286
                    element.addProperty("abt_package_depends", depends.toString());
2359
                    element.addProperty("abt_package_depends", depends.toString());
2287
                    element.addProperty("abt_is_ripple", p.mDirectlyPlanned ? "0" : "1");
2360
                    element.addProperty("abt_is_ripple", p.mDirectlyPlanned ? "0" : "1");
2288
                    element.addProperty("abt_build_reason", p.mBuildReason.toString());
2361
                    element.addProperty("abt_build_reason", p.mBuildReason.toString());
Line 2369... Line 2442...
2369
    {
2442
    {
2370
        StringBuilder comment = new StringBuilder();
2443
        StringBuilder comment = new StringBuilder();
2371
        StringBuilder deps = new StringBuilder();
2444
        StringBuilder deps = new StringBuilder();
2372
        
2445
        
2373
        String joiner = "";
2446
        String joiner = "";
2374
        for (Iterator<String> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
2447
        for (Iterator<PkgDependency> it2 = p.mDependencyCollection.iterator(); it2.hasNext(); )
2375
        {
2448
        {
2376
            String alias = it2.next();
2449
            PkgDependency depEntry = it2.next();
2377
            deps.append(joiner).append(alias); 
2450
            deps.append(joiner).append(depEntry.alias); 
2378
            joiner = ",";
2451
            joiner = ",";
2379
        }
2452
        }
2380
        
2453
        
2381
        comment.append("pvid=").append(p.mId);
2454
        comment.append("pvid=").append(p.mId);
2382
        comment.append(" name=").append('"').append(p.mAlias).append('"');
2455
        comment.append(" name=").append('"').append(p.mAlias).append('"');
Line 2441... Line 2514...
2441
                //  Escrow Only:
2514
                //  Escrow Only:
2442
                //  Generate the 'wrapper' target
2515
                //  Generate the 'wrapper' target
2443
                //  This is used to ensure that the required dependencies have been built - I think
2516
                //  This is used to ensure that the required dependencies have been built - I think
2444
                //
2517
                //
2445
                StringAppender dependList = new StringAppender(",");
2518
                StringAppender dependList = new StringAppender(",");
2446
                if ( !p.mPackageDependencyCollection.isEmpty() )
2519
                if ( !p.mDependencyCollection.isEmpty() )
2447
                {
2520
                {
2448
                    for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
2521
                    for (Iterator<PkgDependency> it = p.mDependencyCollection.iterator(); it.hasNext(); )
2449
                    {
2522
                    {
2450
                        Package dependency = it.next();
2523
                        PkgDependency depEntry = it.next();
2451
                        if ( !mDaemon && dependency.mBuildFile == -2 )
2524
                        if ( !mDaemon && depEntry.pkg.mBuildFile == -2 )
2452
                        {
2525
                        {
2453
                            // ignore targets which build in foreign environments in escrow mode
2526
                            // ignore targets which build in foreign environments in escrow mode
2454
                            continue;
2527
                            continue;
2455
                        }
2528
                        }
2456
                        dependList.append(dependency.mAlias);
2529
                        dependList.append(depEntry.pkg.mAlias);
2457
                    }
2530
                    }
2458
                }
2531
                }
2459
    
2532
    
2460
                XmlBuilder target = xml.addNewElement("target").isExpanded();
2533
                XmlBuilder target = xml.addNewElement("target").isExpanded();
2461
                target.addAttribute("name", p.mAlias + ".wrap");
2534
                target.addAttribute("name", p.mAlias + ".wrap");
Line 2466... Line 2539...
2466
                }
2539
                }
2467
    
2540
    
2468
                if ( !mDaemon )
2541
                if ( !mDaemon )
2469
                {
2542
                {
2470
                    boolean hasDependenciesBuiltInThisIteration = false;
2543
                    boolean hasDependenciesBuiltInThisIteration = false;
2471
                    if ( ( !p.mPackageDependencyCollection.isEmpty()) )
2544
                    if ( ( !p.mDependencyCollection.isEmpty()) )
2472
                    {
2545
                    {
2473
                        for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
2546
                        for (Iterator<PkgDependency> it = p.mDependencyCollection.iterator(); it.hasNext(); )
2474
                        {
2547
                        {
2475
                            Package dependency = it.next();
2548
                            PkgDependency depEntry = it.next();
2476
    
2549
    
2477
                            if ( dependency.mBuildFile == buildFile )
2550
                            if ( depEntry.pkg.mBuildFile == buildFile )
2478
                            {
2551
                            {
2479
                                hasDependenciesBuiltInThisIteration = true;
2552
                                hasDependenciesBuiltInThisIteration = true;
2480
                                break;
2553
                                break;
2481
                            }
2554
                            }
2482
                        }
2555
                        }
Line 2487... Line 2560...
2487
                        XmlBuilder condition = target.addNewElement("condition");
2560
                        XmlBuilder condition = target.addNewElement("condition");
2488
                        condition.addAttribute("property",  p.mAlias + ".build");
2561
                        condition.addAttribute("property",  p.mAlias + ".build");
2489
    
2562
    
2490
                        XmlBuilder and = condition.addNewElement("and");
2563
                        XmlBuilder and = condition.addNewElement("and");
2491
    
2564
    
2492
                        for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
2565
                        for (Iterator<PkgDependency> it = p.mDependencyCollection.iterator(); it.hasNext(); )
2493
                        {
2566
                        {
2494
                            Package dependency = it.next();
2567
                            PkgDependency depEntry = it.next();
2495
    
2568
    
2496
                            if ( dependency.mBuildFile == buildFile )
2569
                            if ( depEntry.pkg.mBuildFile == buildFile )
2497
                            {
2570
                            {
2498
                                XmlBuilder or = and.addNewElement("or");
2571
                                XmlBuilder or = and.addNewElement("or");
2499
    
2572
    
2500
                                XmlBuilder equal1 = or.addNewElement("equals");
2573
                                XmlBuilder equal1 = or.addNewElement("equals");
2501
                                equal1.addAttribute("arg1", "${" + dependency.mAlias + ".res}");
2574
                                equal1.addAttribute("arg1", "${" + depEntry.pkg.mAlias + ".res}");
2502
                                equal1.addAttribute("arg2", "0");
2575
                                equal1.addAttribute("arg2", "0");
2503
    
2576
    
2504
                                XmlBuilder equal2 = or.addNewElement("equals");
2577
                                XmlBuilder equal2 = or.addNewElement("equals");
2505
                                equal2.addAttribute("arg1", "${" + dependency.mAlias + ".res}");
2578
                                equal2.addAttribute("arg1", "${" + depEntry.pkg.mAlias + ".res}");
2506
                                equal2.addAttribute("arg2", "257");
2579
                                equal2.addAttribute("arg2", "257");
2507
                            }
2580
                            }
2508
                        }
2581
                        }
2509
                    }
2582
                    }
2510
                    else
2583
                    else
Line 2563... Line 2636...
2563
 
2636
 
2564
                //    Add our own task and associated information
2637
                //    Add our own task and associated information
2565
                //
2638
                //
2566
                XmlBuilder abt = target.addNewElement("abt").isExpanded();
2639
                XmlBuilder abt = target.addNewElement("abt").isExpanded();
2567
    
2640
    
2568
                for (Iterator<Package> it = p.mPackageDependencyCollection.iterator(); it.hasNext(); )
2641
                for (Iterator<PkgDependency> it = p.mDependencyCollection.iterator(); it.hasNext(); )
2569
                {
2642
                {
2570
                    Package dependency = it.next();
2643
                    PkgDependency depEntry = it.next();
2571
                    XmlBuilder depend = abt.addNewElement("depend");
2644
                    XmlBuilder depend = abt.addNewElement("depend");
2572
                    depend.addAttribute("package_alias", "${" + dependency.mAlias + "}");
2645
                    depend.addAttribute("package_alias", "${" + depEntry.pkg.mAlias + "}");
2573
                }
2646
                }
2574
 
2647
 
2575
                buildInfo(abt,p);
2648
                buildInfo(abt,p);
2576
    
2649
    
2577
                if ( mDaemon && p.mBuildFile == 1 )
2650
                if ( mDaemon && p.mBuildFile == 1 )
Line 2745... Line 2818...
2745
            {
2818
            {
2746
                Package pkg = it.next();
2819
                Package pkg = it.next();
2747
 
2820
 
2748
                if ( pkg != p )
2821
                if ( pkg != p )
2749
                {
2822
                {
2750
                    for (Iterator<Package> it2 = pkg.mPackageDependencyCollection.iterator(); it2.hasNext(); )
2823
                    for (Iterator<PkgDependency> it2 = pkg.mDependencyCollection.iterator(); it2.hasNext(); )
2751
                    {
2824
                    {
2752
                        Package dependency = it2.next();
2825
                        PkgDependency depEntry = it2.next();
2753
 
2826
 
2754
                        if ( dependency == p )
2827
                        if ( depEntry.pkg == p )
2755
                        {
2828
                        {
2756
                            rippleIndirectlyPlanned( pkg );
2829
                            rippleIndirectlyPlanned( pkg );
2757
                            break;
2830
                            break;
2758
                        }
2831
                        }
2759
                    }
2832
                    }