- Cleanup unused functions,
- Implement __getSupportedFlavours() - Auto detect the flavour of the current kernel module in getKernelVersion
This commit is contained in:
@@ -28,7 +28,6 @@ import pisi.actionsapi.autotools as autotools
|
|||||||
import pisi.actionsapi.pisitools as pisitools
|
import pisi.actionsapi.pisitools as pisitools
|
||||||
import pisi.actionsapi.shelltools as shelltools
|
import pisi.actionsapi.shelltools as shelltools
|
||||||
|
|
||||||
DEFAULT_FLAVOURS = ["pae"]
|
|
||||||
|
|
||||||
class ConfigureError(pisi.actionsapi.Error):
|
class ConfigureError(pisi.actionsapi.Error):
|
||||||
def __init__(self, value=''):
|
def __init__(self, value=''):
|
||||||
@@ -39,28 +38,8 @@ class ConfigureError(pisi.actionsapi.Error):
|
|||||||
# Internal helpers
|
# Internal helpers
|
||||||
|
|
||||||
def __getAllSupportedFlavours():
|
def __getAllSupportedFlavours():
|
||||||
pass
|
if os.path.exists("/etc/kernel"):
|
||||||
|
return os.listdir("/etc/kernel")
|
||||||
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
|
|
||||||
#####
|
|
||||||
|
|
||||||
def setModuleWorkDIR():
|
|
||||||
if get.srcNAME().startswith("module-"):
|
|
||||||
globals()['WorkDir'] = __get_workdir_for_module(get.srcNAME())
|
|
||||||
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# Other helpers #
|
# Other helpers #
|
||||||
@@ -75,6 +54,13 @@ def __getFlavour():
|
|||||||
|
|
||||||
return flavour
|
return flavour
|
||||||
|
|
||||||
|
def __getModuleFlavour():
|
||||||
|
for fl in [_f for _f in __getAllSupportedFlavours() if "-" in _f]:
|
||||||
|
if fl.split("-")[1] == get.srcNAME().split("-")[1]:
|
||||||
|
return fl
|
||||||
|
|
||||||
|
return "kernel"
|
||||||
|
|
||||||
def __getSuffix():
|
def __getSuffix():
|
||||||
# Set suffix, e.g. "2.6.30_rc7-119"
|
# Set suffix, e.g. "2.6.30_rc7-119"
|
||||||
suffix = "%s-%s" % (get.srcVERSION(), get.srcRELEASE())
|
suffix = "%s-%s" % (get.srcVERSION(), get.srcRELEASE())
|
||||||
@@ -112,11 +98,12 @@ def getKernelVersion(flavour=None):
|
|||||||
# if flavour==None, it will return the KVER in the /etc/kernel/kernel file else,
|
# if flavour==None, it will return the KVER in the /etc/kernel/kernel file else,
|
||||||
# /etc/kernel/<flavour>.
|
# /etc/kernel/<flavour>.
|
||||||
# If it fails, it will return the running kernel version.
|
# If it fails, it will return the running kernel version.
|
||||||
kverfile = "/etc/kernel"
|
|
||||||
if flavour:
|
# Try to detect module flavour
|
||||||
kverfile = os.path.join(kverfile, flavour)
|
if not flavour:
|
||||||
else:
|
flavour = __getModuleFlavour()
|
||||||
kverfile = os.path.join(kverfile, "kernel")
|
|
||||||
|
kverfile = os.path.join("/etc/kernel", flavour)
|
||||||
|
|
||||||
if os.path.exists(kverfile):
|
if os.path.exists(kverfile):
|
||||||
return open(kverfile, "r").read().strip()
|
return open(kverfile, "r").read().strip()
|
||||||
|
|||||||
Reference in New Issue
Block a user