[Orca-checkins] r337 - in trunk/orca: lib/Orca orca

Blair Zajac blair at orcaware.com
Mon Jun 7 22:01:07 PDT 2004


Author: blair
Date: Mon Jun  7 21:59:04 2004
New Revision: 337

Modified:
   trunk/orca/lib/Orca/Config.pm
   trunk/orca/lib/Orca/Constants.pm
   trunk/orca/orca/orca.pl.in
Log:
Implement a new versioning scheme for Orca to fix a couple of issues.

1) The old code would have version 0.9 be greater than version 0.28.
2) The version string can optionally contain the Subversion repository
   revision number to allow non-blessed distributions to have a
   revision number.  This will make it much easier to track Orca
   versions that people have installed.
3) Be much more flexible in handing required version numbers.

* lib/Orca/Constants.pm:
  ($ORCA_VER_MAJOR),
  ($ORCA_VER_MINOR),
  ($ORCA_VER_PATCH),
  ($ORCA_VER_QUOTED),
  ($ORCA_VER_REVISION),
  ($ORCA_VER_TAG):
    New exported version variables.

* lib/Orca/Config.pm
  (main):
    Use the 'version' Perl module.
    Use $ORCA_VER_QUOTED instead of $ORCA_VERSION.
  (check_config):
    Fix a bug where 0.28 is a release number greater than 0.9.
    Be much more flexible in handling different required Orca version
      number strings.

* orca/orca.pl.in
  (main):
    Use the 'version' Perl module and specify its the required version
      of the version module.
  (pod):
    Give example version number strings.


Modified: trunk/orca/lib/Orca/Config.pm
==============================================================================
--- trunk/orca/lib/Orca/Config.pm	(original)
+++ trunk/orca/lib/Orca/Config.pm	Mon Jun  7 21:59:04 2004
@@ -13,10 +13,12 @@
 use strict;
 use Carp;
 use Exporter;
+use version;
+
 use Orca::Constants     qw($opt_verbose
                            $is_sub_re
                            die_when_called
-                           $ORCA_VERSION
+                           $ORCA_VER_QUOTED
                            @CONST_IMAGE_PLOT_TYPES
                            %CONST_IMAGE_PLOT_INFO
                            @IMAGE_PLOT_TYPES
@@ -326,21 +328,42 @@
     my @require = @{$config_global{require}};
     if (@require == 2) {
       my ($require_what, $require_version) = @require;
-      unless ($require_what eq 'Orca') {
+      if ($require_what eq 'Orca') {
+        # Normalize the required version string to the form
+        # \d+\.\d+\.\d+ .  To handle almost any input version string,
+        # split on the existing periods and for each substring, if it
+        # is not defined or has 0 length, then set it to 0.  Do not
+        # worry about there being more than two periods in the given
+        # string, the regular expression match below will catch
+        # invalid version strings.
+        my @vers = split(/\./, $require_version);
+
+        for (my $i=0; $i<3; ++$i) {
+          unless (defined $vers[$i] and length $vers[$i]) {
+            $vers[$i] = 0;
+          }
+        }
+        my $reformulated_required_version = join('.', @vers);
+
+        if ($reformulated_required_version =~ /^\d+\.\d+\.\d+$/) {
+          $require_version = version->new($reformulated_required_version);
+          my $orca_version = version->new($ORCA_VER_QUOTED);
+
+          if ($orca_version < $require_version) {
+            warn "$0: Orca version $ORCA_VER_QUOTED less than required ",
+                 "version $require_version specified in '$config_filename'.\n";
+            ++$number_errors;
+          }
+        } else {
+          warn "$0: error: 'require' second argument '$require_version' is ",
+               "not a valid version number in '$config_filename'.\n";
+          ++$number_errors;
+        }
+      } else {
         warn "$0: error: 'require' only accepts 'Orca' as first argument in ",
              "'$config_filename'.\n";
         ++$number_errors;
       }
-      if ($require_version !~ /^\d+(?:\.\d*)?$/ and
-          $require_version !~ /^\.\d+$/) {
-        warn "$0: error: 'require' second argument '$require_version' is not ",
-             "a number in '$config_filename'.\n";
-        ++$number_errors;
-      } elsif ($ORCA_VERSION < $require_version) {
-        warn "$0: Orca version $ORCA_VERSION less than required version ",
-             "$require_version specified in '$config_filename'.\n";
-        ++$number_errors;
-      }
     } else {
       warn "$0: error: 'require' needs two arguments in '$config_filename'.\n";
       ++$number_errors;

Modified: trunk/orca/lib/Orca/Constants.pm
==============================================================================
--- trunk/orca/lib/Orca/Constants.pm	(original)
+++ trunk/orca/lib/Orca/Constants.pm	Mon Jun  7 21:59:04 2004
@@ -16,7 +16,32 @@
 @ISA     = qw(Exporter);
 $VERSION = substr q$Revision: 0.01 $, 10;
 
-# ORCA_VERSION          This version of Orca.
+# ORCA_VER_MAJOR        Orca's major version number.  Increment when
+#                       incompatible changes are made to published
+#                       interfaces.
+# ORCA_VER_MINOR        Orca's minor version number.  Increment when
+#                       new functionality is added or new interfaces
+#                       are defined, but all changes are backward
+#                       compatible.
+# ORCA_VER_PATCH        Orca's patch version number.  Increment for
+#                       every released patch.
+# ORCA_VER_QUOTED       The variables $ORCA_VER_MAJOR,
+#                       $ORCA_VER_MINOR and $ORCA_VER_PATCH
+#                       joined with periods, i.e. "1.2.3".
+# ORCA_VER_REVISION     The Subversion repository revision number of
+#                       this release.  It remains 0 in the repository.
+#                       When rolling a tarball, it is automatically
+#                       replaced with a best guess to be the correct
+#                       revision number.
+# ORCA_VER_TAG          A string describing the version.  This tag
+#                       remains " (dev $ORCA_VER_REVISION)" in the
+#                       repository so that we can always see that the
+#                       software has been built from the repository
+#                       rather than a "blessed" version.  For snapshot
+#                       releases, the variable is left unchanged.  For
+#                       final releases, it is emptied.
+# ORCA_VERSION          The real version of Orca.  Formed by the string
+#                       "$ORCA_VER_QUOTED$ORCA_VER_TAG".
 # ORCA_RRD_VERSION      This is the version number used in creating the DS
 #                       names in RRDs.  This should be updated any time a
 #                       new version of Orca needs some new content in its
@@ -24,12 +49,34 @@
 #                       string Orca with this string of digits.
 # DAY_SECONDS           The number of seconds in one day.
 # IS_WIN32              If Orca is running on a Windows platform.
-use vars         qw($ORCA_VERSION $ORCA_RRD_VERSION);
-push(@EXPORT_OK, qw($ORCA_VERSION $ORCA_RRD_VERSION DAY_SECONDS IS_WIN32));
-$ORCA_VERSION        =  '0.27';
-$ORCA_RRD_VERSION    =  19990222;
-sub DAY_SECONDS      () { 24*60*60 };
-sub IS_WIN32         () { $^O eq 'MSWin32' };
+use vars         qw($ORCA_VER_MAJOR
+                    $ORCA_VER_MINOR
+                    $ORCA_VER_PATCH
+                    $ORCA_VER_QUOTED
+                    $ORCA_VER_REVISION
+                    $ORCA_VER_TAG
+                    $ORCA_VERSION
+                    $ORCA_RRD_VERSION);
+push(@EXPORT_OK, qw($ORCA_VER_MAJOR
+                    $ORCA_VER_MINOR
+                    $ORCA_VER_PATCH
+                    $ORCA_VER_QUOTED
+                    $ORCA_VER_REVISION
+                    $ORCA_VER_TAG
+                    $ORCA_VERSION
+                    $ORCA_RRD_VERSION
+                    DAY_SECONDS
+                    IS_WIN32));
+$ORCA_VER_MAJOR    =  0;
+$ORCA_VER_MINOR    = 28;
+$ORCA_VER_PATCH    =  0;
+$ORCA_VER_REVISION =  0;
+$ORCA_VER_QUOTED   =  "$ORCA_VER_MAJOR.$ORCA_VER_MINOR.$ORCA_VER_PATCH";
+$ORCA_VER_TAG      =  " (dev $ORCA_VER_REVISION)";
+$ORCA_VERSION      =  "$ORCA_VER_QUOTED$ORCA_VER_TAG";
+$ORCA_RRD_VERSION  =   19990222;
+sub DAY_SECONDS    () { 24*60*60 };
+sub IS_WIN32       () { $^O eq 'MSWin32' };
 
 # These define the name of the different round robin archives (RRAs)
 # to create in each RRD file, how many primary data points go into a

Modified: trunk/orca/orca/orca.pl.in
==============================================================================
--- trunk/orca/orca/orca.pl.in	(original)
+++ trunk/orca/orca/orca.pl.in	Mon Jun  7 21:59:04 2004
@@ -34,6 +34,7 @@
 use Math::IntervalSearch @MATH_INTERVALSEARCH_VER@ qw(interval_search);
 use Storable             @STORABLE_VER@;
 use RRDs                 @RRDTOOL_VER@;
+use version              @VERSION_VER@;
 
 # Set behavior of the Data::Dumper module.
 $Data::Dumper::Indent   = 1;
@@ -1455,7 +1456,8 @@
 The B<require> parameter allows the configuration file to specify the
 minimum required version of a package to run.  Both I<package name>
 and I<version number> are required and I<version number> must be a
-number, not a general Perl expression.
+version number, not a general Perl expression.  Valid styles of
+version numbers include: '1', '1.', '.28', '0.28.3'.
 
 Currently, only the minimum required version of Orca can be specified
 and I<package name> must be set to Orca.



More information about the Orca-checkins mailing list