diff --git a/pisi/actionsapi/kerneltools.py b/pisi/actionsapi/kerneltools.py index faade3f1..ff405aaa 100644 --- a/pisi/actionsapi/kerneltools.py +++ b/pisi/actionsapi/kerneltools.py @@ -11,6 +11,7 @@ # Standard Python Modules import os +import re import gettext __trans = gettext.translation('pisi', fallback=True) @@ -21,18 +22,85 @@ import pisi.context as ctx # ActionsAPI Modules import pisi.actionsapi -import pisi.actionsapi.get as get -from pisi.actionsapi.shelltools import system -from pisi.actionsapi.shelltools import makedirs -from pisi.actionsapi.shelltools import copytree +import pisi.actionsapi.get as get +import pisi.actionsapi.autotools as autotools +import pisi.actionsapi.pisitools as pisitools +import pisi.actionsapi.shelltools as shelltools -def installHeaders(suffix, extra=[]): +def __getFlavour(): + flavuor = "" + try: + flavuor = get.srcNAME().split("kernel-")[1] + except IndexError: + pass + + return flavour + +def __getExtraVersion(): + try: + # if successful, this is something like: + # .1 for 2.6.30.1 + # _rc8 for 2.6.30_rc8 + extraversion = re.split("2.[0-9].[0-9]{2}([._].*)", get.srcVERSION())[1] + except IndexError: + # e.g. if version == 2.6.30 + extraversion = "" + + extraversion += "-%s" % get.srcRELEASE() + + # Append pae, default, rt, etc. to the extraversion if available + if __getFlavour(): + extraversion += "-%s" % __getFlavour() + + return extraversion + +def configure(): + # Set EXTRAVERSION + extraversion = __getExtraVersion() + + print "******* EV: ", extraversion + + # I don't know what for but let's clean *.orig files + shelltools.system("find . -name \"*.orig\" | xargs rm -f") + + pisitools.dosed("Makefile", "EXTRAVERSION =.*", "EXTRAVERSION = %s" % extraversion) + + # Configure the kernel + autotools.make("silentoldconfig") + +def build(): + autotools.make() + +def install(): + # Set suffix, e.g. "2.6.29_rc8-default" + suffix = "%s-%s" % (get.srcVERSION(), get.srcRELEASE()) + if __getFlavour(): + suffix += "-%s" % __getFlavour() + + # Install the modules into /lib/modules + autotools.rawInstall("INSTALL_MOD_PATH=%s/" % get.installDIR(), + "modules_install") + + # Install bzImage, symvers and System.map + pisitools.insinto("/lib/modules/%s/" % suffix, "System.map") + pisitools.insinto("/lib/modules/%s/" % suffix, "Module.symvers") + pisitools.insinto("/boot/", "arch/x86/boot/bzImage", "kernel-%s" % suffix) + + # Remove wrong symlinks + pisitools.remove("/lib/modules/%s/source" % suffix) + pisitools.remove("/lib/modules/%s/build" % suffix) + + # Remove modules.* files, they will autogenerated on next boot + # TODO: Ubuntu doesn't remove modules.order, reinvestigate. + pisitools.remove("/lib/modules/%s/modules.*" % suffix) + +def installHeaders(extra=[]): """ Install the files needed to build out-of-tree kernel modules. """ pruned = ["include", "scripts"] wanted = ["Makefile*", "Kconfig*", "Kbuild*", "*.sh", "*.pl", "*.lds"] destination = "%s/usr/src/linux-headers-%s" % (get.installDIR(), suffix) - makedirs(destination) + shelltools.makedirs(destination) # First create the skel find_cmd = "find . -path %s -prune -o -type f \( -name %s \) -print" % \ @@ -41,19 +109,19 @@ def installHeaders(suffix, extra=[]): " -o -name ".join(["'%s'" % k for k in wanted]) ) + " | cpio -pd --preserve-modification-time %s" % destination - system(find_cmd) + shelltools.system(find_cmd) # Install additional headers passed by actions.py for d in extra: - system("cp -a %s/*.h %s/%s" % (d, destination, d)) + shelltools.system("cp -a %s/*.h %s/%s" % (d, destination, d)) # Install remaining headers - system("cp -a scripts include %s" % destination) + shelltools.system("cp -a scripts include %s" % destination) # Finally copy the include directories found in arch/ - system("(find arch -name include -type d -print | \ - xargs -n1 -i: find : -type f) | \ - cpio -pd --preserve-modification-time %s" % destination) + shelltools.system("(find arch -name include -type d -print | \ + xargs -n1 -i: find : -type f) | \ + cpio -pd --preserve-modification-time %s" % destination) def installSource(): pass