Subversion Repositories DevTools

Rev

Rev 868 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 868 Rev 874
Line 132... Line 132...
132
   * used for querying package version existence in the database in daemon mode
132
   * used for querying package version existence in the database in daemon mode
133
   * @attribute
133
   * @attribute
134
   */
134
   */
135
  int mPid;
135
  int mPid;
136
 
136
 
-
 
137
  /**maximum major number supported for determining ripple number
-
 
138
   * @attribute
-
 
139
   */
-
 
140
  int mMajorLimit;
-
 
141
 
-
 
142
  /**maximum minor number supported for determining ripple number
-
 
143
   * @attribute
-
 
144
   */
-
 
145
  int mMinorLimit;
-
 
146
 
-
 
147
  /**maximum patch number supported for determining ripple number
-
 
148
   * @attribute
-
 
149
   */
-
 
150
  int mPatchLimit;
-
 
151
 
-
 
152
  /**maximum build number number supported for determining ripple number
-
 
153
   * @attribute
-
 
154
   */
-
 
155
  int mBuildLimit;
-
 
156
 
137
  /**Logger
157
  /**Logger
138
   * @attribute
158
   * @attribute
139
   */
159
   */
140
  private static final Logger mLogger = Logger.getLogger(Package.class);
160
  private static final Logger mLogger = Logger.getLogger(Package.class);
141
 
161
 
Line 207... Line 227...
207
    mExtension = v_ext;
227
    mExtension = v_ext;
208
    mAlias = alias;
228
    mAlias = alias;
209
    mLabel = pkg_label;
229
    mLabel = pkg_label;
210
    mLocation = src_path;
230
    mLocation = src_path;
211
    
231
    
-
 
232
    // setBuild is the default
212
    if (ripple_field == 'M')
233
    if (ripple_field == 'M')
213
    {
234
    {
214
      mRippleField.setMajor();
235
      mRippleField.setMajor();
215
    }
236
    }
216
    else if (ripple_field == 'm')
237
    else if (ripple_field == 'm')
Line 219... Line 240...
219
    }
240
    }
220
    else if (ripple_field == 'p')
241
    else if (ripple_field == 'p')
221
    {
242
    {
222
      mRippleField.setPatch();
243
      mRippleField.setPatch();
223
    }
244
    }
-
 
245
    else if (ripple_field == 'L')
-
 
246
    {
-
 
247
      mRippleField.setLimit();
-
 
248
    }
224
  }
249
  }
225
 
250
 
226
  /**constructor
251
  /**constructor
227
   */
252
   */
228
  Package()
253
  Package()
Line 234... Line 259...
234
    mAlias = "null";
259
    mAlias = "null";
235
    mLabel = "null";
260
    mLabel = "null";
236
    mLocation = "null";
261
    mLocation = "null";
237
  }
262
  }
238
 
263
 
-
 
264
  /**constructor for unit test purposes
-
 
265
  */
-
 
266
  public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
-
 
267
  {
-
 
268
    mId = -1;
-
 
269
    mRippleField.setLimit();
-
 
270
    mVersion = version;
-
 
271
    mMajorLimit = majorLimit;
-
 
272
    mMinorLimit = minorLimit;
-
 
273
    mPatchLimit = patchLimit;
-
 
274
    mBuildLimit = buildNumberLimit;
-
 
275
    try
-
 
276
    {
-
 
277
      mId = applyPV( rm, 0 );
-
 
278
    }
-
 
279
    catch(Exception e)
-
 
280
    {
-
 
281
    }
-
 
282
  }
-
 
283
 
-
 
284
  /**accessor for unit test purposes
-
 
285
   */
-
 
286
  public int getId()
-
 
287
  {
-
 
288
    return mId;
-
 
289
  }
-
 
290
  
-
 
291
  /**accessor for unit test purposes
-
 
292
   */
-
 
293
  public String getVersion()
-
 
294
  {
-
 
295
    return mVersion;
-
 
296
  }
-
 
297
  
239
  /**returns true if mBuildStandardCollection is not empty
298
  /**returns true if mBuildStandardCollection is not empty
240
   */
299
   */
241
  boolean isReproducible()
300
  boolean isReproducible()
242
  {
301
  {
243
    mLogger.debug("isReproducible on Package " + mName);
302
    mLogger.debug("isReproducible on Package " + mName);
Line 335... Line 394...
335
    mLogger.info("isGeneric returned " + retVal);
394
    mLogger.info("isGeneric returned " + retVal);
336
    return retVal;
395
    return retVal;
337
  }
396
  }
338
 
397
 
339
  /**applies the required version number change
398
  /**applies the required version number change
-
 
399
   * returns 0 on success
-
 
400
   *         1 on cannot work with non standard versioning
-
 
401
   *         2 on ripple field limitations prevent a ripple build
340
   */
402
   */
341
  void applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
403
  int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
342
  {
404
  {
343
    mLogger.debug("applyPV on Package " + mName);
405
    mLogger.debug("applyPV on Package " + mName);
344
    // three scenarios, only applyPV for 2 of them
406
    // three scenarios, only applyPV for 2 of them
345
    // WIP exists:                      mDirectlyPlanned == true;   mIndirectlyPlanned == true; mArchivalExistence don't care - applyPV
407
    // WIP exists:                      mDirectlyPlanned == true;   mIndirectlyPlanned == true; mArchivalExistence don't care - applyPV
346
    // Package version is out of date:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == true    - applyPV
408
    // Package version is out of date:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == true    - applyPV
Line 349... Line 411...
349
    {
411
    {
350
      // the package has an mIndirectlyPlanned flag set true in daemon mode because the package does not exist in an archive
412
      // the package has an mIndirectlyPlanned flag set true in daemon mode because the package does not exist in an archive
351
      // do not apply a different package version
413
      // do not apply a different package version
352
      mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence on Package " + mName);
414
      mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence on Package " + mName);
353
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
415
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
416
      mLogger.info("applyPv returned 0");
354
      return;
417
      return 0;
355
    }
418
    }
356
    
419
    
357
    int major = 0;
420
    int major = 0;
358
    int minor = 0;
421
    int minor = 0;
359
    int patch = 1000;
422
    int patch = 1000;
Line 368... Line 431...
368
    }
431
    }
369
    else
432
    else
370
    {
433
    {
371
      // cannot work with non standard versioning
434
      // cannot work with non standard versioning
372
      mLogger.error("applyPV cannot work with non standard versioning");
435
      mLogger.error("applyPV cannot work with non standard versioning");
-
 
436
      mLogger.info("applyPv returned 1");
373
      return;
437
      return 1;
374
    }
438
    }
375
 
439
 
376
    if ( patch < 1000 && field[2].substring(0, 1).compareTo("0") != 0 )
440
    if ( patch < 1000 && field[2].substring(0, 1).compareTo("0") != 0 )
377
    {
441
    {
378
      mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
442
      mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
Line 424... Line 488...
424
          {
488
          {
425
            patch++;
489
            patch++;
426
          } while ( ( patch / 1000 ) * 1000 != patch );
490
          } while ( ( patch / 1000 ) * 1000 != patch );
427
          mLogger.info("applyPV mRippleField.mPatch " + patch);
491
          mLogger.info("applyPV mRippleField.mPatch " + patch);
428
        }
492
        }
429
        else
493
        else if ( mRippleField.mBuild )
430
        {
494
        {
431
          patch++;
495
          patch++;
432
          mLogger.info("applyPV ripple field default " + patch);
496
          mLogger.info("applyPV mRippleField.mBuild " + patch);
-
 
497
        }
-
 
498
        else
-
 
499
        {
-
 
500
          // increment fields according to limits
-
 
501
          boolean changeOccurred = false;
-
 
502
          boolean incrementField = true;
-
 
503
          
-
 
504
          if ( mBuildLimit != 0 )
-
 
505
          {
-
 
506
            // increment or reset the patch build number
-
 
507
            if ( patch < mBuildLimit )
-
 
508
            {
-
 
509
              // can increment the patch build number
-
 
510
              patch++;
-
 
511
              mLogger.info("applyPv mRippleField.mLimit build number " + patch);
-
 
512
              changeOccurred = true;
-
 
513
              incrementField = false;
-
 
514
            }
-
 
515
            else
-
 
516
            {
-
 
517
              if ( mPatchLimit == 0 )
-
 
518
              {
-
 
519
                // reset the patch number and patch build number
-
 
520
                patch = 0;
-
 
521
              }
-
 
522
            }
-
 
523
          }
-
 
524
          
-
 
525
          if ( mPatchLimit != 0 && incrementField )
-
 
526
          {
-
 
527
            // increment or reset the patch number
-
 
528
            if ( ( patch / 1000 ) < mPatchLimit )
-
 
529
            {
-
 
530
              do
-
 
531
              {
-
 
532
                patch++;
-
 
533
              } while ( ( patch / 1000 ) * 1000 != patch );
-
 
534
              
-
 
535
              mLogger.info("applyPv mRippleField.mLimit patch " + patch);
-
 
536
              changeOccurred = true;
-
 
537
              incrementField = false;
-
 
538
            }
-
 
539
            else
-
 
540
            {
-
 
541
              // reset the patch number and patch build number
-
 
542
              patch = 0;
-
 
543
            }
-
 
544
          }
-
 
545
          
-
 
546
          if ( mMinorLimit != 0 && incrementField )
-
 
547
          {
-
 
548
            // increment or reset the minor number
-
 
549
            if ( minor < mMinorLimit )
-
 
550
            {
-
 
551
              minor++;
-
 
552
              mLogger.info("applyPv mRippleField.mLimit minor " + minor);
-
 
553
              changeOccurred = true;
-
 
554
              incrementField = false;
-
 
555
            }
-
 
556
            else
-
 
557
            {
-
 
558
              // reset the minor number
-
 
559
              minor = 0;
-
 
560
            }
-
 
561
          }
-
 
562
          
-
 
563
          if ( mMajorLimit != 0 && incrementField )
-
 
564
          {
-
 
565
            // increment or reset the major number
-
 
566
            if ( major < mMajorLimit )
-
 
567
            {
-
 
568
              // increment the major number
-
 
569
              changeOccurred = true;
-
 
570
              major++;
-
 
571
              mLogger.info("applyPv mRippleField.mLimit major " + major);
-
 
572
            }
-
 
573
          }
-
 
574
          
-
 
575
          if ( !changeOccurred )
-
 
576
          {
-
 
577
            // unable to increment a field due to field limitations
-
 
578
            mLogger.error("applyPV ripple field limitations prevent a ripple build");
-
 
579
            mLogger.info("applyPv returned 2");
-
 
580
            return 2;
-
 
581
          }
433
        }
582
        }
434
      }
583
      }
435
      
584
      
436
      mVersion = String.valueOf(major) + "." + String.valueOf(minor) + ".";
585
      mVersion = String.valueOf(major) + "." + String.valueOf(minor) + ".";
437
      
586
      
Line 450... Line 599...
450
      
599
      
451
      mVersion += String.valueOf(patch);
600
      mVersion += String.valueOf(patch);
452
    } while ( exists(releaseManager, rtag_id) );
601
    } while ( exists(releaseManager, rtag_id) );
453
    
602
    
454
    releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
603
    releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
-
 
604
    mLogger.info("applyPv returned 0");
-
 
605
    return 0;
455
  }
606
  }
456
 
607
 
457
  /**returns true if the version exists in the dpkg_archive, deploy_archive or release manager database
608
  /**returns true if the version exists in the dpkg_archive, deploy_archive or release manager database
458
   * claims the version in the release manager database
609
   * claims the version in the release manager database
459
   */
610
   */
Line 632... Line 783...
632
     * when true indicates the build number will be incremented
783
     * when true indicates the build number will be incremented
633
     * @attribute
784
     * @attribute
634
     */
785
     */
635
    private boolean mBuild = true;
786
    private boolean mBuild = true;
636
 
787
 
-
 
788
    /**in terms of the mChangeType Package field,
-
 
789
     * always false, does not apply
-
 
790
     * in terms of the mRippleField Package field,
-
 
791
     * when true indicates the major, minor, patch and build number will be incremented according to field limits
-
 
792
     * @attribute
-
 
793
     */
-
 
794
    private boolean mLimit = false;
-
 
795
 
637
    /**constructor
796
    /**constructor
638
     */
797
     */
639
    private VersionNumberingStandard()
798
    private VersionNumberingStandard()
640
    {
799
    {
641
      mLogger.debug("VersionNumberingStandard");
800
      mLogger.debug("VersionNumberingStandard");
642
    }
801
    }
643
 
802
 
644
    /**sets mBuild true, mMajor false, mMinor false, mPatch false
803
    /**sets mBuild true, mMajor false, mMinor false, mPatch false, mLimit false
645
     */
804
     */
646
    void setBuild()
805
    void setBuild()
647
    {
806
    {
648
      mLogger.debug("setBuild");
807
      mLogger.debug("setBuild");
649
      mBuild = true;
808
      mBuild = true;
650
      mMajor = false;
809
      mMajor = false;
651
      mMinor = false;
810
      mMinor = false;
652
      mPatch = false;
811
      mPatch = false;
-
 
812
      mLimit = false;
653
    }
813
    }
654
 
814
 
655
    /**sets mBuild false, mMajor true, mMinor false, mPatch false
815
    /**sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit false
656
     */
816
     */
657
    void setMajor()
817
    void setMajor()
658
    {
818
    {
659
      mLogger.debug("setMajor");
819
      mLogger.debug("setMajor");
660
      mBuild = false;
820
      mBuild = false;
661
      mMajor = true;
821
      mMajor = true;
662
      mMinor = false;
822
      mMinor = false;
663
      mPatch = false;
823
      mPatch = false;
-
 
824
      mLimit = false;
664
    }
825
    }
665
 
826
 
666
    /**sets mBuild false, mMajor false, mMinor true, mPatch false
827
    /**sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit false
667
     */
828
     */
668
    void setMinor()
829
    void setMinor()
669
    {
830
    {
670
      mLogger.debug("setMinor");
831
      mLogger.debug("setMinor");
671
      mBuild = false;
832
      mBuild = false;
672
      mMajor = false;
833
      mMajor = false;
673
      mMinor = true;
834
      mMinor = true;
674
      mPatch = false;
835
      mPatch = false;
-
 
836
      mLimit = false;
675
    }
837
    }
676
 
838
 
677
    /**sets mBuild false, mMajor false, mMinor false, mPatch true
839
    /**sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit false
678
     */
840
     */
679
    void setPatch()
841
    void setPatch()
680
    {
842
    {
681
      mLogger.debug("setPatch");
843
      mLogger.debug("setPatch");
682
      mBuild = false;
844
      mBuild = false;
683
      mMajor = false;
845
      mMajor = false;
684
      mMinor = false;
846
      mMinor = false;
685
      mPatch = true;
847
      mPatch = true;
-
 
848
      mLimit = false;
-
 
849
    }
-
 
850
 
-
 
851
    /**sets mBuild false, mMajor false, mMinor false, mPatch false, mLimit true
-
 
852
     */
-
 
853
    void setLimit()
-
 
854
    {
-
 
855
      mLogger.debug("setPatch");
-
 
856
      mBuild = false;
-
 
857
      mMajor = false;
-
 
858
      mMinor = false;
-
 
859
      mPatch = false;
-
 
860
      mLimit = true;
686
    }
861
    }
687
 
862
 
688
  }
863
  }
689
 
864
 
690
}
865
}