299 lines
7.2 KiB
HTML
299 lines
7.2 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Dpkg::Version</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Dpkg::Version</H1>
|
|
Section: libdpkg-perl (3perl)<BR>Updated: 2020-03-23<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Dpkg::Version - handling and comparing dpkg-style version numbers
|
|
<A NAME="lbAC"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
The Dpkg::Version module provides pure-Perl routines to compare
|
|
dpkg-style version numbers (as used in Debian packages) and also
|
|
an object oriented interface overriding perl operators
|
|
to do the right thing when you compare Dpkg::Version object between
|
|
them.
|
|
<A NAME="lbAD"> </A>
|
|
<H2>METHODS</H2>
|
|
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">$v = Dpkg::Version->new($version, %opts)<DD>
|
|
|
|
|
|
|
|
|
|
Create a new Dpkg::Version object corresponding to the version indicated in
|
|
the string (scalar) <TT>$version</TT>. By default it will accepts any string
|
|
and consider it as a valid version. If you pass the option ``check => 1'',
|
|
it will return undef if the version is invalid (see version_check for
|
|
details).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
You can always call <TT>$v</TT>-><B>is_valid()</B> later on to verify that the version is
|
|
valid.
|
|
<DT id="2">boolean evaluation<DD>
|
|
|
|
|
|
When the Dpkg::Version object is used in a boolean evaluation (for example
|
|
in ``if ($v)'' or ``$v ? \''$v\`` : 'default''') it returns true if the version
|
|
stored is valid ($v-><B>is_valid()</B>) and false otherwise.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
<B>Notice</B>: Between dpkg 1.15.7.2 and 1.19.1 this overload used to return
|
|
<TT>$v</TT>-><B>as_string()</B> if <TT>$v</TT>-><B>is_valid()</B>, a breaking change in behavior that caused
|
|
``0'' versions to be evaluated as false. To catch any possibly intended code
|
|
that relied on those semantics, this overload will emit a warning with
|
|
category ``Dpkg::Version::semantic_change::overload::bool'' until dpkg 1.20.x.
|
|
Once fixed, or for already valid code the warning can be quiesced with
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
no if $Dpkg::Version::VERSION ge '1.02',
|
|
warnings => qw(Dpkg::Version::semantic_change::overload::bool);
|
|
|
|
</PRE>
|
|
|
|
|
|
|
|
|
|
<P>
|
|
|
|
|
|
added after the <TT>"use Dpkg::Version"</TT>.
|
|
<DT id="3">$v-><B>is_valid()</B><DD>
|
|
|
|
|
|
|
|
|
|
Returns true if the version is valid, false otherwise.
|
|
<DT id="4">$v-><B>epoch()</B>, $v-><B>version()</B>, $v-><B>revision()</B><DD>
|
|
|
|
|
|
|
|
|
|
Returns the corresponding part of the full version string.
|
|
<DT id="5">$v-><B>is_native()</B><DD>
|
|
|
|
|
|
|
|
|
|
Returns true if the version is native, false if it has a revision.
|
|
<DT id="6">$v1 <=> $v2, $v1 < $v2, $v1 <= $v2, $v1 > $v2, $v1 >= $v2<DD>
|
|
|
|
|
|
|
|
|
|
Numerical comparison of various versions numbers. One of the two operands
|
|
needs to be a Dpkg::Version, the other one can be anything provided that
|
|
its string representation is a version number.
|
|
<DT id="7">"$v", $v-><B>as_string()</B>, $v->as_string(%options)<DD>
|
|
|
|
|
|
|
|
|
|
Accepts an optional option hash reference, affecting the string conversion.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Options:
|
|
<DL COMPACT><DT id="8"><DD>
|
|
<DL COMPACT>
|
|
<DT id="9">omit_epoch (defaults to 0)<DD>
|
|
|
|
|
|
Omit the epoch, if present, in the output string.
|
|
<DT id="10">omit_revision (defaults to 0)<DD>
|
|
|
|
|
|
Omit the revision, if present, in the output string.
|
|
</DL>
|
|
</DL>
|
|
|
|
<DL COMPACT><DT id="11"><DD>
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Returns the string representation of the version number.
|
|
</DL>
|
|
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>FUNCTIONS</H2>
|
|
|
|
|
|
|
|
All the functions are exported by default.
|
|
<DL COMPACT>
|
|
<DT id="12">version_compare($a, $b)<DD>
|
|
|
|
|
|
|
|
|
|
Returns -1 if <TT>$a</TT> is earlier than <TT>$b</TT>, 0 if they are equal and 1 if <TT>$a</TT>
|
|
is later than <TT>$b</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
If <TT>$a</TT> or <TT>$b</TT> are not valid version numbers, it dies with an error.
|
|
<DT id="13">version_compare_relation($a, $rel, $b)<DD>
|
|
|
|
|
|
|
|
|
|
Returns the result (0 or 1) of the given comparison operation. This
|
|
function is implemented on top of <B>version_compare()</B>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Allowed values for <TT>$rel</TT> are the exported constants <FONT SIZE="-1">REL_GT, REL_GE,
|
|
REL_EQ, REL_LE, REL_LT.</FONT> Use <B>version_normalize_relation()</B> if you
|
|
have an input string containing the operator.
|
|
<DT id="14">$rel = version_normalize_relation($rel_string)<DD>
|
|
|
|
|
|
|
|
|
|
Returns the normalized constant of the relation <TT>$rel</TT> (a value
|
|
among <FONT SIZE="-1">REL_GT, REL_GE, REL_EQ, REL_LE</FONT> and <FONT SIZE="-1">REL_LT</FONT>). Supported
|
|
relations names in input are: ``gt'', ``ge'', ``eq'', ``le'', ``lt'', ``>>'', ``>='',
|
|
``='', ``<='', ``<<''. ``>'' and ``<'' are also supported but should not be used as
|
|
they are obsolete aliases of ``>='' and ``<=''.
|
|
<DT id="15">version_compare_string($a, $b)<DD>
|
|
|
|
|
|
|
|
|
|
String comparison function used for comparing non-numerical parts of version
|
|
numbers. Returns -1 if <TT>$a</TT> is earlier than <TT>$b</TT>, 0 if they are equal and 1 if <TT>$a</TT>
|
|
is later than <TT>$b</TT>.
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The ``~'' character always sort lower than anything else. Digits sort lower
|
|
than non-digits. Among remaining characters alphabetic characters (A-Z, a-z)
|
|
sort lower than the other ones. Within each range, the <FONT SIZE="-1">ASCII</FONT> decimal value
|
|
of the character is used to sort between characters.
|
|
<DT id="16">version_compare_part($a, $b)<DD>
|
|
|
|
|
|
|
|
|
|
Compare two corresponding sub-parts of a version number (either upstream
|
|
version or debian revision).
|
|
|
|
|
|
<P>
|
|
|
|
|
|
Each parameter is split by <B>version_split_digits()</B> and resulting items
|
|
are compared together. As soon as a difference happens, it returns -1 if
|
|
<TT>$a</TT> is earlier than <TT>$b</TT>, 0 if they are equal and 1 if <TT>$a</TT> is later than <TT>$b</TT>.
|
|
<DT id="17">@items = version_split_digits($version)<DD>
|
|
|
|
|
|
|
|
|
|
Splits a string in items that are each entirely composed either
|
|
of digits or of non-digits. For instance for ``1.024~beta1+svn234'' it would
|
|
return (``1'', ``.'', ``024'', ``~beta'', ``1'', ``+svn'', ``234'').
|
|
<DT id="18">($ok, $msg) = version_check($version)<DD>
|
|
|
|
|
|
|
|
|
|
|
|
<DT id="19">$ok = version_check($version)<DD>
|
|
|
|
|
|
|
|
|
|
|
|
Checks the validity of <TT>$version</TT> as a version number. Returns 1 in <TT>$ok</TT>
|
|
if the version is valid, 0 otherwise. In the latter case, <TT>$msg</TT>
|
|
contains a description of the problem with the <TT>$version</TT> scalar.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>CHANGES</H2>
|
|
|
|
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Version 1.02 (dpkg 1.19.1)</H3>
|
|
|
|
|
|
|
|
Semantic change: bool evaluation semantics restored to their original behavior.
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Version 1.01 (dpkg 1.17.0)</H3>
|
|
|
|
|
|
|
|
New argument: Accept an options argument in <TT>$v</TT>-><B>as_string()</B>.
|
|
<P>
|
|
|
|
New method: <TT>$v</TT>-><B>is_native()</B>.
|
|
<A NAME="lbAI"> </A>
|
|
<H3>Version 1.00 (dpkg 1.15.6)</H3>
|
|
|
|
|
|
|
|
Mark the module as public.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="20"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="21"><A HREF="#lbAC">DESCRIPTION</A><DD>
|
|
<DT id="22"><A HREF="#lbAD">METHODS</A><DD>
|
|
<DT id="23"><A HREF="#lbAE">FUNCTIONS</A><DD>
|
|
<DT id="24"><A HREF="#lbAF">CHANGES</A><DD>
|
|
<DL>
|
|
<DT id="25"><A HREF="#lbAG">Version 1.02 (dpkg 1.19.1)</A><DD>
|
|
<DT id="26"><A HREF="#lbAH">Version 1.01 (dpkg 1.17.0)</A><DD>
|
|
<DT id="27"><A HREF="#lbAI">Version 1.00 (dpkg 1.15.6)</A><DD>
|
|
</DL>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:39 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|