You are looking at historical revision 23985 of this page. It may differ significantly from its current revision.
This extension provides procedures for handling versioning of arbitrary packages. It should simplify determining when new packages are available based on some string containing version data. This should, hopefully, make life easier for maintainers.
(use versions) (define full-version (string->version "label184.108.40.206.6extra")) (define v1 (string->version "1.2.0")) (define v2 (string->version "2.0")) (if (version>? v2 v1) (bump:major! v1)) (printf "V1: ~A V2: ~A~%" (version->string v1) (version->string v2)) (printf "Sorted: ~A~%" (map version->string (version-sort (list v2 v1 full-version))))
Version strings have the following format:
MAJOR, MINOR, MICRO (if given), and all segments of PATCH (if given) must be separated by dots (.). The version strings have the following semantics:
|LABEL||no||[any chars]||Any characters, including digits, are allowed. If the LABEL ends with a digit character, some separator character BESIDES . is required; otherwise, the end of LABEL will be parsed as the MAJOR value. The LABEL segment usually corresponds to the name of the package.|
|MAJOR||yes||[integer]||Major release version.|
|MINOR||yes||[integer]||Minor release version.|
|MICRO||no||[integer]||Micro release version.|
|PATCH||no||([integer])...||Patch version. This may be composed of any number of segments; there is no limit. (This is to allow parsing of version control tree versions.)|
|EXTRA||no[any chars]||Extra version suffix, usually for local or maintainer versions. It must be separated from the final element by a non-digit, non-dot character.|
Version Records[record] version
[procedure] (make-version MAJOR MINOR #!key (label #f) (micro #f) (patch #f) (extra #f))
Creates a new version record with the given components. MAJOR, MINOR, and MICRO (if given) must be exact non-negative integers. LABEL and EXTRA, if given, must be non-null strings. PATCH (if given) must be either a non-negative exact integer or a list/vector composed of non-negative exact integers.[procedure] (version? OBJ)
Returns #t if OBJ is a version record.[procedure] (version:label VERSION)
[procedure] (version:major VERSION)
[procedure] (version:minor VERSION)
[procedure] (version:micro VERSION)
[procedure] (version:patch VERSION)
[procedure] (version:extra VERSION)
Returns the specified field of the VERSION record.
Conversion Procedures[procedure] (string->version VERSION-STRING)
If VERSION-STRING is a string with valid version data, returns a version record with its parsed components. Otherwise, return #f.[procedure] (version->string VERSION)
Returns the string representation of the given VERSION record.
Two version objects, v1 and v2 are ordered via the rules below. (The version: prefix is ommitted for conciseness.) All string fields are compared with the string=?, string<?, and string>? procedures. All numeric fields or numeric field components are compared with the fx=, fx<, and fx> procedures. The patch field, below, is first checked against the entire field for existence, then each element (if it exists) is compared in order, with an implicit last element of #f.
In each of the following procedures, VER1 and VER2 may be either version records or version strings.[procedure] (version-compare VER1 VER2)
Returns -1 if VER1<VER2, 0 if VER1=VER2, and 1 if VER1>VER2.[procedure] (version=? VER1 VER2)
[procedure] (version<? VER1 VER2)
[procedure] (version<=? VER1 VER2)
[procedure] (version>=? VER1 VER2)
[procedure] (version>? VER1 VER2)
Comparison predicates for versions, according to the rules given above.[procedure] (version-exact? VER1 VER2)
Equivalent to (version=? VER1 VER2).[procedure] (version-older? VER1 VER2)
Equivalent to (version<? VER1 VER2).[procedure] (version-newer? VER1 VER2)
Equivalent to (version>? VER1 VER2).
Sorting Procedures[procedure] (version-sort VERSION-LIST [ASCENDING? #t])
Sorts VERSION-LIST (a list of version strings and/or records). If ASCENDING? is given and #f, VERSION-LIST is sorted in descending order. ASCENDING? defaults to #t.
Bumping Procedures[procedure] (bump:major! VERSION #!key (to #f))
Increase the major-part of the version by 1 or set to to if given.[procedure] (bump:minor! VERSION #!key (to #f))
Increase the minor-part of the version by 1 or set to to if given.[procedure] (bump:micro! VERSION #!key (to #f))
Increase the micro-part of the version by 1 or set to to if given.[procedure] (bump:patch! VERSION #!key (to #f))
Increase the last number ofthe patch-part by 1 or set to to if given.[procedure] (bump! VERSION)
Increase the lowest possible part by 1. This procedure tries to do the right thing, and should generaly really do.
Copyright (C) 2008, Lenny Frank. All rights reserved. Copyright (C) 2011, David Krentzlin. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS-IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.