actionsapi/kerneltools: Refactor
This commit is contained in:
@@ -66,6 +66,9 @@ def __getModuleFlavour():
|
||||
|
||||
return "kernel"
|
||||
|
||||
def __getKernelARCH():
|
||||
return get.ARCH().replace("i686", "i386")
|
||||
|
||||
def __getSuffix():
|
||||
# Set suffix, e.g. "2.6.30_rc7-119"
|
||||
suffix = "%s-%s" % (get.srcVERSION(), get.srcRELEASE())
|
||||
@@ -116,20 +119,20 @@ def getKernelVersion(flavour=None):
|
||||
# Fail
|
||||
raise ConfigureError(_("Can't find kernel version information file %s.") % kverfile)
|
||||
|
||||
def configure():
|
||||
|
||||
def configure():
|
||||
# I don't know what for but let's clean *.orig files
|
||||
shelltools.system("find . -name \"*.orig\" | xargs rm -f")
|
||||
|
||||
# Copy the relevant configuration file
|
||||
shutil.copy("configs/kernel-%s-config" % get.ARCH(), ".config")
|
||||
|
||||
# Set EXTRAVERSION
|
||||
pisitools.dosed("Makefile", "EXTRAVERSION =.*", "EXTRAVERSION = %s" % __getExtraVersion())
|
||||
|
||||
# Configure the kernel
|
||||
configtype = os.getenv("KCONFIG")
|
||||
if configtype:
|
||||
autotools.make(configtype)
|
||||
else:
|
||||
autotools.make("oldconfig")
|
||||
autotools.make("ARCH=%s oldconfig" % __getKernelARCH())
|
||||
|
||||
|
||||
def updateKConfig():
|
||||
# Call this to set newly added symbols to their defaults after sedding some KConfig
|
||||
@@ -151,21 +154,26 @@ def dumpVersion():
|
||||
|
||||
open(os.path.join(destination, get.srcNAME()), "w").write(__getSuffix())
|
||||
|
||||
|
||||
def build(debugSymbols=False):
|
||||
extra_config = []
|
||||
if debugSymbols:
|
||||
# Enable debugging symbols (-g -gdwarf2)
|
||||
extra_config.append("CONFIG_DEBUG_INFO=y")
|
||||
|
||||
autotools.make("%s" % " ".join(extra_config))
|
||||
autotools.make("ARCH=%s %s" % (__getKernelARCH(), " ".join(extra_config)))
|
||||
|
||||
|
||||
def install(installFirmwares=True):
|
||||
suffix = __getSuffix()
|
||||
|
||||
# Install kernel image
|
||||
pisitools.insinto("/boot/", "arch/x86/boot/bzImage", "kernel-%s" % suffix)
|
||||
|
||||
# Check if loadable module support is available or not before doing module specific tasks
|
||||
if re.search("CONFIG_MODULES=y", open(".config", "r").read().strip()):
|
||||
|
||||
# Install the modules into /lib/modules
|
||||
# Install the modules and the firmwares into /lib/{modules,firmware}
|
||||
autotools.rawInstall("INSTALL_MOD_PATH=%s/" % get.installDIR(),
|
||||
"modules_install")
|
||||
|
||||
@@ -177,12 +185,9 @@ def install(installFirmwares=True):
|
||||
pisitools.remove("/lib/modules/%s/source" % suffix)
|
||||
pisitools.remove("/lib/modules/%s/build" % suffix)
|
||||
|
||||
# Install kernel image
|
||||
pisitools.insinto("/boot/", "arch/x86/boot/bzImage", "kernel-%s" % suffix)
|
||||
|
||||
if not installFirmwares:
|
||||
# For use with PAE e.g.
|
||||
shelltools.system("rm -rf %s/lib/firmware" % get.installDIR())
|
||||
if not installFirmwares:
|
||||
# For use with PAE e.g.
|
||||
shelltools.system("rm -rf %s/lib/firmware" % get.installDIR())
|
||||
|
||||
|
||||
def installHeaders(extra=[]):
|
||||
@@ -231,6 +236,7 @@ def installHeaders(extra=[]):
|
||||
# Settle the correct build symlink to this headers
|
||||
pisitools.dosym("/%s" % headersDirectoryName, "/lib/modules/%s/build" % suffix)
|
||||
|
||||
|
||||
def installLibcHeaders(excludes=[]):
|
||||
headers_tmp = os.path.join(get.installDIR(), 'tmp-headers')
|
||||
headers_dir = os.path.join(get.installDIR(), 'usr/include')
|
||||
@@ -263,35 +269,28 @@ def installLibcHeaders(excludes=[]):
|
||||
|
||||
shelltools.cd(oldwd)
|
||||
|
||||
# FIXME: Do we really need to delete those directories below?
|
||||
"""
|
||||
# remove all directories other than asm/asm-generic and linux
|
||||
# FIXME: Check this.
|
||||
for directory in shelltools.ls("%s/usr/include/" % get.installDIR()):
|
||||
if directory not in ["asm", "asm-generic", "linux"]:
|
||||
pisitools.removeDir("/usr/include/%s" % directory)
|
||||
"""
|
||||
|
||||
# Remove tmp directory
|
||||
shelltools.system("rm -rf %s" % headers_tmp)
|
||||
|
||||
|
||||
def installSource():
|
||||
def installSource(onlySymlink=False):
|
||||
destination = "usr/src/linux-source-%s" % __getSuffix()
|
||||
|
||||
# Copy the whole source directory
|
||||
pisitools.dodir("/usr/src")
|
||||
shelltools.copytree("../%s/" % os.path.basename(get.curDIR()), os.path.join(get.installDIR(), destination))
|
||||
|
||||
# Cleanup the installed source
|
||||
shelltools.cd(os.path.join(get.installDIR(), destination))
|
||||
autotools.make("clean")
|
||||
autotools.make("modules_prepare")
|
||||
shelltools.system("find . -path './.*' | xargs rm -rf")
|
||||
|
||||
# Create the symlink
|
||||
pisitools.dosym("/%s" % destination, "/lib/modules/%s/source" % __getSuffix())
|
||||
|
||||
if not onlySymlink:
|
||||
# Copy the whole source directory
|
||||
pisitools.dodir("/usr/src")
|
||||
shelltools.copytree("../%s/" % os.path.basename(get.curDIR()), os.path.join(get.installDIR(), destination))
|
||||
|
||||
# Cleanup the installed source
|
||||
shelltools.cd(os.path.join(get.installDIR(), destination))
|
||||
autotools.make("clean")
|
||||
autotools.make("modules_prepare")
|
||||
shelltools.system("find . -path './.*' | xargs rm -rf")
|
||||
|
||||
|
||||
def cleanModuleFiles():
|
||||
""" Cleans module.* files generated by depmod """
|
||||
# Remove modules.* files, they will be autogenerated during pakhandler.
|
||||
@@ -299,7 +298,3 @@ def cleanModuleFiles():
|
||||
# according to the link order.
|
||||
shelltools.system("find %s/lib/modules/%s -name 'modules.*' \
|
||||
-not -name 'modules.order' -exec rm -f '{}' \;" % (get.installDIR(), __getSuffix()))
|
||||
|
||||
def mkinitramfs():
|
||||
""" Create and install the initramfs image into the package. This will hopefully be done on user's system. """
|
||||
shelltools.system("/sbin/mkinitramfs kernel=%s --full --root-dir=%s --output=%s/boot" % (__getSuffix(), get.installDIR(), get.installDIR()))
|
||||
|
||||
Reference in New Issue
Block a user