Hello,
  so this is what I've done to my apt-move to get openoffice (and couple of
other packages it seems...) right.  During apt-move run on my box cmpversion is
invoked about 12000 times - fortunately 11800 of them is for matching
source & target, so for them we can take shortcut of not executing dpkg.
For remaining 200 we have...

  Unfortunately I was not able to find apt's equivalent for dpkg 
--compare-versions,
so probably patch is not OK for upstream, as it won't work on RPM based apt.
But it might be fine for Debian/Ubuntu.

  I'm not awk expert, so I just hope that there is no special quoting needed
around a/b arguments to dpkg.  If there is, then I'm sorry, but I have no
clue how it should look like.
                                                Thanks,
                                                        Petr Vandrovec


diff -urN apt-move-4.2.26.post-sign/apt-move apt-move-4.2.26/apt-move
--- apt-move-4.2.26.post-sign/apt-move  2006-11-05 15:11:05.000000000 -0800
+++ apt-move-4.2.26/apt-move    2006-11-05 19:04:15.000000000 -0800
@@ -72,7 +72,7 @@
 FETCH=/usr/lib/apt-move/fetch  # crappy replacement for apt-get
 SCRIPTS=$APTMOVE_SCRIPTS
 : ${SCRIPTS:=/usr/share/apt-move}
-awk="awk -f $SCRIPTS/cmpbignum.awk -f $SCRIPTS/cmpversion.awk -f"
+awk="awk -f $SCRIPTS/cmpversion.awk -f"
 awk="$awk $SCRIPTS/getdist.awk -f"
 MOVE3=$SCRIPTS/move3
 MOVE4="$awk $SCRIPTS/move4"
diff -urN apt-move-4.2.26.post-sign/cmpbignum.awk apt-move-4.2.26/cmpbignum.awk
--- apt-move-4.2.26.post-sign/cmpbignum.awk     2002-01-25 00:47:24.000000000 
-0800
+++ apt-move-4.2.26/cmpbignum.awk       1969-12-31 16:00:00.000000000 -0800
@@ -1,35 +0,0 @@
-# cmpbignum --- compare two arbitrarily long integers.
-#      The function returns:
-#              < 0 if a < b
-#              == 0 if a == b
-#              > 0 if a > b
-#      The idea came from Anthony Towns in http://bugs.debian.org/92839.
-#
-# Copyright (c) 2001 Herbert Xu <[EMAIL PROTECTED]>
-# $Id: cmpbignum.awk,v 1.1 2002/01/25 08:47:24 herbert Exp $
-
-function cmpbignum(a, b, i, j, k, l, d) {
-       i = match(a, /[^0]/)
-       j = match(b, /[^0]/)
-       if (!i || !j) {
-               return !!i - !!j
-       }
-
-       k = length(a)
-       l = length(b)
-       d = (k - i) - (l - j)
-       if (d) {
-               return d
-       }
-
-       do {
-               d = substr(a, i, 1) - substr(b, j, 1)
-               if (d) {
-                       return d
-               }
-               i++
-               j++
-       } while (i <= k)
-
-       return 0
-}
diff -urN apt-move-4.2.26.post-sign/cmpversion.awk 
apt-move-4.2.26/cmpversion.awk
--- apt-move-4.2.26.post-sign/cmpversion.awk    2002-10-28 23:59:41.000000000 
-0800
+++ apt-move-4.2.26/cmpversion.awk      2006-11-05 19:08:11.000000000 -0800
@@ -1,128 +1,20 @@
 # cmpversion --- compare versions of Debian packages.
-#      The function returns:
-#              < 0 if a < b
-#              == 0 if a == b
-#              > 0 if a > b
-#      This function depends on cmpbignum.
+#      The function compares two versions and returns TRUE if
+#              a < b and operator is ne, lt, or le.
+#              a == b and operator is eq, le, or ge.
+#              a > b and operator is ne, gt, or ge.
 #
 # Copyright (c) 2001 Herbert Xu <[EMAIL PROTECTED]>
 # $Id: cmpversion.awk,v 1.2 2002/10/29 07:59:41 herbert Exp $
 
-function _cmpversion_segment(a, b, i, j, k, l, m, n, p, q, d) {
-       k = length(a)
-       l = length(b)
-
-       while (k > 0 && l > 0) {
-               i = match(a, /[0-9]/)
-               if (!i) {
-                       i = k + 1
-               }
-               j = match(b, /[0-9]/)
-               if (!j) {
-                       j = l + 1
-               }
-
-               m = 1
-               n = 1
-               while (m < i && n < j) {
-                       p = substr(a, m, 1)
-                       q = substr(b, n, 1)
-                       d = (q ~ /[A-Za-z]/) - (p ~ /[A-Za-z]/)
-                       if (d) {
-                               return d
-                       }
-                       if (p != q) {
-                               return p < q ? -1 : 1
-                       }
-                       m++
-                       n++
-               }
-
-               d = (m < i) - (n < j)
-               if (d) {
-                       return d
-               }
-
-               a = substr(a, i)
-               b = substr(b, j)
-               k -= i - 1
-               l -= j - 1
-               if (k <= 0 || l <= 0) {
-                       break
-               }
-
-               i = match(a, /[^0-9]/)
-               if (!i) {
-                       i = k + 1
-               }
-               j = match(b, /[^0-9]/)
-               if (!j) {
-                       j = l + 1
-               }
-
-               d = cmpbignum(substr(a, 1, i - 1), substr(b, 1, j - 1))
-               if (d) {
-                       return d
-               }
-
-               a = substr(a, i)
-               b = substr(b, j)
-               k -= i - 1
-               l -= j - 1
-       }
-
-       return (k > 0) - (l > 0)
-}
-
-function cmpversion(a, b, i, j, k, l, d) {
+function cmpversion(a, o, b) {
        if (a == b) {
-               return 0
+               return o == "eq" || o == "le" || o == "ge"
        } else if (a == "-") {
-               return 1
+               return o == "ne" || o == "gt" || o == "ge"
        } else if (b == "-") {
-               return -1
-       }
-
-       i = index(a, ":")
-       j = index(b, ":")
-       if (i > 1 || j > 1) {
-               d = (i > 1) - (j > 1)
-               if (d) {
-                       return d
-               }
-               d = cmpbignum(substr(a, 1, i - 1), substr(b, 1, j - 1))
-               if (d) {
-                       return d
-               }
-               i++
-               j++
-       } else {
-               i = 1
-               j = 1
-       }
-
-       a = substr(a, i)
-       b = substr(b, j)
-       k = match(a, /.*-/)
-       if (k) {
-               k = RLENGTH - 1
-               i = k + 2
-       } else {
-               k = length(a)
-               i = k + 1
-       }
-       l = match(b, /.*-/)
-       if (l) {
-               l = RLENGTH - 1
-               j = l + 2
+               return o == "ne" || o == "lt" || o == "le"
        } else {
-               l = length(b)
-               j = l + 1
-       }
-
-       d = _cmpversion_segment(substr(a, 1, k), substr(b, 1, l))
-       if (d) {
-               return d
+               return system("dpkg --compare-versions " a " " o " " b) == 0
        }
-       return _cmpversion_segment(substr(a, i), substr(b, j))
 }
diff -urN apt-move-4.2.26.post-sign/get2 apt-move-4.2.26/get2
--- apt-move-4.2.26.post-sign/get2      2002-10-11 18:21:05.000000000 -0700
+++ apt-move-4.2.26/get2        2006-11-05 18:48:45.000000000 -0800
@@ -11,7 +11,7 @@
 }
 
 {
-       if (cmpversion($NF, bestver) > 0) {
+       if (cmpversion($NF, "gt", bestver)) {
                bestline = $0
                bestver = $NF
        }
diff -urN apt-move-4.2.26.post-sign/move5 apt-move-4.2.26/move5
--- apt-move-4.2.26.post-sign/move5     2002-10-07 02:39:07.000000000 -0700
+++ apt-move-4.2.26/move5       2006-11-05 18:49:22.000000000 -0800
@@ -74,10 +74,10 @@
                        dist = sdist[i]
                        break
                }
-               if (cmpversion(sver[i], ver) < 0) {
+               if (cmpversion(sver[i], "lt", ver)) {
                        continue
                }
-               if (low == "" || cmpversion(sver[i], low) < 0) {
+               if (low == "" || cmpversion(sver[i], "lt", low)) {
                        low = sver[i]
                        dist = sdist[i]
                }
diff -urN apt-move-4.2.26.post-sign/move6 apt-move-4.2.26/move6
--- apt-move-4.2.26.post-sign/move6     2002-10-18 21:20:33.000000000 -0700
+++ apt-move-4.2.26/move6       2006-11-05 18:49:44.000000000 -0800
@@ -49,7 +49,7 @@
 }
 
 function check() {
-       if (((rel, arch) in best) && cmpversion(best[rel, arch], ver) > 0) {
+       if (((rel, arch) in best) && cmpversion(best[rel, arch], "gt", ver)) {
                return
        }
        best[rel, arch] = ver
@@ -148,7 +148,7 @@
                if (arch != "binary-all" && !((rel, arch) in relarches)) {
                        continue
                }
-               if (cmpversion(ver, bver) > 0) {
+               if (cmpversion(ver, "gt", bver)) {
                        continue
                }
                check()
diff -urN apt-move-4.2.26.post-sign/move7 apt-move-4.2.26/move7
--- apt-move-4.2.26.post-sign/move7     2002-10-07 02:39:07.000000000 -0700
+++ apt-move-4.2.26/move7       2006-11-05 18:50:05.000000000 -0800
@@ -91,11 +91,11 @@
        prevname = name
 }
 
-!eof && curname == name && cmpversion(ver, curver) <= 0 {
+!eof && curname == name && cmpversion(ver, "le", curver) {
        next
 }
 
-best == "" || cmpversion(ver, best) > 0 {
+best == "" || cmpversion(ver, "gt", best) {
        best = ver
        bestlink = link
        bestfile = file


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to