version.py revision 36
3N/A# The contents of this file are subject to the terms of the 3N/A# Common Development and Distribution License (the "License"). 3N/A# You may not use this file except in compliance with the License. 3N/A# See the License for the specific language governing permissions 3N/A# and limitations under the License. 3N/A# When distributing Covered Code, include this CDDL HEADER in each 3N/A# If applicable, add the following below this CDDL HEADER, with the 3N/A# fields enclosed by brackets "[]" replaced with your own identifying 3N/A# information: Portions Copyright [yyyy] [name of copyright owner] 3N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 3N/A# Use is subject to license terms. 3N/A """A DotSequence is the typical "x.y.z" string used in software 3N/A versioning. We define the "major release" value and the "minor release" 3N/A value as the first two numbers in the sequence.""" 30N/A """Return true if self is a "subsequence" of other, meaning that 30N/A other and self have identical components, up to the length of 30N/A self's sequence.""" 32N/A """Version format is release[,build_release]-branch:timestamp, which we 32N/A decompose into three DotSequences and the timestamp. The 22N/A release and branch DotSequences are interpreted normally, where v1 < v2 22N/A implies that v2 is a later release or branch. The build_release 22N/A DotSequence records the system on which the package binaries were 22N/A constructed. Interpretation of the build_release by the client is that, 22N/A in the case b1 < b2, a b1 package can be run on either b1 or b2 22N/A systems,while a b2 package can only be run on a b2 system.""" 3N/A # XXX If illegally formatted, raise exception. 26N/A m =
re.
match(
"(\d+[\.\d]*),(\d+[\.\d]*)-(\d+[\.\d]*)\:(\d+)",
22N/A """target is a DotSequence for the target system.""" 30N/A """Evaluate true if self is a successor version to other. 30N/A The loosest constraint is CONSTRAINT_NONE (None is treated 30N/A equivalently, which is a simple test for self > other. As we 30N/A proceed through the policies we get stricter, depending on the 30N/A selected constraint. 30N/A For CONSTRAINT_RELEASE, self is a successor to other if all of 30N/A the components of other's release match, and there are later 32N/A components of self's version. The branch and timestamp 30N/A components are ignored. 30N/A For CONSTRAINT_RELEASE_MAJOR and CONSTRAINT_RELEASE_MINOR, other 30N/A is effectively truncated to [other[0]] and [other[0], other[1]] 30N/A prior to being treated as for CONSTRAINT_RELEASE. 30N/A Similarly for CONSTRAINT_BRANCH, the release fields of other and 30N/A self are expected to be identical, and then the branches are 30N/A compared as releases were for the CONSTRAINT_RELEASE* policies.