Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.ripple;
2
 
3
import java.io.File;
4
 
5
import java.util.Iterator;
6
import java.util.Vector;
7
 
8
import org.apache.log4j.Logger;
9
 
10
public class Package
11
{
12
  /**name of package, must not contain spaces
13
   * @attribute
14
   */
15
  String mName = new String();
16
 
17
  /**package scope
18
   * @attribute
19
   */
20
  String mExtension = new String();
21
 
22
  /**instance identifier
23
   * @attribute
24
   */
25
  String mVersion = new String();
26
 
27
  /**unique identifier
28
   * for daemon builds = mName + mExtension
29
   * for escrow builds = mName + mVersion + mExtension
30
   * @attribute
31
   */
32
  String mAlias = new String();
33
 
34
  /**clearcase vob location, must not contain spaces
35
   * @attribute
36
   */
37
  String mLocation = new String();
38
 
39
  /**clearcase source file instance identifier
40
   * @attribute
41
   */
42
  String mLabel = new String();
43
 
44
  /**build standards
45
   * @attribute
46
   */
864 mhunt 47
  Vector<BuildStandard> mBuildStandardCollection = new Vector<BuildStandard>();
814 mhunt 48
 
49
  /**GBE_MACHTYPE used to build generic packages for this baseline
50
   * only has meaning in the daemon build, not the escrow build
51
   * accessed by BuildStandard::getPlatform, getBuildStandard
52
   * @attribute
53
   */
54
  public static final String mGenericMachtype = System.getenv("GBE_MACHTYPE");
55
 
56
  /**build dependencies by package alias
57
   * @attribute
58
   */
864 mhunt 59
  Vector<String> mDependencyCollection = new Vector<String>();
814 mhunt 60
 
61
  /**primary package version key pv_id in database
62
   * @attribute
63
   */
64
  int mId;
65
 
66
  /**indication of the nature of change
67
   * @attribute
68
   */
69
  Package.VersionNumberingStandard mChangeType = new VersionNumberingStandard();
70
 
71
  /**determines what field is rippled on a package version whose dependencies have changed
72
   * @attribute
73
   */
74
  Package.VersionNumberingStandard mRippleField = new VersionNumberingStandard();
75
 
76
  /**interested owners
77
   * @attribute
78
   */
864 mhunt 79
  private Vector<String> mBuildFailureEmailCollection = new Vector<String>();
814 mhunt 80
 
81
  /**when true will trigger unit tests as part of the package build phase in daemon mode
82
   * @attribute
83
   */
84
  boolean mHasAutomatedUnitTests = false;
85
 
86
  /**when true, do not ripple this package through packages which are dependent upon it in daemon mode
87
   * @attribute
88
   */
89
  boolean mAdvisoryRipple = false;
90
 
91
  /**determines the build file the package is built in, or not
92
   *  1 buildfile 1 etc
93
   *  0 not yet processed (initial value)
94
   * -1 not reproducible
95
   * -2 not reproducible on the build platforms configured for this release
96
   * -3 do not ripple
97
   * -4 directly dependent on package versions not in the baseline
98
   * -5 indirectly dependent on package versions which are not reproducible
99
   *    because of -1, -2 (escrow), -3 (daemon), -4
100
   * @attribute
101
   */
102
  int mBuildFile = 0;
103
 
104
  /**build dependencies by package
105
   * @attribute
106
   */
864 mhunt 107
  Vector<Package> mPackageDependencyCollection = new Vector<Package>();
814 mhunt 108
 
109
  /**used for escrow build purposes
110
   * set true when a package has been processed
111
   * @attribute
112
   */
113
  boolean mProcessed = false;
114
 
115
  /**set true for WIP package versions
116
   * only used in daemon mode
117
   * @attribute
118
   */
119
  boolean mDirectlyPlanned = false;
120
 
121
  /**set true when it is determined to be ripple built
122
   * @attribute
123
   */
124
  boolean mIndirectlyPlanned = false;
125
 
126
  /**build dependencies by pv_id (-1 or not used for planned dependencies)
127
   * @attribute
128
   */
864 mhunt 129
  Vector<Integer> mDependencyIDCollection = new Vector<Integer>();
814 mhunt 130
 
131
  /**unique pkg_id in the database
132
   * used for querying package version existence in the database in daemon mode
133
   * @attribute
134
   */
135
  int mPid;
136
 
874 mhunt 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
 
814 mhunt 157
  /**Logger
158
   * @attribute
159
   */
160
  private static final Logger mLogger = Logger.getLogger(Package.class);
161
 
162
  /**dpkg archive location
163
   * @attribute
164
   */
165
  public static final String mGbeDpkg = System.getenv("GBE_DPKG");
166
 
167
  /**deploy archive location
168
   * @attribute
169
   */
170
  public static final String mGbeDply = System.getenv("GBE_DPLY");
171
 
896 mhunt 172
  /**Exception message used upon detection an archive does not exist
173
   * Seems this is a rare but transient and recoverable scenario
174
   * @attribute
175
   */
176
  public static final String mRecoverable = "dpkg or deploy_archive do not exist, recovery will be attempted";
177
 
814 mhunt 178
  /**true if the package exists in the dpkg or deploy archive
179
   * @attribute
180
   */
181
  private boolean mArchivalExistence = true;
182
 
852 mhunt 183
  /**when true will trigger source control interaction eg labelling
184
   * @attribute
185
   */
186
  public boolean mRequiresSourceControlInteraction = true;
187
 
814 mhunt 188
  /**constructor
189
   */
190
  Package(int pv_id, String pkg_name, String v_ext, String alias, 
902 mhunt 191
          String pkg_label, String src_path, char change_type, char ripple_field)
814 mhunt 192
  {
193
    mLogger.debug("Package 1: pv_id " + pv_id + " pkg_name " + pkg_name + " v_ext " + v_ext + " alias " + alias + " pkg_label " + pkg_label + " src_path " + src_path + " change_type " + change_type);
194
    mId = pv_id;
195
    mName = pkg_name;
196
    mVersion = "0.0.0000";
197
    mExtension = v_ext;
198
    mAlias = alias;
199
    mLabel = pkg_label;
200
    mLocation = src_path;
201
 
202
    if (change_type == 'M')
203
    {
902 mhunt 204
      // a ripple_field of 'L' indicates this package has limited version numbering
205
      mChangeType.setMajor(ripple_field == 'L' ? true : false);
814 mhunt 206
    }
207
    else if (change_type == 'N')
208
    {
902 mhunt 209
      mChangeType.setMinor(ripple_field == 'L' ? true : false);
814 mhunt 210
    }
211
    else
212
    {
902 mhunt 213
      mChangeType.setPatch(ripple_field == 'L' ? true : false);
814 mhunt 214
    }
215
  }
216
 
217
  /**constructor
218
   */
219
  Package(int pv_id, String pkg_name, String pkg_version, String v_ext, 
220
          String alias, String pkg_label, String src_path, 
221
          char ripple_field)
222
  {
223
    mLogger.debug("Package 2: pv_id " + pv_id + " pkg_name " + pkg_name + " pkg_version " + pkg_version + " v_ext " + v_ext + " alias " + alias + " pkg_label " + pkg_label + " src_path " + src_path + " ripple_field " + ripple_field);
224
    mId = pv_id;
225
    mName = pkg_name;
226
    mVersion = pkg_version;
227
    int endindex = mVersion.length() - v_ext.length();
228
 
229
    if ( endindex > 0 )
230
    {
231
      mVersion = mVersion.substring(0, endindex);
232
    }
233
 
234
    mExtension = v_ext;
235
    mAlias = alias;
236
    mLabel = pkg_label;
237
    mLocation = src_path;
238
 
874 mhunt 239
    // setBuild is the default
814 mhunt 240
    if (ripple_field == 'M')
241
    {
242
      mRippleField.setMajor();
243
    }
244
    else if (ripple_field == 'm')
245
    {
246
      mRippleField.setMinor();
247
    }
248
    else if (ripple_field == 'p')
249
    {
250
      mRippleField.setPatch();
251
    }
874 mhunt 252
    else if (ripple_field == 'L')
253
    {
254
      mRippleField.setLimit();
255
    }
814 mhunt 256
  }
257
 
258
  /**constructor
259
   */
260
  Package()
261
  {
262
    mLogger.debug("Package 3");
263
    mId = 0;
264
    mName = "null";
265
    mExtension = "null";
266
    mAlias = "null";
267
    mLabel = "null";
268
    mLocation = "null";
269
  }
270
 
874 mhunt 271
  /**constructor for unit test purposes
272
  */
273
  public Package(ReleaseManager rm, String version, int majorLimit, int minorLimit, int patchLimit, int buildNumberLimit)
274
  {
275
    mId = -1;
276
    mRippleField.setLimit();
277
    mVersion = version;
278
    mMajorLimit = majorLimit;
279
    mMinorLimit = minorLimit;
280
    mPatchLimit = patchLimit;
281
    mBuildLimit = buildNumberLimit;
282
    try
283
    {
284
      mId = applyPV( rm, 0 );
285
    }
286
    catch(Exception e)
287
    {
288
    }
289
  }
290
 
291
  /**accessor for unit test purposes
292
   */
293
  public int getId()
294
  {
295
    return mId;
296
  }
297
 
298
  /**accessor for unit test purposes
299
   */
300
  public String getVersion()
301
  {
302
    return mVersion;
303
  }
304
 
814 mhunt 305
  /**returns true if mBuildStandardCollection is not empty
306
   */
307
  boolean isReproducible()
308
  {
309
    mLogger.debug("isReproducible on Package " + mName);
310
    boolean retVal = false;
311
 
312
    if ( mBuildStandardCollection.size() > 0 )
313
    {
314
      retVal = true;
315
    }
316
 
317
    mLogger.info("isReproducible returned " + retVal);
318
    return retVal;
319
  }
320
 
321
  /**returns true if at least one of its BuildStandards has mWin32 or mGeneric true
322
   */
323
  boolean isWin32Built()
324
  {
325
    mLogger.debug("isWin32Built on Package " + mName);
326
    boolean retVal = false;
864 mhunt 327
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 328
    {
864 mhunt 329
      BuildStandard buildStandard = it.next();
814 mhunt 330
 
331
      if (buildStandard.getWin32() || buildStandard.getGeneric())
332
      {
333
        retVal = true;
334
        break;
335
      }
336
    }
337
 
338
    mLogger.info("isWin32Built returned " + retVal);
339
    return retVal;
340
  }
341
 
342
  /**returns true if at least one of its BuildStandards has mSolaris or mGeneric true
343
   */
344
  boolean isSolarisBuilt()
345
  {
346
    mLogger.debug("isSolarisBuilt on Package " + mName);
347
    boolean retVal = false;
864 mhunt 348
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 349
    {
864 mhunt 350
      BuildStandard buildStandard = it.next();
814 mhunt 351
 
352
      if (buildStandard.getSolaris() || buildStandard.getGeneric())
353
      {
354
        retVal = true;
355
        break;
356
      }
357
    }
358
 
359
    mLogger.info("isSolarisBuilt returned " + retVal);
360
    return retVal;
361
  }
362
 
363
  /**returns true if at least one of its BuildStandards has mLinux or mGeneric true
364
   */
365
  boolean isLinuxBuilt()
366
  {
367
    mLogger.debug("isLinuxBuilt on Package " + mName);
368
    boolean retVal = false;
864 mhunt 369
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 370
    {
864 mhunt 371
      BuildStandard buildStandard = it.next();
814 mhunt 372
 
373
      if (buildStandard.getLinux() || buildStandard.getGeneric())
374
      {
375
        retVal = true;
376
        break;
377
      }
378
    }
379
 
380
    mLogger.info("isLinuxBuilt returned " + retVal);
381
    return retVal;
382
  }
383
 
384
  /**returns true if at least one of its BuildStandards has mGeneric true
385
   */
386
  boolean isGeneric()
387
  {
388
    mLogger.debug("isGeneric on Package " + mName);
389
    boolean retVal = false;
864 mhunt 390
    for (Iterator<BuildStandard> it = mBuildStandardCollection.iterator(); it.hasNext(); )
814 mhunt 391
    {
864 mhunt 392
      BuildStandard buildStandard = it.next();
814 mhunt 393
 
394
      if (buildStandard.getGeneric())
395
      {
396
        retVal = true;
397
        break;
398
      }
399
    }
400
 
401
    mLogger.info("isGeneric returned " + retVal);
402
    return retVal;
403
  }
404
 
405
  /**applies the required version number change
874 mhunt 406
   * returns 0 on success
407
   *         1 on cannot work with non standard versioning
408
   *         2 on ripple field limitations prevent a ripple build
814 mhunt 409
   */
874 mhunt 410
  int applyPV(ReleaseManager releaseManager, int rtag_id) throws Exception
814 mhunt 411
  {
412
    mLogger.debug("applyPV on Package " + mName);
413
    // three scenarios, only applyPV for 2 of them
414
    // WIP exists:                      mDirectlyPlanned == true;   mIndirectlyPlanned == true; mArchivalExistence don't care - applyPV
415
    // Package version is out of date:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == true    - applyPV
416
    // Package version does not exist:  mDirectlyPlanned == false;  mIndirectlyPlanned == true; mArchivalExistence == false   - do not applyPV
417
    if ( !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence )
418
    {
419
      // the package has an mIndirectlyPlanned flag set true in daemon mode because the package does not exist in an archive
420
      // do not apply a different package version
421
      mLogger.info("applyPV !mDirectlyPlanned && mIndirectlyPlanned && !mArchivalExistence on Package " + mName);
836 mhunt 422
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
874 mhunt 423
      mLogger.info("applyPv returned 0");
424
      return 0;
814 mhunt 425
    }
426
 
892 mhunt 427
    MutableInt major = new MutableInt();
428
    major.value = 0;
429
    MutableInt minor = new MutableInt();
430
    minor.value = 0;
431
    MutableInt patch = new MutableInt();
432
    patch.value = 1000;
814 mhunt 433
 
434
    String field[] = mVersion.split("\\D");
888 mhunt 435
    String nonStandardCotsVersion = "";
436
 
814 mhunt 437
    if ( field.length == 3 )
438
    {
892 mhunt 439
      major.value = Integer.parseInt(field[0]);
440
      minor.value = Integer.parseInt(field[1]);
441
      patch.value = Integer.parseInt(field[2]);
814 mhunt 442
    }
443
    else
444
    {
888 mhunt 445
      if ( !mChangeType.mMajor &&
446
           !mChangeType.mMinor &&
447
           !mChangeType.mPatch &&
448
           mRippleField.mBuild &&
449
           mExtension.compareTo(".cots") == 0 &&
450
           field.length > 0 )
451
      {
452
        // DEVI 52782
453
        // allow and work with (ripple build) versions a.b.c.d....xxxx
454
        // where xxxx.length > 3
455
        String patchStr = field[field.length - 1];
456
        int patchLen = patchStr.length();
457
 
458
        // check patchStr is the last (at least 4) digits
459
        if ( patchLen > 3 && mVersion.substring( mVersion.length() - patchLen, mVersion.length() ).compareTo(patchStr) == 0 )
460
        {
892 mhunt 461
          patch.value = Integer.parseInt(patchStr);
888 mhunt 462
          nonStandardCotsVersion = mVersion.substring(0, mVersion.length() - patchLen );
463
        }
464
      }
465
 
466
      if ( nonStandardCotsVersion.length() == 0 )
467
      {
468
        // cannot work with non standard versioning
469
        mLogger.error("applyPV cannot work with non standard versioning");
470
        mLogger.info("applyPv returned 1");
471
        return 1;
472
      }
814 mhunt 473
    }
474
 
888 mhunt 475
    if ( nonStandardCotsVersion.length() == 0 &&
892 mhunt 476
         patch.value < 1000 && 
888 mhunt 477
         field[2].substring(0, 1).compareTo("0") != 0 )
814 mhunt 478
    {
479
      mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
892 mhunt 480
      patch.value = patch.value * 1000;
814 mhunt 481
    }
482
 
483
    // mChangeType overrides mRippleField
484
    do
485
    {
486
      if ( mChangeType.mMajor )
487
      {
892 mhunt 488
        if ( !incrementFieldsAccordingToLimits(4, major, minor, patch) )
489
        {
490
          mLogger.info("applyPv returned 2");
491
          return 2;
492
        }
814 mhunt 493
      }
494
      else if ( mChangeType.mMinor )
495
      {
892 mhunt 496
        if ( !incrementFieldsAccordingToLimits(3, major, minor, patch) )
497
        {
498
          mLogger.info("applyPv returned 2");
499
          return 2;
500
        }
814 mhunt 501
      }
502
      else if ( mChangeType.mPatch )
503
      {
892 mhunt 504
        if ( !incrementFieldsAccordingToLimits(2, major, minor, patch) )
814 mhunt 505
        {
892 mhunt 506
          mLogger.info("applyPv returned 2");
507
          return 2;
508
        }
814 mhunt 509
      }
510
      else
511
      {
512
        if ( mRippleField.mMajor )
513
        {
892 mhunt 514
          major.value++;
515
          mLogger.info("applyPV mRippleField.mMajor " + major.value);
516
          minor.value = 0;
517
          patch.value = 0;
814 mhunt 518
        }
519
        else if ( mRippleField.mMinor )
520
        {
892 mhunt 521
          minor.value++;
522
          mLogger.info("applyPV mRippleField.mMinor " + minor.value);
523
          patch.value = 0;
814 mhunt 524
        }
525
        else if ( mRippleField.mPatch )
526
        {
527
          do
528
          {
892 mhunt 529
            patch.value++;
530
          } while ( ( patch.value / 1000 ) * 1000 != patch.value );
531
          mLogger.info("applyPV mRippleField.mPatch " + patch.value);
814 mhunt 532
        }
874 mhunt 533
        else if ( mRippleField.mBuild )
814 mhunt 534
        {
892 mhunt 535
          patch.value++;
536
          mLogger.info("applyPV mRippleField.mBuild " + patch.value);
814 mhunt 537
        }
874 mhunt 538
        else
539
        {
892 mhunt 540
          if ( !incrementFieldsAccordingToLimits(1, major, minor, patch) )
874 mhunt 541
          {
542
            mLogger.info("applyPv returned 2");
543
            return 2;
544
          }
545
        }
814 mhunt 546
      }
888 mhunt 547
 
548
      if ( nonStandardCotsVersion.length() == 0 )
549
      {
892 mhunt 550
        mVersion = String.valueOf(major.value) + "." + String.valueOf(minor.value) + ".";
888 mhunt 551
      }
552
      else
553
      {
554
        mVersion = nonStandardCotsVersion;
555
      }
814 mhunt 556
 
892 mhunt 557
      if ( patch.value < 10 )
814 mhunt 558
      {
559
        mVersion += "000";
560
      }
892 mhunt 561
      else if ( patch.value < 100 )
814 mhunt 562
      {
563
        mVersion += "00";
564
      }
892 mhunt 565
      else if ( patch.value < 1000 )
814 mhunt 566
      {
567
        mVersion += "0";
568
      }
569
 
892 mhunt 570
      mVersion += String.valueOf(patch.value);
814 mhunt 571
    } while ( exists(releaseManager, rtag_id) );
572
 
573
    releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
874 mhunt 574
    mLogger.info("applyPv returned 0");
575
    return 0;
814 mhunt 576
  }
577
 
892 mhunt 578
  /**increments fields according to mRippleField.mLimit if necessary
579
   * will apply it to the field passed as follows
580
   * 1 = build
581
   * 2 = patch
582
   * 3 = minor
583
   * other = major
584
   * returns true on success
585
   *         false on ripple field limitations prevent a ripple build
586
   */
587
  private boolean incrementFieldsAccordingToLimits(int field, MutableInt major, MutableInt minor, MutableInt patch)
588
  {
589
    boolean retVal = true;
590
 
902 mhunt 591
    if (!mChangeType.mLimit && !mRippleField.mLimit)
892 mhunt 592
    {
593
      // simple case
594
      // no need to take field limits into consideration
595
      switch (field)
596
      {
597
      case 1:
598
        // unreachable
599
        // the only scenario involving build number manipulation involves the mRippleField.mLimit being set
600
        retVal = false;
601
        break;
602
      case 2:
603
        do
604
        {
605
          patch.value++;
606
        } while ( ( patch.value / 1000 ) * 1000 != patch.value );
607
        mLogger.info("incrementFieldsAccordingToLimits patch " + patch.value);
608
        break;
609
      case 3:
610
        minor.value++;
611
        mLogger.info("incrementFieldsAccordingToLimits minor " + minor.value);
612
        patch.value = 0;
613
        break;
614
      default:
615
        major.value++;
616
        mLogger.info("incrementFieldsAccordingToLimits major " + major.value);
617
        minor.value = 0;
618
        patch.value = 0;
619
      }
620
    }
621
    else
622
    {
623
      // take field limits into consideration
624
      boolean changeOccurred = false;
625
      boolean incrementField = true;
626
 
627
      switch (field)
628
      {
629
      case 1:
630
        if ( mBuildLimit != 0 )
631
        {
632
          // increment or reset the patch build number
633
          int buildNumber = patch.value - (patch.value/1000) * 1000;
634
 
635
          if ( buildNumber < mBuildLimit )
636
          {
637
            // can increment the patch build number
638
            patch.value++;
639
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit build number " + patch.value);
640
            changeOccurred = true;
641
            incrementField = false;
642
          }
643
          else
644
          {
645
            if ( mPatchLimit == 0 )
646
            {
647
              // reset the patch number and patch build number
648
              patch.value = 0;
649
            }
650
          }
651
        }
652
        // no break by design
653
      case 2:
654
        if ( mPatchLimit != 0 && incrementField )
655
        {
656
          // increment or reset the patch number
657
          if ( ( patch.value / 1000 ) < mPatchLimit )
658
          {
659
            do
660
            {
661
              patch.value++;
662
            } while ( ( patch.value / 1000 ) * 1000 != patch.value );
663
 
664
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit patch " + patch.value);
665
            changeOccurred = true;
666
            incrementField = false;
667
          }
668
          else
669
          {
670
            // reset the patch number and patch build number
671
            patch.value = 0;
672
          }
673
        }
674
        // no break by design
675
      case 3:
676
        if ( mMinorLimit != 0 && incrementField )
677
        {
678
          // increment or reset the minor number
679
          if ( minor.value < mMinorLimit )
680
          {
681
            minor.value++;
682
            patch.value = 0;
683
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit minor " + minor.value);
684
            changeOccurred = true;
685
            incrementField = false;
686
          }
687
          else
688
          {
689
            // reset the minor number
690
            minor.value = 0;
691
          }
692
        }
693
        // no break by design
694
      default:
695
        if ( mMajorLimit != 0 && incrementField )
696
        {
697
          // increment or reset the major number
698
          if ( major.value < mMajorLimit )
699
          {
700
            // increment the major number
701
            changeOccurred = true;
702
            major.value++;
703
            minor.value = 0;
704
            patch.value = 0;
705
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit major " + major.value);
706
          }
707
        }
708
      }
709
 
710
      if ( !changeOccurred )
711
      {
712
        // unable to increment a field due to field limitations
713
        mLogger.error("incrementFieldsAccordingToLimits ripple field limitations prevent a ripple build");
714
        mLogger.info("incrementFieldsAccordingToLimits returned false");
715
        retVal = false;
716
      }
717
    }
718
 
719
    return retVal;
720
  }
721
 
814 mhunt 722
  /**returns true if the version exists in the dpkg_archive, deploy_archive or release manager database
723
   * claims the version in the release manager database
724
   */
725
  private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
726
  {
727
    mLogger.debug("exists 1 on Package " + mName + " version " + mVersion + " extension " + mExtension);
728
    boolean retVal = false;
729
 
864 mhunt 730
    if ( !ReleaseManager.mUseDatabase )
814 mhunt 731
    {
732
      mLogger.info("exists 1 !releaseManager.mUseDatabase");
733
    }
734
    else
735
    {
736
      retVal = exists();
737
 
738
      if ( !retVal )
739
      {
740
        String pkg_version = new String(mVersion);
741
 
742
        if ( mExtension.length() > 0 )
743
        {
744
          pkg_version += mExtension;
745
        }
746
 
747
        retVal = releaseManager.queryPackageVersions(mPid, pkg_version);
748
      }
749
    }
750
 
751
    mLogger.info("exists 1 returned " + retVal);
752
    return retVal;
753
  }
754
 
896 mhunt 755
  /**returns true if the dpkg_archive and deploy_archive exist
756
   * attempt to recover from their transient loss 
757
   */
758
  public static boolean recover()
759
  {
760
    mLogger.debug("recover");
761
    boolean retVal = false;
762
 
763
    String Release = mGbeDpkg;
764
    String Deploy = mGbeDply;
765
 
766
    if (Release != null && Deploy != null)
767
    {
768
      File dpkg = new File(mGbeDpkg);
769
      File dply = new File(mGbeDply);
770
 
771
      if ( dpkg.exists() && dply.exists() )
772
      {
773
        retVal = true;
774
      }
775
    }
776
 
777
    mLogger.info("recover returned " + retVal);
778
    return retVal;
779
  }
780
 
814 mhunt 781
  /**returns true if the version exists in the dpkg_archive or deploy_archive
782
   */
783
  boolean exists()
784
    throws Exception
785
  {
786
    mLogger.debug("exists 2 on Package " + mName);
787
    boolean retVal = false;
788
 
789
    String Release = mGbeDpkg;
790
    String Deploy = mGbeDply;
791
 
792
    if (Release == null || Deploy == null)
793
    {
868 mhunt 794
      mLogger.fatal("exists 2 Release == null || Deploy == null");
795
      throw new Exception("exists 2 Release == null || Deploy == null");
814 mhunt 796
    }
896 mhunt 797
 
798
    File dpkg = new File(mGbeDpkg);
799
    File dply = new File(mGbeDply);
800
 
801
    if ( !dpkg.exists() || !dply.exists() )
802
    {
803
      mLogger.fatal("exists 2 " + mRecoverable);
804
      throw new Exception(mRecoverable);
805
    }
814 mhunt 806
 
807
    String fs = System.getProperty( "file.separator" );
808
    String name = new String(Release);
809
    name += fs + mName + fs + mVersion + mExtension;
810
    File release = new File(name);
811
 
812
    if (release.exists())
813
    {
814
      mLogger.info("exists 2 release.exists()");
815
      retVal = true;
816
    }
817
 
818
    if (!retVal && (Release != Deploy))
819
    {
820
      name = Deploy + fs + mName + fs + mVersion + mExtension;
821
 
822
      File deploy = new File(name);
823
 
824
      if (deploy.exists())
825
      {
826
        mLogger.info("exists 2 deploy.exists()");
827
        retVal = true;
828
      }
829
    }
830
 
831
    mArchivalExistence = retVal;
832
    mLogger.info("exists 2 returned " + retVal);
833
    return retVal;
834
  }
854 mhunt 835
 
836
  /**returns email information
837
   */
838
  String emailInfo( String lf )
839
  {
840
    String retVal = new String();
841
 
864 mhunt 842
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
854 mhunt 843
    {
864 mhunt 844
      String email = it.next();
854 mhunt 845
      retVal +=
846
      "  <owner email=\"" + email +"\"/>" + lf;
847
    }
848
 
849
    return retVal;
850
  }
814 mhunt 851
 
866 mhunt 852
  /**returns email information
853
   */
854
  String emailInfoNonAntTask()
855
  {
856
    String retVal = null;
857
 
858
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
859
    {
860
      String email = it.next();
861
 
862
      if ( retVal == null )
863
      {
864
        retVal = new String();
865
      }
866
      else
867
      {
868
        retVal += ",";
869
      }
870
      retVal += email;
871
    }
872
 
873
    return retVal;
874
  }
875
 
864 mhunt 876
  /**adds email to mBuildFailureEmailCollection if unique
877
   */
878
  void addEmail( String email )
879
  {
880
    boolean alreadyExists = false;
881
 
882
    for (Iterator<String> it = mBuildFailureEmailCollection.iterator(); it.hasNext(); )
883
    {
884
      String existingEmail = it.next();
885
 
886
      if ( existingEmail.compareTo(email) == 0 )
887
      {
888
        alreadyExists = true;
889
        break;
890
      }
891
    }
892
 
893
    if ( !alreadyExists )
894
    {
895
      mBuildFailureEmailCollection.add(email);
896
    }
897
  }
898
 
814 mhunt 899
  /**entity class supporting the ERG version numbering standard:
900
   * <major>.<minor>.<patch/build>
901
   * patch/build is at least a 4 digit number whose last 3 digits represent the build
902
   */
903
  public class VersionNumberingStandard
904
  {
905
    /**in terms of the mChangeType Package field,
906
     * when true indicates the contract of the package has changed in a non backwardly compatible manner
907
     * in terms of the mRippleField Package field,
908
     * when true indicates the major version number will be incremented
909
     * @attribute
910
     */
911
    private boolean mMajor = false;
912
 
913
    /**in terms of the mChangeType Package field,
914
     * when true indicates the contract of the package has changed in a backwardly compatible manner
915
     * in terms of the mRippleField Package field,
916
     * when true indicates the minor version number will be incremented
917
     * @attribute
918
     */
919
    private boolean mMinor = false;
920
 
921
    /**in terms of the mChangeType Package field,
922
     * when true indicates the contract of the package has not changed, but the package has changed internally
923
     * in terms of the mRippleField Package field,
924
     * when true indicates the minor version number will be incremented
925
     * @attribute
926
     */
927
    private boolean mPatch = false;
928
 
929
    /**in terms of the mChangeType Package field,
930
     * when true indicates the package has not changed, its dependencies potentially have
931
     * in terms of the mRippleField Package field,
932
     * when true indicates the build number will be incremented
933
     * @attribute
934
     */
935
    private boolean mBuild = true;
936
 
874 mhunt 937
    /**in terms of the mChangeType Package field,
902 mhunt 938
     * when true indicates the major, minor, and patch number will be incremented according to field limits
874 mhunt 939
     * in terms of the mRippleField Package field,
940
     * when true indicates the major, minor, patch and build number will be incremented according to field limits
941
     * @attribute
942
     */
943
    private boolean mLimit = false;
944
 
814 mhunt 945
    /**constructor
946
     */
947
    private VersionNumberingStandard()
948
    {
949
      mLogger.debug("VersionNumberingStandard");
950
    }
951
 
874 mhunt 952
    /**sets mBuild true, mMajor false, mMinor false, mPatch false, mLimit false
814 mhunt 953
     */
954
    void setBuild()
955
    {
956
      mLogger.debug("setBuild");
957
      mBuild = true;
958
      mMajor = false;
959
      mMinor = false;
960
      mPatch = false;
874 mhunt 961
      mLimit = false;
814 mhunt 962
    }
963
 
874 mhunt 964
    /**sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit false
814 mhunt 965
     */
966
    void setMajor()
967
    {
968
      mLogger.debug("setMajor");
969
      mBuild = false;
970
      mMajor = true;
971
      mMinor = false;
972
      mPatch = false;
874 mhunt 973
      mLimit = false;
814 mhunt 974
    }
975
 
902 mhunt 976
    /**sets mBuild false, mMajor true, mMinor false, mPatch false, mLimit limit
977
     */
978
    void setMajor( boolean limit )
979
    {
980
      mLogger.debug("setMajor " + limit);
981
      mBuild = false;
982
      mMajor = true;
983
      mMinor = false;
984
      mPatch = false;
985
      mLimit = limit;
986
    }
987
 
874 mhunt 988
    /**sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit false
814 mhunt 989
     */
990
    void setMinor()
991
    {
992
      mLogger.debug("setMinor");
993
      mBuild = false;
994
      mMajor = false;
995
      mMinor = true;
996
      mPatch = false;
874 mhunt 997
      mLimit = false;
814 mhunt 998
    }
999
 
902 mhunt 1000
    /**sets mBuild false, mMajor false, mMinor true, mPatch false, mLimit limit
1001
     */
1002
    void setMinor( boolean limit )
1003
    {
1004
      mLogger.debug("setMinor " + limit);
1005
      mBuild = false;
1006
      mMajor = false;
1007
      mMinor = true;
1008
      mPatch = false;
1009
      mLimit = limit;
1010
    }
1011
 
874 mhunt 1012
    /**sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit false
814 mhunt 1013
     */
1014
    void setPatch()
1015
    {
1016
      mLogger.debug("setPatch");
1017
      mBuild = false;
1018
      mMajor = false;
1019
      mMinor = false;
1020
      mPatch = true;
874 mhunt 1021
      mLimit = false;
814 mhunt 1022
    }
1023
 
902 mhunt 1024
    /**sets mBuild false, mMajor false, mMinor false, mPatch true, mLimit limit
1025
     */
1026
    void setPatch( boolean limit )
1027
    {
1028
      mLogger.debug("setPatch");
1029
      mBuild = false;
1030
      mMajor = false;
1031
      mMinor = false;
1032
      mPatch = true;
1033
      mLimit = limit;
1034
    }
1035
 
874 mhunt 1036
    /**sets mBuild false, mMajor false, mMinor false, mPatch false, mLimit true
1037
     */
1038
    void setLimit()
1039
    {
1040
      mLogger.debug("setPatch");
1041
      mBuild = false;
1042
      mMajor = false;
1043
      mMinor = false;
1044
      mPatch = false;
1045
      mLimit = true;
1046
    }
1047
 
814 mhunt 1048
  }
1049
 
1050
}