Class DebVersionScheme

java.lang.Object
org.cthing.versionparser.debian.DebVersionScheme

public final class DebVersionScheme extends Object
Represents the version scheme used by a Debian package. To parse a version string, call the parseVersion(String) method. To parse a version constraint expression, call the parseConstraint(String) method.
  • Method Details

    • parseVersion

      public static DebVersion parseVersion(String version) throws VersionParsingException
      Parse a Debian package version string. Debian packages are described in the Debian Policy Manual. The format of the package version is defined in section 5.6.12 of that manual. A Debian package version has the following format:
           [epoch:]upstream_version[-debian_revision]
       
      Refer to the policy manual for details on each field. The following are examples of valid Debian package versions:
       22.07.5-2ubuntu1.5
       2.3.1-1
       3.2.2
       0.24
       1.0.126+nmu1ubuntu0.7
       5:27.3.1-1~ubuntu.22.04~jammy
       9.55.0~dfsg1-0ubuntu5.13
       
      Parameters:
      version - Debian package version to parse
      Returns:
      Version object corresponding to the specified version string.
      Throws:
      VersionParsingException - if there was a problem parsing the version
    • parseConstraint

      public static VersionConstraint parseConstraint(String rangeString) throws VersionParsingException
      Parses a Debian package version constraint. The Debian package manager does not define or handle version ranges. However, tools such as Puppet allow version ranges to be specified for package selection. The <, >, <=, >=, and = operators are supported. The following are examples of valid version constraints:
       3
       =3
       <3
       >3 <=5
       >=1.0-1 <2.0-1
       
      Note that 3 and =3 are equivalent.
      Parameters:
      rangeString - Version constraint to parse
      Returns:
      Version constraint object corresponding to the specified constraint.
      Throws:
      VersionParsingException - if there is a problem parsing the constraint