From 1be510f9529cb082f802408b472a77d074b394c0 Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Sun, 14 Apr 2013 13:46:12 +0000 Subject: Add zarb MLs html archives --- zarb-ml/mageia-dev/2012-February/012223.html | 138 +++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 zarb-ml/mageia-dev/2012-February/012223.html (limited to 'zarb-ml/mageia-dev/2012-February/012223.html') diff --git a/zarb-ml/mageia-dev/2012-February/012223.html b/zarb-ml/mageia-dev/2012-February/012223.html new file mode 100644 index 000000000..1dfdc23c0 --- /dev/null +++ b/zarb-ml/mageia-dev/2012-February/012223.html @@ -0,0 +1,138 @@ + + + + [Mageia-dev] [soft-commits] [3012] Add ability to increase the version number of a given package + + + + + + + + + +

[Mageia-dev] [soft-commits] [3012] Add ability to increase the version number of a given package

+ Thierry Vignaud + thierry.vignaud at gmail.com +
+ Wed Feb 22 18:13:12 CET 2012 +

+
+ +
On 22 February 2012 17:06,  <root at mageia.org> wrote:
+> Revision 3012 Author ovitters Date 2012-02-22 17:06:51 +0100 (Wed, 22 Feb
+> 2012)
+>
+> Log Message
+>
+> Add ability to increase the version number of a given package
+>
+> Command tries to be careful and does various checks (patches still apply,
+> etc)
+
+Too sad it doesn't support this:
+  %define rel 3
+  %define release %mkrel %rel
+(which is hard anyway and should be rare though it does exist among
+mga packages)
+
+> +def version_cmp(a, b):
+> +    """Compares two versions
+> +
+> +    Returns
+> +      -1 if a < b
+> +      0  if a == b
+> +      1  if a > b
+> +
+> +    Logic from Bugzilla::Install::Util::vers_cmp"""
+> +    A = re_version.findall(a.lstrip('0'))
+> +    B = re_version.findall(b.lstrip('0'))
+> +
+> +    while A and B:
+> +        a = A.pop(0)
+> +        b = B.pop(0)
+> +
+> +        if a == b:
+> +            continue
+> +        elif a == '-':
+> +            return -1
+> +        elif b == '-':
+> +            return 1
+> +        elif a == '.':
+> +            return -1
+> +        elif b == '.':
+> +            return 1
+> +        elif a.isdigit() and b.isdigit():
+> +            c = cmp(a, b) if (a.startswith('0') or b.startswith('0')) else
+> cmp(int(a, 10), int(b, 10))
+> +            if c:
+> +                return c
+> +        else:
+> +            c = cmp(a.upper(), b.upper())
+> +            if c:
+> +                return c
+> +
+> +    return cmp(len(A), len(B))
+
+Please do not reinvent the whell and do sg like this instead:
+
+import rpm
+
+def compare(t1, t2):
+   # t1 and t2 are tuples of (version, release)
+    v1, r1 = t1
+    v2, r2 = t2
+    return rpm.labelCompare(('1', v1, r1), ('1', v2, r2))
+
+ + + + + + + + + + + + + + + + + + + + + +
+

+ +
+More information about the Mageia-dev +mailing list
+ -- cgit v1.2.1