diff options
author | Rémy Oudompheng <remy@archlinux.org> | 2011-11-05 19:17:01 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-11-05 19:24:46 +0100 |
commit | ef69c002a69e5d7983554b68d41f26e06ad8fb7c (patch) | |
tree | bd51f3fe4d07607e88efc903076baa7eddcd8d93 /cron-jobs/check_archlinux/check_packages.py | |
parent | 3084db6f3c6678eeb27ba0d532db0007432bfed1 (diff) |
Use ctypes module to access alpm_pkg_vercmp() instead of the C module.
Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
Diffstat (limited to 'cron-jobs/check_archlinux/check_packages.py')
-rwxr-xr-x | cron-jobs/check_archlinux/check_packages.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/cron-jobs/check_archlinux/check_packages.py b/cron-jobs/check_archlinux/check_packages.py index 0a2b10e..06589ca 100755 --- a/cron-jobs/check_archlinux/check_packages.py +++ b/cron-jobs/check_archlinux/check_packages.py @@ -16,9 +16,12 @@ # a non-core package) # 8. Circular dependencies -import os,re,commands,getopt,sys,tarfile,alpm +import os,re,commands,getopt,sys,tarfile import pdb +import ctypes +_alpm = ctypes.cdll.LoadLibrary("libalpm.so") + DBEXT='.db.tar.gz' packages = {} # pkgname : PacmanPackage @@ -143,7 +146,17 @@ def splitprov(prov): return (name,version) def vercmp(v1,mod,v2): - res = alpm.vercmp(v1,v2) + """ + >>> vercmp("1.0", "<=", "2.0") + True + >>> vercmp("1:1.0", ">", "2.0") + True + >>> vercmp("1.0.2", ">=", "2.1.0") + False + """ + s1 = ctypes.c_char_p(v1) + s2 = ctypes.c_char_p(v2) + res = _alpm.alpm_pkg_vercmp(s1,s2) if res == 0: return (mod.find("=") > -1) elif res < 0: |