summaryrefslogtreecommitdiffstats
path: root/cron-jobs
diff options
context:
space:
mode:
Diffstat (limited to 'cron-jobs')
-rw-r--r--cron-jobs/check_archlinux/README8
-rw-r--r--cron-jobs/check_archlinux/alpm.c40
-rwxr-xr-xcron-jobs/check_archlinux/alpm.sobin7057 -> 0 bytes
-rwxr-xr-xcron-jobs/check_archlinux/check_packages.py17
-rw-r--r--cron-jobs/check_archlinux/setup.py10
5 files changed, 16 insertions, 59 deletions
diff --git a/cron-jobs/check_archlinux/README b/cron-jobs/check_archlinux/README
index 8f178dc..03bb0e0 100644
--- a/cron-jobs/check_archlinux/README
+++ b/cron-jobs/check_archlinux/README
@@ -1,8 +1,2 @@
-1) Build the python module
-$ python2 setup.py build
-
-2) copy it back to the current working directory
-$ cp build/lib.*/alpm.* .
-
-3) run the script
+1) run the script
$ ./check_packages.py -h
diff --git a/cron-jobs/check_archlinux/alpm.c b/cron-jobs/check_archlinux/alpm.c
deleted file mode 100644
index 0b7cd2c..0000000
--- a/cron-jobs/check_archlinux/alpm.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <Python.h>
-#include <alpm.h>
-
-static PyObject *
-alpm_vercmp(PyObject *self, PyObject *args)
-{
- const char *v1, *v2;
- int ret;
-
- if (!PyArg_ParseTuple(args, "ss", &v1, &v2))
- return NULL;
- ret = alpm_pkg_vercmp(v1, v2);
- return Py_BuildValue("i", ret);
-}
-
-static PyMethodDef AlpmMethods[] = {
- {"vercmp", alpm_vercmp, METH_VARARGS,
- "Execute vercmp."},
- {NULL, NULL, 0, NULL} /* Sentinel */
-};
-
-PyMODINIT_FUNC
-initalpm(void)
-{
- (void) Py_InitModule("alpm", AlpmMethods);
-}
-
-int
-main(int argc, char *argv[])
-{
- /* Pass argv[0] to the Python interpreter */
- Py_SetProgramName(argv[0]);
-
- /* Initialize the Python interpreter. Required. */
- Py_Initialize();
-
- /* Add a static module */
- initalpm();
- return 0;
-}
diff --git a/cron-jobs/check_archlinux/alpm.so b/cron-jobs/check_archlinux/alpm.so
deleted file mode 100755
index 8944bbe..0000000
--- a/cron-jobs/check_archlinux/alpm.so
+++ /dev/null
Binary files differ
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:
diff --git a/cron-jobs/check_archlinux/setup.py b/cron-jobs/check_archlinux/setup.py
deleted file mode 100644
index b172752..0000000
--- a/cron-jobs/check_archlinux/setup.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from distutils.core import setup, Extension
-
-alpm = Extension('alpm',
- libraries = ['alpm'],
- sources = ['alpm.c'])
-
-setup (name = 'Alpm',
- version = '1.0',
- description = 'Alpm bindings',
- ext_modules = [alpm])