From 1328abc5dea025402c1dd3f79d7f0807e6d3d717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 5 May 2009 09:36:03 +0000 Subject: [PATCH] Strip correctly the module prefix and flavour suffix from module packages and export the workdir into the global namespace. --- pisi/actionsapi/kerneltools.py | 43 ++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/pisi/actionsapi/kerneltools.py b/pisi/actionsapi/kerneltools.py index c8eadcea..f8532f79 100644 --- a/pisi/actionsapi/kerneltools.py +++ b/pisi/actionsapi/kerneltools.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2009, TUBITAK/UEKAE +# Copyright (C) 2009 TUBITAK/UEKAE # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -27,12 +27,47 @@ import pisi.actionsapi.autotools as autotools import pisi.actionsapi.pisitools as pisitools import pisi.actionsapi.shelltools as shelltools -# Set WorkDir for kernel modules, black magic :) +KERNELRC = "/etc/kernelrc" +DEFAULT_FLAVOURS = "pae" + +# Internal helpers + +def __getAllSupportedFlavours(): + def_flavours = DEFAULT_FLAVOURS.split(",") + + import ConfigParser + cp = ConfigParser.ConfigParser() + + if os.path.exists(KERNELRC) and cp.read(KERNELRC): + try: + return cp.get('general', 'flavours').strip('"') + except NoSectionError, NoOptionError: + return def_flavours + else: + return def_flavours + +def __get_workdir_for_module(mod): + mod = mod.split("module-")[1] + + # Now we have something like alsa-driver or alsa-driver-pae. We also have + # to strip a possible flavour name at the end.. + for f in __getAllSupportedFlavours(): + if mod.endswith("-%s" % f): + mod = mod.split("-%s" % f)[0] + break + + return "%s-%s" % (mod, get.srcVERSION()) + +##### +# Set WorkDir for kernel modules +##### if not globals().has_key("WorkDir") and get.srcNAME().startswith("module-"): - globals()['WorkDir'] = "%s-%s" % (get.srcNAME().split("module-")[1], get.srcVERSION()) + globals()['WorkDir'] = __get_workdir_for_module(get.srcNAME()) -# Internal helpers for versioning stuff +################# +# Other helpers # +################# def __getFlavour(): flavour = ""