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

Adding a size check



On some subarches we have a size restriction on the kernel image (e.g.
so it fits into flash).  I suggested adding a size check a while ago
and waldi thought abicheck would be the right place for this.  I've
made a first stab at this now.  Any comments, waldi?

You can put check_size and (optionally) check_file in the image stanza:

 [versatile_image]
 configs: arm/config.versatile
+check_size: 1000000
+check_file: arch/arm/boot/zImage

and then you'll get the following during the build:

python debian/bin/abicheck.py debian/build/build_armel_none_versatile armel none versatile
Kernel image is too large: 1316048 > 1000000
make[2]: *** [debian/stamps/build_armel_none_versatile_kernel-package] Error 1
make[2]: Leaving directory `/home/tbm/kernel/linux-2.6-2.6.27~rc3'


Index: bin/abicheck.py
===================================================================
--- bin/abicheck.py	(revision 12062)
+++ bin/abicheck.py	(working copy)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python
 
+import os
+import stat
 import sys
 sys.path.append('debian/lib/python')
 
@@ -12,6 +14,7 @@
         self.arch, self.featureset, self.flavour = arch, featureset, flavour
         self.config = ConfigCoreDump(fp = file("debian/config.defines.dump"))
         self.filename_new = "%s/Module.symvers" % dir
+        self.dir = dir
 
         changelog = Changelog(version = VersionLinux)[0]
         version = changelog.version.linux_version
@@ -21,6 +24,23 @@
     def __call__(self, out):
         ret = 0
 
+        # Check the size of the kernel image
+        image = self.config.merge('image', self.arch, self.featureset, self.flavour)
+        if image.has_key('check_size'):
+                kernel = self.dir + '/' + image.get('check_file', 'vmlinux')
+                try:
+                       size = os.stat(kernel)[stat.ST_SIZE]
+                except OSError:
+                        out.write("Can't find kernel file %s\n" % kernel)
+                        return 1
+                check_size = int(image['check_size'])
+                if size <= check_size:
+                        out.write("Size check of kernel image passed (%d <= %d)\n" % (size, check_size))
+                else:
+                        out.write("Kernel image is too large: %d > %d\n" % (size, check_size))
+                        return 1
+
+        # Check the ABI
         new = symbols(self.filename_new)
         try:
             ref = symbols(self.filename_ref)

-- 
Martin Michlmayr
http://www.cyrius.com/


Reply to: