actionsapi/kerneltools: Refactor
This commit is contained in:
@@ -66,6 +66,9 @@ def __getModuleFlavour():
|
|||||||
|
|
||||||
return "kernel"
|
return "kernel"
|
||||||
|
|
||||||
|
def __getKernelARCH():
|
||||||
|
return get.ARCH().replace("i686", "i386")
|
||||||
|
|
||||||
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())
|
||||||
@@ -116,20 +119,20 @@ def getKernelVersion(flavour=None):
|
|||||||
# Fail
|
# Fail
|
||||||
raise ConfigureError(_("Can't find kernel version information file %s.") % kverfile)
|
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
|
# I don't know what for but let's clean *.orig files
|
||||||
shelltools.system("find . -name \"*.orig\" | xargs rm -f")
|
shelltools.system("find . -name \"*.orig\" | xargs rm -f")
|
||||||
|
|
||||||
|
# Copy the relevant configuration file
|
||||||
|
shutil.copy("configs/kernel-%s-config" % get.ARCH(), ".config")
|
||||||
|
|
||||||
# Set EXTRAVERSION
|
# Set EXTRAVERSION
|
||||||
pisitools.dosed("Makefile", "EXTRAVERSION =.*", "EXTRAVERSION = %s" % __getExtraVersion())
|
pisitools.dosed("Makefile", "EXTRAVERSION =.*", "EXTRAVERSION = %s" % __getExtraVersion())
|
||||||
|
|
||||||
# Configure the kernel
|
# Configure the kernel
|
||||||
configtype = os.getenv("KCONFIG")
|
autotools.make("ARCH=%s oldconfig" % __getKernelARCH())
|
||||||
if configtype:
|
|
||||||
autotools.make(configtype)
|
|
||||||
else:
|
|
||||||
autotools.make("oldconfig")
|
|
||||||
|
|
||||||
def updateKConfig():
|
def updateKConfig():
|
||||||
# Call this to set newly added symbols to their defaults after sedding some KConfig
|
# 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())
|
open(os.path.join(destination, get.srcNAME()), "w").write(__getSuffix())
|
||||||
|
|
||||||
|
|
||||||
def build(debugSymbols=False):
|
def build(debugSymbols=False):
|
||||||
extra_config = []
|
extra_config = []
|
||||||
if debugSymbols:
|
if debugSymbols:
|
||||||
# Enable debugging symbols (-g -gdwarf2)
|
# Enable debugging symbols (-g -gdwarf2)
|
||||||
extra_config.append("CONFIG_DEBUG_INFO=y")
|
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):
|
def install(installFirmwares=True):
|
||||||
suffix = __getSuffix()
|
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
|
# 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()):
|
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(),
|
autotools.rawInstall("INSTALL_MOD_PATH=%s/" % get.installDIR(),
|
||||||
"modules_install")
|
"modules_install")
|
||||||
|
|
||||||
@@ -177,12 +185,9 @@ def install(installFirmwares=True):
|
|||||||
pisitools.remove("/lib/modules/%s/source" % suffix)
|
pisitools.remove("/lib/modules/%s/source" % suffix)
|
||||||
pisitools.remove("/lib/modules/%s/build" % suffix)
|
pisitools.remove("/lib/modules/%s/build" % suffix)
|
||||||
|
|
||||||
# Install kernel image
|
if not installFirmwares:
|
||||||
pisitools.insinto("/boot/", "arch/x86/boot/bzImage", "kernel-%s" % suffix)
|
# 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=[]):
|
def installHeaders(extra=[]):
|
||||||
@@ -231,6 +236,7 @@ def installHeaders(extra=[]):
|
|||||||
# Settle the correct build symlink to this headers
|
# Settle the correct build symlink to this headers
|
||||||
pisitools.dosym("/%s" % headersDirectoryName, "/lib/modules/%s/build" % suffix)
|
pisitools.dosym("/%s" % headersDirectoryName, "/lib/modules/%s/build" % suffix)
|
||||||
|
|
||||||
|
|
||||||
def installLibcHeaders(excludes=[]):
|
def installLibcHeaders(excludes=[]):
|
||||||
headers_tmp = os.path.join(get.installDIR(), 'tmp-headers')
|
headers_tmp = os.path.join(get.installDIR(), 'tmp-headers')
|
||||||
headers_dir = os.path.join(get.installDIR(), 'usr/include')
|
headers_dir = os.path.join(get.installDIR(), 'usr/include')
|
||||||
@@ -263,35 +269,28 @@ def installLibcHeaders(excludes=[]):
|
|||||||
|
|
||||||
shelltools.cd(oldwd)
|
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
|
# Remove tmp directory
|
||||||
shelltools.system("rm -rf %s" % headers_tmp)
|
shelltools.system("rm -rf %s" % headers_tmp)
|
||||||
|
|
||||||
|
|
||||||
def installSource():
|
def installSource(onlySymlink=False):
|
||||||
destination = "usr/src/linux-source-%s" % __getSuffix()
|
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
|
# Create the symlink
|
||||||
pisitools.dosym("/%s" % destination, "/lib/modules/%s/source" % __getSuffix())
|
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():
|
def cleanModuleFiles():
|
||||||
""" Cleans module.* files generated by depmod """
|
""" Cleans module.* files generated by depmod """
|
||||||
# Remove modules.* files, they will be autogenerated during pakhandler.
|
# Remove modules.* files, they will be autogenerated during pakhandler.
|
||||||
@@ -299,7 +298,3 @@ def cleanModuleFiles():
|
|||||||
# according to the link order.
|
# according to the link order.
|
||||||
shelltools.system("find %s/lib/modules/%s -name 'modules.*' \
|
shelltools.system("find %s/lib/modules/%s -name 'modules.*' \
|
||||||
-not -name 'modules.order' -exec rm -f '{}' \;" % (get.installDIR(), __getSuffix()))
|
-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