Subversion Repositories DevTools

Rev

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

Rev 7047 Rev 7048
Line 1... Line 1...
1
package com.erggroup.buildtool.ripple;
1
package com.erggroup.buildtool.ripple;
2
 
2
 
3
import java.io.File;
3
import java.io.File;
4
import java.sql.SQLException;
4
import java.sql.SQLException;
5
import java.util.ArrayList;
5
import java.util.ArrayList;
-
 
6
import java.util.Comparator;
6
import java.util.HashMap;
7
import java.util.HashMap;
7
import java.util.Iterator;
8
import java.util.Iterator;
8
import java.util.LinkedHashSet;
9
import java.util.LinkedHashSet;
9
import java.util.Vector;
10
import java.util.Vector;
10
import java.util.Comparator;
-
 
11
 
11
 
12
import org.slf4j.Logger;
12
import org.slf4j.Logger;
13
import org.slf4j.LoggerFactory;
13
import org.slf4j.LoggerFactory;
14
 
14
 
15
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
15
import com.erggroup.buildtool.ripple.ReleaseManager.BuildReason;
Line 39... Line 39...
39
     * instance identifier
39
     * instance identifier
40
     * 
40
     * 
41
     * @attribute
41
     * @attribute
42
     */
42
     */
43
    public String mVersion = new String();
43
    public String mVersion = new String();
-
 
44
    
-
 
45
    /**
-
 
46
     * If this package is a candidate for building, then this value will be calculated
-
 
47
     * and will  be used if the package is selected for building
-
 
48
     */
-
 
49
    public String mNextVersion = null;
44
 
50
 
45
    /**
51
    /**
46
     * Version string as specified by the user. Used with a ripple type of 'F'
52
     * Version string as specified by the user. Used with a ripple type of 'F'
47
     */
53
     */
48
    String mFixedVersion = new String();
54
    String mFixedVersion = new String();
Line 157... Line 163...
157
     */
163
     */
158
    public boolean mIsBuildable = true;
164
    public boolean mIsBuildable = true;
159
 
165
 
160
    /**
166
    /**
161
     * determines the build file the package is built in, or not
167
     * determines the build file the package is built in, or not
162
     * @param   1 Post Plan: build file - Result of planning
168
     * <br>   1 Post Plan: build file - Result of planning
163
     * @param   2 Post Plan: Future build requirement
169
     * <br>   2 Post Plan: Future build requirement
164
     * @param   3 Post Plan: Package has no build requirement
170
     * <br>   3 Post Plan: Package has no build requirement
165
     * @param   0 not yet processed (initial value) 
171
     * <br>   0 not yet processed (initial value) 
166
     * @param  -1 not reproducible
172
     * <br>  -1 not reproducible
167
     * @param  -2 escrow: not reproducible on the build platforms configured for this release
173
     * <br>  -2 escrow: not reproducible on the build platforms configured for this release
168
     * @param  -3 daemon: do not ripple
174
     * <br>  -3 daemon: do not ripple
169
     * @param  -4 directly dependent on package versions not in the baseline
175
     * <br>  -4 directly dependent on package versions not in the baseline
170
     * @param  -5 indirectly dependent on package versions which are not reproducible due to detected fault
176
     * <br>  -5 indirectly dependent on package versions which are not reproducible due to detected fault
171
     * @param  -6 circular dependency
177
     * <br>  -6 circular dependency
172
     * @param  -7 Pegged or SDK Imported package not in dpkg_archive
178
     * <br>  -7 Pegged or SDK Imported package not in dpkg_archive
173
     * @param  -8 Pegged or SDK Imported package
179
     * <br>  -8 Pegged or SDK Imported package
174
     * @param  -9 Rejected Daemon Instruction
180
     * <br>  -9 Rejected Daemon Instruction
175
     * @param  -10 UnBuildable Package not in dpkg_archive
181
     * <br>  -10 UnBuildable Package not in dpkg_archive
176
     * @param  -11 Marked as RippleStop
182
     * <br>  -11 Marked as RippleStop
177
     * 
183
     * 
178
     */
184
     */
179
    int mBuildFile = 0;
185
    int mBuildFile = 0;
180
    
186
    
181
    /** Retained reason the package will not be built
187
    /** Retained reason the package will not be built
Line 221... Line 227...
221
    /**
227
    /**
222
     * non zero instruction number when it is determined to be ripple built by force
228
     * non zero instruction number when it is determined to be ripple built by force
223
     * 
229
     * 
224
     * @attribute
230
     * @attribute
225
     */
231
     */
226
    int mForcedRippleInstruction = 0;
232
    public int mForcedRippleInstruction = 0;
227
 
233
 
228
    /**
234
    /**
229
     * test build - non zero instruction number when it is determined to be test built
235
     * test build - non zero instruction number when it is determined to be test built
230
     * 
236
     * 
231
     * @attribute
237
     * @attribute
232
     */
238
     */
233
    int mTestBuildInstruction = 0;
239
    public int mTestBuildInstruction = 0;
234
 
-
 
235
    /**
-
 
236
     * test build - Package PVID
-
 
237
     * 
-
 
238
     * @attribute
-
 
239
     */
-
 
240
    int mTestBuildPvId = -1;
-
 
241
 
-
 
242
    /**
-
 
243
     * test build email destination
-
 
244
     * Used by all daemon instructions to retain instigator of the instruction 
-
 
245
     * 
-
 
246
     * @attribute
-
 
247
     */
-
 
248
    String mTestBuildEmail;
-
 
249
 
-
 
250
    /**
-
 
251
     * test build - Version Control System Tag
-
 
252
     * 
-
 
253
     * @attribute
-
 
254
     */
-
 
255
    String mTestBuildVcsTag = new String();
-
 
256
 
-
 
257
    /**
-
 
258
     * test build - build standards
-
 
259
     * 
-
 
260
     * @attribute
-
 
261
     */
-
 
262
    Vector<BuildStandard> mTestBuildStandardCollection = new Vector<BuildStandard>();
-
 
263
 
-
 
264
    /**
-
 
265
     * test build - build dependencies by package alias
-
 
266
     * 
-
 
267
     * @attribute
-
 
268
     */
-
 
269
    Vector<String> mTestBuildDependencyCollection = new Vector<String>();
-
 
270
 
-
 
271
    /** 
-
 
272
     * test build - package has build dependencies
-
 
273
     */
-
 
274
	public boolean mTestBuildHasAutomatedUnitTests;
-
 
275
 
240
 
276
    /**
241
    /**
277
     * build dependencies by pv_id (-1 or not used for planned dependencies)
242
     * build dependencies by pv_id (-1 or not used for planned dependencies)
278
     * 
243
     * 
279
     * @attribute
244
     * @attribute
Line 385... Line 350...
385
     * Planned packages (WIPS) need calculate a new version number
350
     * Planned packages (WIPS) need calculate a new version number
386
     * This should be based on the Version of the package that the WIP was based upon
351
     * This should be based on the Version of the package that the WIP was based upon
387
     */
352
     */
388
	public String mPrevVersion;
353
	public String mPrevVersion;
389
	
354
	
390
	/** Used to preserve the basic ordering of the package list(s)
355
    /** Used to preserve the basic ordering of the package list(s)
391
	 *  Only valid for the duration of the comparison sorts
356
     *  Only valid for the duration of the comparison sorts
392
	 */
357
     */
393
	int mSeqId;
358
    int mSeqId;	
394
 
359
	
395
	/** Indicates that the package not be ripple built at this time
360
	/** Indicates that the package not be ripple built at this time
396
	 *  Sequence is:
361
	 *  Sequence is:
397
	 *     User sets to 's'
362
	 *     User sets to 's'
398
	 *     This buildtool will set to 'w' when a ripple has been detected
363
	 *     This buildtool will set to 'w' when a ripple has been detected
399
	 *     User resets to NULL when the ripple can be resumed. This is stored as an 'n'
364
	 *     User resets to NULL when the ripple can be resumed. This is stored as an 'n'
400
	 * 
365
	 * 
401
	 */
366
	 */
-
 
367
	
402
    public char mRippleStop;
368
    public char mRippleStop;
-
 
369
    
-
 
370
    /**
-
 
371
     *  The calculated ripple build plan for this package
-
 
372
     *  Will not be calculated for all packages, just those of interest
-
 
373
     *  All packages that can (not must) be built when this package is built
-
 
374
     *  The list will not include packages that cannot be built at the moment
-
 
375
     *  
-
 
376
     *  Does not include this package
-
 
377
     */
-
 
378
    public ArrayList<Package> mRipplePlan = null;
-
 
379
    
-
 
380
    /** The duration (seconds) of the last build of this package
-
 
381
     *  Used to estimate the cost of building the package
-
 
382
     *  A WIP packages gets the buildTime of the package its based upon
-
 
383
     */
-
 
384
    public int mBuildTime;
-
 
385
 
-
 
386
    /** Calculated time ( seconds) that is may take to build this package and then ripple packages that depend on it
-
 
387
     *  both directly and indirectly. Based on mRipplePlan. 
-
 
388
     */
-
 
389
    public int mRippleTime = 0;
-
 
390
    
-
 
391
    /** Set to indicate that the package is NOT a part of the full release set
-
 
392
     *  The package is a WIP, TestBuild or a ForcedRipple
-
 
393
     *  
-
 
394
     *   Used to simplify detection of such packages and to limit processing of these packages
-
 
395
     *   May be cleared if the package is added to the full set
-
 
396
     */
-
 
397
    public boolean mIsNotReleased = false;
403
 
398
 
404
    /**
399
    /**
405
     * Constructor
400
     * Constructor
406
     * Used to create planned packages. In these packages the change_type is significant
401
     * Used to create planned packages. In these packages the change_type is significant
407
     * 
402
     * 
Line 510... Line 505...
510
        mAlias = "null";
505
        mAlias = "null";
511
        mVcsTag = "null";
506
        mVcsTag = "null";
512
    }
507
    }
513
 
508
 
514
    /**
509
    /**
515
     * Constructor for test build purposes
-
 
516
     * Used when a test build package does not exist in the current package set
-
 
517
     * 
-
 
518
     */
-
 
519
    Package(int pkg_id, int pv_id, String pkg_name, String v_ext, String alias, String pkg_vcs_tag, int testBuildInstruction, String email)
-
 
520
    {
-
 
521
        mLogger.debug("Package 4: pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_vcs_tag "
-
 
522
                + pkg_vcs_tag);
-
 
523
        // don't need pv_id
-
 
524
        mId = -1;
-
 
525
        mName = pkg_name;
-
 
526
        mPid = pkg_id;
-
 
527
        // avoid interaction with real versions
-
 
528
        mVersion = "0.0.0000";
-
 
529
        mExtension = v_ext;
-
 
530
        mAlias = alias;
-
 
531
        mTestBuildInstruction = testBuildInstruction;
-
 
532
        mTestBuildEmail = email;
-
 
533
        mTestBuildVcsTag = pkg_vcs_tag;
-
 
534
        mTestBuildPvId = pv_id;
-
 
535
        mTestBuildHasAutomatedUnitTests = false;
-
 
536
 
-
 
537
    }
-
 
538
 
-
 
539
    /**
-
 
540
     * constructor for unit test purposes
510
     * constructor for unit test purposes
541
     */
511
     */
542
    public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
512
    public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
543
    {
513
    {
544
        mId = -1;
514
        mId = -1;
Line 581... Line 551...
581
    public String getVersion()
551
    public String getVersion()
582
    {
552
    {
583
        return mVersion;
553
        return mVersion;
584
    }
554
    }
585
    
555
    
586
    
-
 
587
    /** Set the sequence of all packages in the list
-
 
588
     *  Used so that the UnitTestComparator function can preserve the
-
 
589
     *  basic ordering of the list 
-
 
590
     */
-
 
591
    public static void setSequence(ArrayList<Package> al)
-
 
592
    {
-
 
593
        int seq = 1;
-
 
594
        for (Iterator<Package> it = al.iterator(); it.hasNext(); )
-
 
595
        {
-
 
596
            Package p = it.next();
-
 
597
            p.mSeqId = seq++;
-
 
598
        }
-
 
599
    }
-
 
600
    
-
 
601
    /** Comparator for sorting unit tests
-
 
602
     *      Used to sort a list of packages such that the package with the lowest mTestBuildInstruction
-
 
603
     *      is at the head of the list.
-
 
604
     *      
-
 
605
     *      Packages without a unit test are sorted by mSeqId to preserve the basic 
-
 
606
     *      ordering of the list. 
-
 
607
     */
-
 
608
    public static final Comparator<Package> UnitTestComparator = new Comparator<Package>() {
-
 
609
        
-
 
610
        /**
-
 
611
         * Returns -ve: p1 is less than p2
-
 
612
         *           0: p1 = p2
-
 
613
         *         +ve: p1 > p2
-
 
614
         */
-
 
615
        public int compare (Package p1, Package p2) {
-
 
616
            // Both are test builds
-
 
617
            if (p1.mTestBuildInstruction > 0 && p2.mTestBuildInstruction > 0)
-
 
618
                return p1.mTestBuildInstruction - p2.mTestBuildInstruction;
-
 
619
            
-
 
620
            // Neither is a test build
-
 
621
            if (p1.mTestBuildInstruction == 0 && p2.mTestBuildInstruction == 0)
-
 
622
                return p1.mSeqId - p2.mSeqId;
-
 
623
            
-
 
624
            // Only one is a test build
-
 
625
            if (p1.mTestBuildInstruction > 0)
-
 
626
                return -1;
-
 
627
            
-
 
628
            return 1;
-
 
629
        }
-
 
630
    };
-
 
631
 
556
 
632
    /**
557
    /**
633
     * returns true if mBuildStandardCollection is not empty
558
     * returns true if mBuildStandardCollection is not empty
634
     */
559
     */
635
    boolean isReproducible()
560
    boolean isReproducible()
636
    {
561
    {
637
        mLogger.debug("isReproducible on Package " + mName);
562
        mLogger.debug("isReproducible on Package {}", mName);
638
        boolean retVal = ! mBuildStandardCollection.isEmpty();
563
        boolean retVal = ! mBuildStandardCollection.isEmpty();
639
        mLogger.info("isReproducible returned " + retVal);
564
        mLogger.info("isReproducible returned {}", retVal);
640
        return retVal;
565
        return retVal;
641
    }
566
    }
642
 
567
 
643
 
568
 
644
    /**
569
    /**
645
     * returns true if at least one of its BuildStandards has mGeneric true
570
     * returns true if at least one of its BuildStandards has mGeneric true
646
     */
571
     */
647
    boolean isGeneric()
572
    boolean isGeneric()
648
    {
573
    {
649
        mLogger.debug("isGeneric on Package " + mName);
574
        mLogger.debug("isGeneric on Package {}", mName);
650
        boolean retVal = false;
575
        boolean retVal = false;
651
        for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
576
        for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext();)
652
        {
577
        {
653
            BuildStandard buildStandard = it.next();
578
            BuildStandard buildStandard = it.next();
654
 
579
 
Line 657... Line 582...
657
                retVal = true;
582
                retVal = true;
658
                break;
583
                break;
659
            }
584
            }
660
        }
585
        }
661
 
586
 
662
        mLogger.info("isGeneric returned " + retVal);
587
        mLogger.info("isGeneric returned {}", retVal);
663
        return retVal;
588
        return retVal;
664
    }
589
    }
665
    
590
    
666
    /**
591
    /**
667
     * Returns true if at least one of the packages build standards can be 
592
     * Returns true if at least one of the packages build standards can be 
Line 815... Line 740...
815
        return false;
740
        return false;
816
      
741
      
817
    }
742
    }
818
 
743
 
819
    /**
744
    /**
820
     * Applies the required version number change
745
     * Applies the required version number change. Will calculate mNextVersion
821
     * 
746
     * 
822
     * @param releaseManager    Release Manager instance to work against
747
     * @param releaseManager    Release Manager instance to work against
823
     * @param rtag_id           Release Identifier
748
     * @param rtag_id           Release Identifier
824
     * 
749
     * 
825
     * @return 0 on success
750
     * @return 0 : success
826
     *         1 on cannot work with non standard versioning
751
     *         1 : cannot work with non standard versioning
827
     *         2 on ripple field limitations prevent a ripple build
752
     *         2 : ripple field limitations prevent a ripple build
828
     *         3 on Invalid Change Type
753
     *         3 : Invalid Change Type
829
     * @exception Exception
754
     * @exception Exception
830
     */
755
     */
831
    int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
756
    int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
832
    {
757
    {
833
        String logInfo = "applyPV," + mName;
758
        String logInfo = "applyPV," + mName;
834
        mLogger.debug("applyPV on Package " + mName);
759
        mLogger.debug("applyPV on Package " + mName);
-
 
760
        
-
 
761
        //
-
 
762
        //  This method used to actually perform the version change
-
 
763
        //  Now it just calculates the potential value
-
 
764
        //  Must not alter mVersion as it will be used if the package is not selected to be built,
-
 
765
        //  but some of the code assumes that it can be.
-
 
766
        //
-
 
767
        String originalVersion = mVersion;
-
 
768
        
835
        //
769
        //
836
        // Four scenarios, only applyPV for 3 of them
770
        // Four scenarios, only applyPV for 3 of them
837
        // mDirectlyPlanned mIndirectlyPlanned mArchivalExistence mForcedRipple
771
        // mDirectlyPlanned mIndirectlyPlanned mArchivalExistence mForcedRipple
838
        // Action
772
        // Action
839
        // WIP/test build exists: true true don't care don't care applyPV
773
        // WIP/test build exists: true true don't care don't care applyPV
Line 844... Line 778...
844
        if (!mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && mForcedRippleInstruction == 0)
778
        if (!mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence && mForcedRippleInstruction == 0)
845
        {
779
        {
846
            // the package has an mIndirectlyPlanned flag set true in daemon
780
            // the package has an mIndirectlyPlanned flag set true in daemon
847
            // mode because the package does not exist in an archive
781
            // mode because the package does not exist in an archive
848
            // do not apply a different package version
782
            // do not apply a different package version
849
            mLogger.info("applyPV. Rebuild Package " + mName);
783
            mLogger.info("applyPV. Rebuild Package {}", mName);
850
            releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
851
            mLogger.info("applyPv returned 0");
784
            mLogger.info("applyPv returned 0");
852
            return 0;
785
            return 0;
853
        }
786
        }
854
 
787
 
855
        // override - no longer doing a rebuild - version number change from this point on
788
        // override - no longer doing a rebuild - version number change from this point on
Line 870... Line 803...
870
        // Detect invalid change type
803
        // Detect invalid change type
871
        // Flagged when package instance is created
804
        // Flagged when package instance is created
872
        //
805
        //
873
        if (mChangeType.mUnknown)
806
        if (mChangeType.mUnknown)
874
        {
807
        {
875
            mLogger.info("Package Version specified on Package " + mName + "New Version:" + mVersion);
808
            mLogger.info("Package Version specified on Package {} New Version: {}", mName, mVersion);
876
            mLogger.info("applyPv returned 3");
809
            mLogger.info("applyPv returned 3");
877
            return 3;
810
            return 3;
878
        }
811
        }
879
 
812
 
880
        // If we are not calculating the new package version because the user
813
        // If we are not calculating the new package version because the user
881
        // has fixed the version of the package. We are given the new package version.
814
        // has fixed the version of the package. We are given the new package version.
882
        if (mChangeType.mFixed)
815
        if (mChangeType.mFixed)
883
        {
816
        {
884
            // mVersion is already setup
817
            // mVersion is already setup
885
 
818
 
886
            mVersion = mFixedVersion;
819
            mNextVersion = mFixedVersion;
887
            mLogger.info("Package Version specified on Package " + mName + "New Version:" + mVersion);
820
            mLogger.info("Package Version specified on Package {} New Version: {}", mName,  mVersion);
888
            releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
889
            mLogger.info("applyPv returned 0");
821
            mLogger.info("applyPv returned 0");
890
            return 0;
822
            return 0;
891
        }
823
        }
892
 
824
 
893
        // We need to calculate the new version number
825
        // We need to calculate the new version number
Line 919... Line 851...
919
            // Can ripple a .cots package under very controlled conditions
851
            // Can ripple a .cots package under very controlled conditions
920
            // Its ends with a .patchBuild field
852
            // Its ends with a .patchBuild field
921
            // Package is marked as ripple via build number
853
            // Package is marked as ripple via build number
922
            // Change type of Major and Minor are not allowed
854
            // Change type of Major and Minor are not allowed
923
            //
855
            //
924
            if (!mChangeType.mMajor && !mChangeType.mMinor && mRippleField.mBuild && mExtension.compareTo(".cots") == 0
856
            if (!mChangeType.mMajor && !mChangeType.mMinor && mRippleField.mBuild && mExtension.compareTo(".cots") == 0 && field.length > 0)
925
                    && field.length > 0)
-
 
926
            {
857
            {
927
                // DEVI 52782
-
 
928
                // allow and work with (ripple build) versions a.b.c.d....xxxx
858
                // allow and work with (ripple build) versions a.b.c.d....xxxx
929
                // where xxxx.length > 3
859
                // where xxxx.length > 3
930
                String patchStr = field[field.length - 1];
860
                String patchStr = field[field.length - 1];
931
                int patchLen = patchStr.length();
861
                int patchLen = patchStr.length();
932
 
862
 
Line 948... Line 878...
948
            }
878
            }
949
        }
879
        }
950
 
880
 
951
        if (nonStandardCotsVersion.length() == 0 && patch.value < 1000 && field[2].substring(0, 1).compareTo("0") != 0)
881
        if (nonStandardCotsVersion.length() == 0 && patch.value < 1000 && field[2].substring(0, 1).compareTo("0") != 0)
952
        {
882
        {
953
            mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
883
            mLogger.info("applyPV accomodate old style Version of the form 1.0.1");
954
            patch.value = patch.value * 1000;
884
            patch.value = patch.value * 1000;
955
        }
885
        }
956
 
886
 
957
        // mChangeType overrides mRippleField
887
        // mChangeType overrides mRippleField
958
        do
888
        do
Line 961... Line 891...
961
            {
891
            {
962
                logInfo += ",CT Major";
892
                logInfo += ",CT Major";
963
                if (!incrementFieldsAccordingToLimits(4, major, minor, patch))
893
                if (!incrementFieldsAccordingToLimits(4, major, minor, patch))
964
                {
894
                {
965
                    mLogger.info("applyPv returned 2");
895
                    mLogger.info("applyPv returned 2");
-
 
896
                    mVersion = originalVersion;
966
                    return 2;
897
                    return 2;
967
                }
898
                }
968
            } else if (mChangeType.mMinor)
899
            } else if (mChangeType.mMinor)
969
            {
900
            {
970
                logInfo += ",CT Minor";
901
                logInfo += ",CT Minor";
971
                if (!incrementFieldsAccordingToLimits(3, major, minor, patch))
902
                if (!incrementFieldsAccordingToLimits(3, major, minor, patch))
972
                {
903
                {
973
                    mLogger.info("applyPv returned 2");
904
                    mLogger.info("applyPv returned 2");
-
 
905
                    mVersion = originalVersion;
974
                    return 2;
906
                    return 2;
975
                }
907
                }
976
            } else if (mChangeType.mPatch)
908
            } else if (mChangeType.mPatch)
977
            {
909
            {
978
                logInfo += ",CT Patch";
910
                logInfo += ",CT Patch";
979
                if (!incrementFieldsAccordingToLimits(2, major, minor, patch))
911
                if (!incrementFieldsAccordingToLimits(2, major, minor, patch))
980
                {
912
                {
981
                    mLogger.info("applyPv returned 2");
913
                    mLogger.info("applyPv returned 2");
-
 
914
                    mVersion = originalVersion;
982
                    return 2;
915
                    return 2;
983
                }
916
                }
984
            } else
917
            } else
985
            {
918
            {
986
                if (mRippleField.mMajor)
919
                if (mRippleField.mMajor)
987
                {
920
                {
988
                    logInfo += ",R Major";
921
                    logInfo += ",R Major";
989
                    major.value++;
922
                    major.value++;
990
                    mLogger.info("applyPV mRippleField.mMajor " + major.value);
923
                    mLogger.info("applyPV mRippleField.mMajor {}", major.value);
991
                    minor.value = 0;
924
                    minor.value = 0;
992
                    patch.value = 0;
925
                    patch.value = 0;
993
                } else if (mRippleField.mMinor)
926
                } else if (mRippleField.mMinor)
994
                {
927
                {
995
                    logInfo += ",R Minor";
928
                    logInfo += ",R Minor";
996
                    minor.value++;
929
                    minor.value++;
997
                    mLogger.info("applyPV mRippleField.mMinor " + minor.value);
930
                    mLogger.info("applyPV mRippleField.mMinor {}", minor.value);
998
                    patch.value = 0;
931
                    patch.value = 0;
999
                } else if (mRippleField.mPatch)
932
                } else if (mRippleField.mPatch)
1000
                {
933
                {
1001
                    logInfo += ",R Patch";
934
                    logInfo += ",R Patch";
1002
                    patch.value = ((patch.value / 1000) + 1) * 1000; 
935
                    patch.value = ((patch.value / 1000) + 1) * 1000; 
1003
                    mLogger.info("applyPV mRippleField.mPatch " + patch.value);
936
                    mLogger.info("applyPV mRippleField.mPatch {}", patch.value);
1004
                } else if (mRippleField.mBuild)
937
                } else if (mRippleField.mBuild)
1005
                {
938
                {
1006
                    logInfo += ", R Build";
939
                    logInfo += ", R Build";
1007
                    patch.value++;
940
                    patch.value++;
1008
                    mLogger.info("applyPV mRippleField.mBuild " + patch.value);
941
                    mLogger.info("applyPV mRippleField.mBuild {}", patch.value);
1009
                } else
942
                } else
1010
                {
943
                {
1011
                    if (!incrementFieldsAccordingToLimits(1, major, minor, patch))
944
                    if (!incrementFieldsAccordingToLimits(1, major, minor, patch))
1012
                    {
945
                    {
1013
                        mLogger.info("applyPv returned 2");
946
                        mLogger.info("applyPv returned 2");
-
 
947
                        mVersion = originalVersion;
1014
                        return 2;
948
                        return 2;
1015
                    }
949
                    }
1016
                }
950
                }
1017
            }
951
            }
1018
 
952
 
Line 1036... Line 970...
1036
            }
970
            }
1037
 
971
 
1038
            mVersion += String.valueOf(patch.value);
972
            mVersion += String.valueOf(patch.value);
1039
        } while (exists(releaseManager, rtag_id));
973
        } while (exists(releaseManager, rtag_id));
1040
 
974
 
1041
        logInfo += ", Claim:" + mVersion;
975
        logInfo += ", Next Version:" + mVersion;
1042
        releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
1043
        mLogger.error(logInfo);
976
        mLogger.error(logInfo);
1044
        mLogger.info("applyPv returned 0");
977
        mLogger.info("applyPv returned 0");
-
 
978
        mNextVersion = mVersion;
-
 
979
        mVersion = originalVersion;
1045
        return 0;
980
        return 0;
1046
    }
981
    }
1047
 
982
 
1048
    /**
983
    /**
1049
     * increments fields according to mRippleField.mLimit if necessary will
984
     * increments fields according to mRippleField.mLimit if necessary will
Line 1182... Line 1117...
1182
 
1117
 
1183
        return retVal;
1118
        return retVal;
1184
    }
1119
    }
1185
 
1120
 
1186
    /**
1121
    /**
1187
     * Check if a Package Version exists in dpkg_archive or the Release Manager Database
1122
     * Check if a specified Version of the package exists in dpkg_archive or the Release Manager Database
1188
     * 
1123
     * 
1189
     * @param releaseManager Release Manager Instance
1124
     * @param releaseManager Release Manager Instance
1190
     * @param rtag_id        Release Tag Identifier
1125
     * @param rtag_id        Release Tag Identifier
1191
     * 
1126
     * 
1192
     * @return True if the Package Version exists within the Release Manager Database
1127
     * @return True if the Package Version exists within the Release Manager Database
Line 1195... Line 1130...
1195
    private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
1130
    private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
1196
    {
1131
    {
1197
        mLogger.debug("exists on Package " + mName + " version " + mVersion + " extension " + mExtension);
1132
        mLogger.debug("exists on Package " + mName + " version " + mVersion + " extension " + mExtension);
1198
        boolean retVal = false;
1133
        boolean retVal = false;
1199
 
1134
 
1200
        if (!ReleaseManager.mUseDatabase)
1135
        if (!releaseManager.mUseDatabase)
1201
        {
1136
        {
1202
            mLogger.info("exists !releaseManager.mUseDatabase");
1137
            mLogger.info("exists !releaseManager.mUseDatabase");
1203
        }
1138
        }
1204
        else
1139
        else
1205
        {
1140
        {
Line 1383... Line 1318...
1383
    }
1318
    }
1384
 
1319
 
1385
    /**
1320
    /**
1386
     * Adds email to mBuildFailureEmailCollection.
1321
     * Adds email to mBuildFailureEmailCollection.
1387
     * Do not worry about multiple entries. These will be handled when the data is extracted
1322
     * Do not worry about multiple entries. These will be handled when the data is extracted
1388
     * @param   email   - Email address
1323
     * @param   email   - Email address. Null is allowed and will not be added
1389
     */
1324
     */
1390
    public void addEmail(String email)
1325
    public void addEmail(String email)
1391
    {
1326
    {
1392
        mBuildFailureEmailCollection.add(email);
-
 
1393
    }
-
 
1394
 
-
 
1395
    /**
-
 
1396
     * Transfer the Test Build Email information to the packages email list
-
 
1397
     */
-
 
1398
    void setTestEmail()
-
 
1399
    {
-
 
1400
        mBuildFailureEmailCollection.clear();
-
 
1401
        addEmail(mTestBuildEmail);
1327
        if (email != null) 
1402
    }
-
 
1403
 
-
 
1404
    /**
-
 
1405
     * Transfer the Test Build Dependency information to the packages dependency collection
-
 
1406
     */
-
 
1407
    void setTestDependencyCollection()
-
 
1408
    {
-
 
1409
        // does not worry about mPackageDendencyCollection by design
-
 
1410
        mDependencyCollection.clear();
-
 
1411
 
-
 
1412
        for (Iterator<String> it = mTestBuildDependencyCollection.iterator(); it.hasNext();)
-
 
1413
        {
1328
        {
1414
            String dependency = it.next();
-
 
1415
            mDependencyCollection.add(dependency);
-
 
1416
        }
-
 
1417
    }
-
 
1418
 
-
 
1419
    /**
-
 
1420
     * Transfer the Test Build Build Standard information to the packages build standard collection
-
 
1421
     */
-
 
1422
    void setTestBuildStandardCollection()
-
 
1423
    {
-
 
1424
        mBuildStandardCollection.clear();
-
 
1425
 
-
 
1426
        for (Iterator<BuildStandard> it = mTestBuildStandardCollection.iterator(); it.hasNext();)
-
 
1427
        {
-
 
1428
            BuildStandard buildStandard = it.next();
-
 
1429
            mBuildStandardCollection.add(buildStandard);
1329
            mBuildFailureEmailCollection.add(email);
1430
        }
1330
        }
1431
    }
1331
    }
1432
 
1332
 
1433
    /**
1333
    /**
1434
     * End of Processing for a Test Build
1334
     * End of Processing for a Test Build
Line 1525... Line 1425...
1525
     * If the package depends on a package with a circular dependency then the function
1425
     * If the package depends on a package with a circular dependency then the function
1526
     * will return false.
1426
     * will return false.
1527
     */
1427
     */
1528
    public boolean hasCircularDependency(RippleEngine ripEng)
1428
    public boolean hasCircularDependency(RippleEngine ripEng)
1529
    {
1429
    {
1530
        mLogger.debug("hasCircularDependency: " + mAlias);
1430
        mLogger.debug("hasCircularDependency: {}", mAlias);
1531
        boolean retVal = detectCircularDependency(mAlias, ripEng, null);
1431
        boolean retVal = detectCircularDependency(mAlias, ripEng, null);
1532
        mLogger.info("hasCircularDependency returned " + retVal);
1432
        mLogger.info("hasCircularDependency returned {} ", retVal);
1533
        return retVal;
1433
        return retVal;
1534
    }
1434
    }
1535
 
1435
 
1536
    /**
1436
    /**
1537
     * Returns true is a part of a circular dependency
1437
     * Returns true is a part of a circular dependency
Line 1595... Line 1495...
1595
            mCheckedCircularDependency = true;
1495
            mCheckedCircularDependency = true;
1596
        } 
1496
        } 
1597
 
1497
 
1598
        // return the persisted circular dependency outcome
1498
        // return the persisted circular dependency outcome
1599
        retVal = mHasCircularDependency;
1499
        retVal = mHasCircularDependency;
1600
        mLogger.info("detectCircularDependency 2 returned " + retVal);
1500
        mLogger.info("detectCircularDependency 2 returned {}", retVal);
1601
        return retVal;
1501
        return retVal;
1602
    }
1502
    }
-
 
1503
    
-
 
1504
    /** Set the sequence of all packages in the list
-
 
1505
     *  Used so that the Unit Tests function can preserve the basic ordering of the list 
-
 
1506
     */
-
 
1507
    public static void setSequence(ArrayList<Package> al)
-
 
1508
    {
-
 
1509
        int seq = 1;
-
 
1510
        for (Iterator<Package> it = al.iterator(); it.hasNext(); )
-
 
1511
        {
-
 
1512
            Package p = it.next();
-
 
1513
            p.mSeqId = seq++;
-
 
1514
        }
-
 
1515
    }
-
 
1516
 
-
 
1517
    
-
 
1518
    /** Comparator for sorting package collections by mSeqId
-
 
1519
     *  Used to preserve order for unit testing
-
 
1520
     */
-
 
1521
    public static final Comparator<Package> SeqComparator = new Comparator<Package>() {
-
 
1522
        
-
 
1523
        /**
-
 
1524
         * Returns -ve: p1 is less than p2
-
 
1525
         *           0: p1 = p2
-
 
1526
         *         +ve: p1 > p2
-
 
1527
         */
-
 
1528
        public int compare (Package p1, Package p2) {
-
 
1529
                return p1.mSeqId - p2.mSeqId;
-
 
1530
        }
-
 
1531
    };    
1603
 
1532
 
1604
    /**
1533
    /**
1605
     * entity class supporting the ERG version numbering standard:
1534
     * entity class supporting the ERG version numbering standard:
1606
     * <major>.<minor>.<patch/build> patch/build is at least a 4 digit number
1535
     * <major>.<minor>.<patch/build> patch/build is at least a 4 digit number
1607
     * whose last 3 digits represent the build
1536
     * whose last 3 digits represent the build