jhbuild r2699 - in trunk: . jhbuild/modtypes



Author: johncarr
Date: Wed Feb  4 13:40:22 2009
New Revision: 2699
URL: http://svn.gnome.org/viewvc/jhbuild?rev=2699&view=rev

Log:
Improved kernel building support: Fix a bug that prevented jhbuild calling make modules_install. Support doing make mrproper. Do make install by hand (to avoid colliding with custom distro Kbuild foo or installing to /boot). Install headers. Support 'make defconfig' if moduleset doesnt specificy a kconfig.


Modified:
   trunk/ChangeLog
   trunk/jhbuild/modtypes/linux.py

Modified: trunk/jhbuild/modtypes/linux.py
==============================================================================
--- trunk/jhbuild/modtypes/linux.py	(original)
+++ trunk/jhbuild/modtypes/linux.py	Wed Feb  4 13:40:22 2009
@@ -31,6 +31,21 @@
 
 __all__ = [ 'LinuxModule' ]
 
+
+class LinuxConfig:
+
+    def __init__(self, version, path, branch):
+        self.version = version
+        self.path = path
+        self.branch = branch
+
+    def checkout(self, buildscript):
+        if self.branch:
+            self.branch.checkout(buildscript)
+            if not os.path.exists(self.path):
+                raise BuildStateError(_('kconfig file %s was not created') % self.path)
+
+
 class LinuxModule(Package):
     '''For modules that are built with the linux kernel method of
     make config, make, make install and make modules_install.'''
@@ -39,10 +54,12 @@
     STATE_CHECKOUT        = 'checkout'
     STATE_FORCE_CHECKOUT  = 'force_checkout'
     STATE_CLEAN           = 'clean'
+    STATE_MRPROPER        = 'mrproper'
     STATE_CONFIGURE       = 'configure'
     STATE_BUILD           = 'build'
     STATE_INSTALL         = 'install'
     STATE_MODULES_INSTALL = 'modules_install'
+    STATE_HEADERS_INSTALL = 'headers_install'
 
     def __init__(self, name, branch, kconfigs, makeargs,
             dependencies, after, suggests, extra_env = None):
@@ -76,10 +93,8 @@
         self.checkout(buildscript)
         for kconfig in self.kconfigs:
             kconfig.checkout(buildscript)
-            if not os.path.exists(kconfig.path):
-                raise BuildStateError(_('kconfig file %s was not created') % kconfig.path)
     do_checkout.next_state = STATE_CONFIGURE
-    do_checkout.error_states = [STATE_FORCE_CHECKOUT]
+    do_checkout.error_states = [STATE_MRPROPER]
 
     def skip_force_checkout(self, buildscript, last_state):
         return False
@@ -88,7 +103,28 @@
         buildscript.set_action(_('Checking out'), self)
         self.branch.force_checkout(buildscript)
     do_force_checkout.next_state = STATE_CONFIGURE
-    do_force_checkout.error_states = [STATE_FORCE_CHECKOUT]
+    do_force_checkout.error_states = [STATE_FORCE_CHECKOUT, STATE_MRPROPER]
+
+    def skip_mrproper(self, buildscript, last_state):
+        return buildscript.config.nobuild
+
+    def do_mrproper(self, buildscript):
+        buildscript.set_action(_('make mrproper'), self)
+        for kconfig in self.kconfigs:
+            cmd = '%s %s mrproper EXTRAVERSION=%s O=%s' % (
+                    os.environ.get('MAKE', 'make'),
+                    self.makeargs,
+                    kconfig.version,
+                    'build-' + kconfig.version)
+            buildscript.execute(cmd, cwd = self.branch.srcdir,
+                    extra_env = self.extra_env)
+
+        cmd = '%s mrproper' % os.environ.get('MAKE', 'make')
+        buildscript.execute(cmd, cwd = self.branch.srcdir,
+                    extra_env = self.extra_env)
+
+    do_mrproper.next_state = STATE_CONFIGURE
+    do_mrproper.error_states = []
 
     def skip_configure(self, buildscript, last_state):
         return False
@@ -97,7 +133,8 @@
         buildscript.set_action(_('Configuring'), self)
 
         for kconfig in self.kconfigs:
-            shutil.copyfile(kconfig.path, os.path.join(self.branch.srcdir, ".config"))
+            if kconfig.path:
+                shutil.copyfile(kconfig.path, os.path.join(self.branch.srcdir, ".config"))
 
             try:
                 os.makedirs(os.path.join(self.branch.srcdir, 'build-' + kconfig.version))
@@ -105,7 +142,12 @@
                 if e != errno.EEXIST:
                     raise
 
-            cmd = '%s oldconfig EXTRAVERSION=%s O=%s' % (
+            if kconfig.branch:
+                cmd = '%s oldconfig EXTRAVERSION=%s O=%s'
+            else:
+                cmd = '%s defconfig EXTRAVERSION=%s O=%s'
+
+            cmd = cmd % (
                     os.environ.get('MAKE', 'make'),
                     kconfig.version,
                     'build-' + kconfig.version)
@@ -113,7 +155,8 @@
             buildscript.execute(cmd, cwd = self.branch.srcdir,
                     extra_env = self.extra_env)
 
-            os.remove(os.path.join(self.branch.srcdir, ".config"))
+            if kconfig.path:
+                os.remove(os.path.join(self.branch.srcdir, ".config"))
 
     do_configure.next_state = STATE_CLEAN
     do_configure.error_states = [STATE_FORCE_CHECKOUT]
@@ -150,21 +193,24 @@
                     extra_env = self.extra_env)
 
     do_build.next_state = STATE_INSTALL
-    do_build.error_states = [STATE_FORCE_CHECKOUT, STATE_CONFIGURE]
+    do_build.error_states = [STATE_FORCE_CHECKOUT, STATE_MRPROPER, STATE_CONFIGURE]
 
     def skip_install(self, buildscript, last_state):
         return buildscript.config.nobuild
 
     def do_install(self, buildscript):
         buildscript.set_action(_('Installing'), self)
+        bootdir = os.path.join(buildscript.config.prefix, 'boot')
+        if not os.path.isdir(bootdir):
+            os.makedirs(bootdir)
         for kconfig in self.kconfigs:
-            cmd = '%s %s install EXTRAVERSION=%s O=%s INSTALL_PATH=%s/boot' % (
-                    os.environ.get('MAKE', 'make'),
-                    self.makeargs,
-                    kconfig.version,
-                    'build-' + kconfig.version,
-                    buildscript.config.prefix)
-            buildscript.execute(cmd, cwd = self.branch.srcdir,
+            # We do this on our own without 'make install' because things will go weird on the user
+            # if they have a custom installkernel script in ~/bin or /sbin/ and we can't override this.
+            for f in ("System.map", ".config", "vmlinux"):
+                cmd = "cp %s %s" % (
+                    os.path.join('build-'+kconfig.version, f),
+                    os.path.join(bootdir, f+'-'+kconfig.version))
+                buildscript.execute(cmd, cwd = self.branch.srcdir,
                     extra_env = self.extra_env)
 
     do_install.next_state = STATE_MODULES_INSTALL
@@ -184,10 +230,28 @@
                     buildscript.config.prefix)
             buildscript.execute(cmd, cwd = self.branch.srcdir,
                     extra_env = self.extra_env)
+
+    do_modules_install.next_state = STATE_HEADERS_INSTALL
+    do_modules_install.error_states = []
+
+    def skip_headers_install(self, buildscript, last_state):
+        return buildscript.config.nobuild
+
+    def do_headers_install(self, buildscript):
+        buildscript.set_action(_('Installing kernel'), self)
+        for kconfig in self.kconfigs:
+            cmd = '%s %s headers_install EXTRAVERSION=%s O=%s INSTALL_HDR_PATH=%s' % (
+                    os.environ.get('MAKE', 'make'),
+                    self.makeargs,
+                    kconfig.version,
+                    'build-' + kconfig.version,
+                    buildscript.config.prefix)
+            buildscript.execute(cmd, cwd = self.branch.srcdir,
+                    extra_env = self.extra_env)
         buildscript.packagedb.add(self.name, self.get_revision() or '')
 
-    do_install.next_state = Package.STATE_DONE
-    do_install.error_states = []
+    do_headers_install.next_state = Package.STATE_DONE
+    do_headers_install.error_states = []
 
     def xml_tag_and_attrs(self):
         return 'linux', [('id', 'name', None),
@@ -215,19 +279,21 @@
             except KeyError:
                 raise FatalError(_('Default Repository=%s not found for kconfig in module id=%s. Possible repositories are %s') % (default_repo, id, repositories))
 
-        kconfig = repo.branch_from_xml(id, childnode, repositories, default_repo)
+        branch = repo.branch_from_xml(id, childnode, repositories, default_repo)
 
-        kconfig.version = childnode.getAttribute('version')
+        version = childnode.getAttribute('version')
 
         if childnode.hasAttribute('config'):
-            kconfig.path = os.path.join(kconfig.srcdir, childnode.getAttribute('config'))
+            path = os.path.join(kconfig.srcdir, childnode.getAttribute('config'))
         else:
-            kconfig.path = kconfig.srcdir
+            path = kconfig.srcdir
 
+        kconfig = LinuxConfig(version, path, branch)
         kconfigs.append(kconfig)
 
     if not kconfigs:
-        raise FatalError(_('No <kconfig> elements found for module %s') % id)
+        kconfig = LinuxConfig('default', None, None)
+        kconfigs.append(kconfig)
 
     return kconfigs
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]