summaryrefslogtreecommitdiff
path: root/cron-jobs/check_archlinux
diff options
context:
space:
mode:
Diffstat (limited to 'cron-jobs/check_archlinux')
-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.py258
-rw-r--r--cron-jobs/check_archlinux/setup.py10
5 files changed, 136 insertions, 180 deletions
diff --git a/cron-jobs/check_archlinux/README b/cron-jobs/check_archlinux/README
deleted file mode 100644
index 8f178dc..0000000
--- a/cron-jobs/check_archlinux/README
+++ /dev/null
@@ -1,8 +0,0 @@
-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
-$ ./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..d233bf6 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:
@@ -364,131 +377,132 @@ def print_usage():
print " ./check_packages.py --abs-tree=/var/abs --repos=community --arch=i686"
print ""
-## Default path to the abs root directory
-absroots = ["/var/abs"]
-## Default list of repos to check
-repos = ['core', 'extra']
-## Default arch
-arch = "i686"
-## Default repodir
-repodir = "/srv/ftp"
-
-try:
- opts, args = getopt.getopt(sys.argv[1:], "", ["abs-tree=", "repos=",
- "arch=", "repo-dir="])
-except getopt.GetoptError:
- print_usage()
- sys.exit()
-if opts != []:
- for o, a in opts:
- if o in ("--abs-tree"):
- absroots = a.split(',')
- elif o in ("--repos"):
- repos = a.split(",")
- elif o in ("--arch"):
- arch = a
- elif o in ("--repo-dir"):
- repodir = a
- else:
- print_usage()
- sys.exit()
- if args != []:
- print_usage()
+if __name__ == "__main__":
+ ## Default path to the abs root directory
+ absroots = ["/var/abs"]
+ ## Default list of repos to check
+ repos = ['core', 'extra']
+ ## Default arch
+ arch = "i686"
+ ## Default repodir
+ repodir = "/srv/ftp"
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "", ["abs-tree=", "repos=",
+ "arch=", "repo-dir="])
+ except getopt.GetoptError:
+ print_usage()
+ sys.exit()
+ if opts != []:
+ for o, a in opts:
+ if o in ("--abs-tree"):
+ absroots = a.split(',')
+ elif o in ("--repos"):
+ repos = a.split(",")
+ elif o in ("--arch"):
+ arch = a
+ elif o in ("--repo-dir"):
+ repodir = a
+ else:
+ print_usage()
+ sys.exit()
+ if args != []:
+ print_usage()
+ sys.exit()
+
+ for absroot in absroots:
+ if not os.path.isdir(absroot):
+ print "Error : the abs tree " + absroot + " does not exist"
sys.exit()
+ for repo in repos:
+ repopath = absroot + "/" + repo
+ if not os.path.isdir(repopath):
+ print("Warning : the repository " + repo + " does not exist in " + absroot)
-for absroot in absroots:
- if not os.path.isdir(absroot):
- print "Error : the abs tree " + absroot + " does not exist"
+ if not os.path.isdir(repodir):
+ print "Error: the repository directory %s does not exist" % repodir
sys.exit()
for repo in repos:
- repopath = absroot + "/" + repo
- if not os.path.isdir(repopath):
- print("Warning : the repository " + repo + " does not exist in " + absroot)
-
-if not os.path.isdir(repodir):
- print "Error: the repository directory %s does not exist" % repodir
- sys.exit()
-for repo in repos:
- path = os.path.join(repodir,repo,'os',arch,repo + DBEXT)
- if not os.path.isfile(path):
- print "Error : repo DB %s : File not found" % path
- sys.exit()
- if not tarfile.is_tarfile(path):
- print "Error : Cant open repo DB %s, not a valid tar file" % path
- sys.exit()
-# repos which need to be loaded
-loadrepos = set([])
-for repo in repos:
- loadrepos = loadrepos | set(get_repo_hierarchy(repo))
+ path = os.path.join(repodir,repo,'os',arch,repo + DBEXT)
+ if not os.path.isfile(path):
+ print "Error : repo DB %s : File not found" % path
+ sys.exit()
+ if not tarfile.is_tarfile(path):
+ print "Error : Cant open repo DB %s, not a valid tar file" % path
+ sys.exit()
+ # repos which need to be loaded
+ loadrepos = set([])
+ for repo in repos:
+ loadrepos = loadrepos | set(get_repo_hierarchy(repo))
-print_heading("Integrity Check " + arch + " of " + ",".join(repos))
-print("\nPerforming integrity checks...")
+ print_heading("Integrity Check " + arch + " of " + ",".join(repos))
+ print("\nPerforming integrity checks...")
-print("==> parsing pkgbuilds")
-parse_pkgbuilds(loadrepos,arch)
+ print("==> parsing pkgbuilds")
+ parse_pkgbuilds(loadrepos,arch)
-# fill provisions
-for name,pkg in packages.iteritems():
- for prov in pkg.provides:
- provname=prov.split("=")[0]
- if provname not in provisions:
- provisions[provname] = []
- provisions[provname].append(pkg)
-
-# fill repopkgs
-for name,pkg in packages.iteritems():
- if pkg.repo in repos:
- repopkgs[name] = pkg
-
-print("==> parsing db files")
-dbpkgs = parse_dbs(repos,arch)
-
-print("==> checking mismatches")
-for name,pkg in repopkgs.iteritems():
- pkgdirname = pkg.path.split("/")[-1]
- if name != pkgdirname and pkg.base != pkgdirname:
- mismatches.append(name + " vs. " + pkg.path)
-
-print("==> checking archs")
-for name,pkg in repopkgs.iteritems():
- archs = verify_archs(name,pkg.repo,pkg.archs)
- invalid_archs.extend(archs)
-
-deph,makedeph = [],[]
-
-print("==> checking dependencies")
-for name,pkg in repopkgs.iteritems():
- (deps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.deps)
- pkgdeps[pkg] = deps
- missing_deps.extend(missdeps)
- deph.extend(hierarchy)
-
-print("==> checking makedepends")
-for name,pkg in repopkgs.iteritems():
- (makedeps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.makedeps)
- makepkgdeps[pkg] = makedeps
- missing_makedeps.extend(missdeps)
- makedeph.extend(hierarchy)
-
-print("==> checking hierarchy")
-dep_hierarchy = check_hierarchy(deph)
-makedep_hierarchy = check_hierarchy(makedeph)
-
-print("==> checking for circular dependencies")
-# make sure pkgdeps is filled for every package
-for name,pkg in packages.iteritems():
- if pkg not in pkgdeps:
- (deps,missdeps,_) = verify_deps(name,pkg.repo,pkg.deps)
+ # fill provisions
+ for name,pkg in packages.iteritems():
+ for prov in pkg.provides:
+ provname=prov.split("=")[0]
+ if provname not in provisions:
+ provisions[provname] = []
+ provisions[provname].append(pkg)
+
+ # fill repopkgs
+ for name,pkg in packages.iteritems():
+ if pkg.repo in repos:
+ repopkgs[name] = pkg
+
+ print("==> parsing db files")
+ dbpkgs = parse_dbs(repos,arch)
+
+ print("==> checking mismatches")
+ for name,pkg in repopkgs.iteritems():
+ pkgdirname = pkg.path.split("/")[-1]
+ if name != pkgdirname and pkg.base != pkgdirname:
+ mismatches.append(name + " vs. " + pkg.path)
+
+ print("==> checking archs")
+ for name,pkg in repopkgs.iteritems():
+ archs = verify_archs(name,pkg.repo,pkg.archs)
+ invalid_archs.extend(archs)
+
+ deph,makedeph = [],[]
+
+ print("==> checking dependencies")
+ for name,pkg in repopkgs.iteritems():
+ (deps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.deps)
pkgdeps[pkg] = deps
-find_scc(repopkgs.values())
-
-print("==> checking for differences between db files and pkgbuilds")
-for repo in repos:
- for pkg in dbpkgs[repo]:
- if not (pkg in repopkgs and repopkgs[pkg].repo == repo):
- dbonly.append("%s/%s" % (repo,pkg))
-for name,pkg in repopkgs.iteritems():
- if not name in dbpkgs[pkg.repo]:
- absonly.append("%s/%s" % (pkg.repo,name))
-
-print_results()
+ missing_deps.extend(missdeps)
+ deph.extend(hierarchy)
+
+ print("==> checking makedepends")
+ for name,pkg in repopkgs.iteritems():
+ (makedeps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.makedeps)
+ makepkgdeps[pkg] = makedeps
+ missing_makedeps.extend(missdeps)
+ makedeph.extend(hierarchy)
+
+ print("==> checking hierarchy")
+ dep_hierarchy = check_hierarchy(deph)
+ makedep_hierarchy = check_hierarchy(makedeph)
+
+ print("==> checking for circular dependencies")
+ # make sure pkgdeps is filled for every package
+ for name,pkg in packages.iteritems():
+ if pkg not in pkgdeps:
+ (deps,missdeps,_) = verify_deps(name,pkg.repo,pkg.deps)
+ pkgdeps[pkg] = deps
+ find_scc(repopkgs.values())
+
+ print("==> checking for differences between db files and pkgbuilds")
+ for repo in repos:
+ for pkg in dbpkgs[repo]:
+ if not (pkg in repopkgs and repopkgs[pkg].repo == repo):
+ dbonly.append("%s/%s" % (repo,pkg))
+ for name,pkg in repopkgs.iteritems():
+ if not name in dbpkgs[pkg.repo]:
+ absonly.append("%s/%s" % (pkg.repo,name))
+
+ print_results()
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])