import os
import xml.sax.saxutils
-import util
-
+import pakfire.util as util
from pakfire.i18n import _
-from pakfire.util import make_progress
-
class Package(object):
def __init__(self, pakfire, repo=None):
self.pakfire = pakfire
if not self.name == other.name:
return cmp(self.name, other.name)
- ret = util.version_compare(self.version_tuple, other.version_tuple)
+ ret = util.version_compare(self.pakfire.pool,
+ self.friendly_version, other.friendly_version)
# XXX this is to move packages that have been built a while ago and
# do not have all the meta information that they won't be evaluated
return int(epoch)
- @property
- def version_tuple(self):
- """
- Returns a tuple like (epoch, version, release) that can
- be used to compare versions of packages.
- """
- return (self.epoch, self.version, self.release)
-
@property
def arch(self):
raise NotImplementedError
import tempfile
import xattr
-import util
-
import pakfire.util as util
import pakfire.compress as compress
from pakfire.errors import FileError
import zlib
import pakfire.compress
+import pakfire.util as util
from pakfire.util import rm
-import util
from pakfire.constants import *
from pakfire.i18n import _
+++ /dev/null
-#!/usr/bin/python
-
-from __future__ import division
-
-import hashlib
-import re
-
-from pakfire.constants import *
-
-def version_compare_epoch(e1, e2):
- # If either e1 or e2 is None, we cannot say anything
- if None in (e1, e2):
- return 0
-
- return cmp(e1, e2)
-
-def version_compare_version(v1, v2):
- return cmp(v1, v2)
-
-def version_compare_release(r1, r2):
- # If either e1 or e2 is None, we cannot say anything
- if None in (r1, r2):
- return 0
-
- d1, d2 = None, None
-
- if "." in r1:
- r1, d1 = r1.split(".", 1)
-
- if "." in r2:
- r2, d2 = r2.split(".", 1)
-
- # Compare the distribution tag at first.
- if d1 and d2:
- ret = cmp(d1, d2)
-
- if not ret == 0:
- return ret
-
- r1 = int(r1)
- r2 = int(r2)
-
- return cmp(r1, r2)
-
-def version_compare((e1, v1, r1), (e2, v2, r2)):
- ret = version_compare_epoch(e1, e2)
- if not ret == 0:
- return ret
-
- ret = version_compare_version(v1, v2)
- if not ret == 0:
- return ret
-
- return version_compare_release(r1, r2)
-
-def text_wrap(s, length=65):
- t = []
- s = s.split()
-
- l = []
- for word in s:
- l.append(word)
-
- if len(" ".join(l)) >= length:
- t.append(l)
- l = []
-
- if l:
- t.append(l)
-
- return [" ".join(l) for l in t]
-
-def format_size(s):
- sign = 1
-
- # If s is negative, we save the sign and run the calculation with the
- # absolute value of s.
- if s < 0:
- sign = -1
- s = -1 * s
-
- units = (" ", "k", "M", "G", "T")
- unit = 0
-
- while s >= 1024 and unit < len(units):
- s /= 1024
- unit += 1
-
- return "%d %s" % (int(s) * sign, units[unit])
-
-def format_time(s):
- return "%02d:%02d" % (s // 60, s % 60)
-
-def format_speed(s):
- return "%sB/s" % format_size(s)
-
-def calc_hash1(filename=None, data=None):
- h = hashlib.sha1()
-
- if filename:
- f = open(filename)
- buf = f.read(BUFFER_SIZE)
- while buf:
- h.update(buf)
- buf = f.read(BUFFER_SIZE)
-
- f.close()
-
- elif data:
- h.update(data)
-
- return h.hexdigest()
-
-def parse_pkg_expr(s):
- # Possible formats:
- # gcc=4.0.0
- # gcc=4.0.0-1
- # gcc=4.0.0-1.ip3
- # gcc=0:4.0.0-1
- # gcc=0:4.0.0-1.ip3
- # gcc>=...
- # gcc>...
- # gcc<...
- # gcc<=...
-
- (name, exp, epoch, version, release) = (None, None, None, None, None)
-
- m = re.match(r"([A-Za-z0-9\-\+]+)(=|\<|\>|\>=|\<=)([0-9]+\:)?([0-9A-Za-z\.]+)-?([0-9]+\.?[a-z0-9]+|[0-9]+)?", s)
-
- if m:
- (name, exp, epoch, version, release) = m.groups()
-
- # Remove : from epoch and convert to int
- if epoch:
- epoch = epoch.replace(":", "")
- epoch = int(epoch)
-
- return (exp, name, epoch, version, release)
-
-def test_parse_pkg_expr():
- strings = (
- "gcc=4.0.0",
- "gcc=4.0.0-1",
- "gcc=4.0.0-1.ip3",
- "gcc=0:4.0.0-1",
- "gcc=0:4.0.0-1.ip3",
- "gcc>=4.0.0-1",
- "gcc>4.0.0-1",
- "gcc<4.0.0-1",
- "gcc<=4.0.0-1",
- "openssl-devel>=1.0.0d-2",
- )
-
- for s in strings:
- print s, parse_pkg_expr(s)
-
-def parse_virtual_expr(s):
- # pkgconfig(bla)=1.2.3
-
- (type, name, exp, version) = (None, None, None, None)
-
- m = re.match(r"^([A-Za-z0-9]+)\(([A-Za-z0-9\.\-\+:]+)\)?(=|\<|\>|\>=|\<=)?([A-Za-z0-9\.\-]+)?", s)
-
- if m:
- (type, name, exp, version) = m.groups()
-
- return (type, exp, name, version)
-
-def test_parse_virtual_expr():
- strings = (
- "pkgconfig(libxml-2.0)",
- "pkgconfig(libxml-2.0)=1.2.3",
- "pkgconfig(libxml-2.0)>=1.2.3",
- )
-
- for s in strings:
- print s, parse_virtual_expr(s)
-
-if __name__ == "__main__":
- test_parse_pkg_expr()
- test_parse_virtual_expr()
#!/usr/bin/python
+from __future__ import division
+
import fcntl
+import hashlib
import os
import progressbar
import random
import termios
import time
-from errors import Error
-from packages.util import calc_hash1, format_size, format_speed, format_time
+from constants import *
from i18n import _
+# Import binary version of version_compare
+from _pakfire import version_compare
+
def cli_is_interactive():
"""
Say weather a shell is interactive or not.
cr = (25, 80)
return int(cr[1]), int(cr[0])
+
+def format_size(s):
+ sign = 1
+
+ # If s is negative, we save the sign and run the calculation with the
+ # absolute value of s.
+ if s < 0:
+ sign = -1
+ s = -1 * s
+
+ units = (" ", "k", "M", "G", "T")
+ unit = 0
+
+ while s >= 1024 and unit < len(units):
+ s /= 1024
+ unit += 1
+
+ return "%d %s" % (int(s) * sign, units[unit])
+
+def format_time(s):
+ return "%02d:%02d" % (s // 60, s % 60)
+
+def format_speed(s):
+ return "%sB/s" % format_size(s)
+
+def calc_hash1(filename=None, data=None):
+ h = hashlib.sha1()
+
+ if filename:
+ f = open(filename)
+ buf = f.read(BUFFER_SIZE)
+ while buf:
+ h.update(buf)
+ buf = f.read(BUFFER_SIZE)
+
+ f.close()
+
+ elif data:
+ h.update(data)
+
+ return h.hexdigest()
+
+def text_wrap(s, length=65):
+ t = []
+ s = s.split()
+
+ l = []
+ for word in s:
+ l.append(word)
+
+ if len(" ".join(l)) >= length:
+ t.append(l)
+ l = []
+
+ if l:
+ t.append(l)
+
+ return [" ".join(l) for l in t]
pakfire/packages/packager.py
pakfire/packages/solv.py
pakfire/packages/source.py
-pakfire/packages/util.py
pakfire/packages/virtual.py
pakfire/repository/base.py
pakfire/repository/cache.py
src/step.c
src/test.py
src/transaction.c
+src/util.c
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-07-31 19:32+0000\n"
+"POT-Creation-Date: 2011-08-03 13:36+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "One or more dependencies could not been resolved."
msgstr ""
-#: ../pakfire/packages/base.py:72
+#: ../pakfire/packages/base.py:70
msgid "Name"
msgstr ""
-#: ../pakfire/packages/base.py:73 ../pakfire/transaction.py:164
+#: ../pakfire/packages/base.py:71 ../pakfire/transaction.py:164
msgid "Arch"
msgstr ""
-#: ../pakfire/packages/base.py:74 ../pakfire/transaction.py:164
+#: ../pakfire/packages/base.py:72 ../pakfire/transaction.py:164
msgid "Version"
msgstr ""
-#: ../pakfire/packages/base.py:75
+#: ../pakfire/packages/base.py:73
msgid "Release"
msgstr ""
-#: ../pakfire/packages/base.py:76 ../pakfire/transaction.py:165
+#: ../pakfire/packages/base.py:74 ../pakfire/transaction.py:165
msgid "Size"
msgstr ""
-#: ../pakfire/packages/base.py:77
+#: ../pakfire/packages/base.py:75
msgid "Repo"
msgstr ""
-#: ../pakfire/packages/base.py:78
+#: ../pakfire/packages/base.py:76
msgid "Summary"
msgstr ""
-#: ../pakfire/packages/base.py:79
+#: ../pakfire/packages/base.py:77
msgid "Groups"
msgstr ""
-#: ../pakfire/packages/base.py:80
+#: ../pakfire/packages/base.py:78
msgid "URL"
msgstr ""
-#: ../pakfire/packages/base.py:81
+#: ../pakfire/packages/base.py:79
msgid "License"
msgstr ""
-#: ../pakfire/packages/base.py:84
+#: ../pakfire/packages/base.py:82
msgid "Description"
msgstr ""
-#: ../pakfire/packages/base.py:90
+#: ../pakfire/packages/base.py:88
msgid "UUID"
msgstr ""
-#: ../pakfire/packages/base.py:91
+#: ../pakfire/packages/base.py:89
msgid "Build ID"
msgstr ""
-#: ../pakfire/packages/base.py:92
+#: ../pakfire/packages/base.py:90
msgid "Build date"
msgstr ""
-#: ../pakfire/packages/base.py:93
+#: ../pakfire/packages/base.py:91
msgid "Build host"
msgstr ""
-#: ../pakfire/packages/base.py:95
+#: ../pakfire/packages/base.py:93
msgid "Provides"
msgstr ""
-#: ../pakfire/packages/base.py:100
+#: ../pakfire/packages/base.py:98
msgid "Requires"
msgstr ""
msgid "Running transaction"
msgstr ""
-#: ../pakfire/util.py:39
+#: ../pakfire/util.py:44
#, python-format
msgid "%s [y/N]"
msgstr ""
#include "solver.h"
#include "step.h"
#include "transaction.h"
+#include "util.h"
static PyMethodDef pakfireModuleMethods[] = {
+ {"version_compare", (PyCFunction)version_compare, METH_VARARGS, NULL},
{ NULL, NULL, 0, NULL }
};
--- /dev/null
+
+#include <Python.h>
+
+#include "util.h"
+
+PyObject *version_compare(PyObject *self, PyObject *args) {
+ Pool *pool;
+ const char *evr1, *evr2;
+
+ if (!PyArg_ParseTuple(args, "Oss", &pool, &evr1, &evr2)) {
+ /* XXX raise exception */
+ return NULL;
+ }
+
+ int ret = pool_evrcmp_str(pool, evr1, evr2, EVRCMP_COMPARE);
+
+ return Py_BuildValue("i", ret);
+}
--- /dev/null
+
+#ifndef PAKFIRE_UTIL_H
+#define PAKFIRE_UTIL_H
+
+#include <Python.h>
+
+#include <satsolver/evr.h>
+
+extern PyObject *version_compare(PyObject *self, PyObject *args);
+
+#endif