[kernel] r11136 - in people/waldi/dkt: bin lib/dkt/bin

Bastian Blank waldi at alioth.debian.org
Wed Apr 23 10:03:32 UTC 2008


Author: waldi
Date: Wed Apr 23 10:03:32 2008
New Revision: 11136

Log:
* bin/dkt-maintainer: Read kernel-img.conf if requested.
* lib/dkt/bin/backward_kpkg.py: Add.


Added:
   people/waldi/dkt/lib/dkt/bin/backward_kpkg.py
Modified:
   people/waldi/dkt/bin/dkt-maintainer

Modified: people/waldi/dkt/bin/dkt-maintainer
==============================================================================
--- people/waldi/dkt/bin/dkt-maintainer	(original)
+++ people/waldi/dkt/bin/dkt-maintainer	Wed Apr 23 10:03:32 2008
@@ -1,15 +1,19 @@
 #!/usr/bin/python
 
-import sys
+import os, sys
 
 from dkt.bin.base import MainBase
+from dkt.bin.backward_kpkg import MainBackwardKpkg
 from dkt.config.base import Config
 
-class MainAll(MainBase):
+class MainAll(MainBase, MainBackwardKpkg):
     def __init__(self, package, version):
         super(MainAll, self).__init__()
         self.package, self.version = package, version
 
+        if self.config.get('backward-compatibility', 'use-kpkg-config', False) and os.path.exists("/etc/kernel-img.conf"):
+            self.systemconfig_read_kpkg(file("/etc/kernel-img.conf"))
+
     def itemconfig_create(self):
         c = {'package': {'name': self.package, 'version': self.version}}
         if self.package.startswith('linux-image-'):

Added: people/waldi/dkt/lib/dkt/bin/backward_kpkg.py
==============================================================================
--- (empty file)
+++ people/waldi/dkt/lib/dkt/bin/backward_kpkg.py	Wed Apr 23 10:03:32 2008
@@ -0,0 +1,81 @@
+import os, re
+
+class _read(object):
+    def __init__(self, config, option, dataname, default):
+        self.config, self.option, self.dataname, self.default = config, option, dataname, default
+
+    def __call__(self, data):
+        self.set(data.get(self.dataname, None))
+
+    def set(self, value):
+        if value is None:
+            value = self.default
+        if value is not None:
+            # XXX: Hack
+            self.config._sections['backward-compatibility'].setdefault(self.option, value)
+
+class _read_bool(_read):
+    def __call__(self, data):
+        value = data.get(self.dataname, None)
+        value_real = None
+        if value is not None:
+            value = value.lower()
+            if value in ('no', 'false', '0'):
+                value_real = False
+            elif value in ('yes', 'true', '1'):
+                value_real = True
+        self.set(value_real)
+
+class _read_fail(object):
+    __slots__ = 'dataname'
+
+    def __init__(self, dataname):
+        self.dataname = dataname
+
+    def __call__(self, data):
+        if data.get(self.dataname, None) is not None:
+            raise RuntimeError('Unsuported option found: %s' % self.dataname)
+
+class MainBackwardKpkg(object):
+    __re = re.compile(r"(\w+)\s*=\s*(\S+)")
+
+    def systemconfig_read_kpkg(self, f):
+        data = {}
+
+        for line in f:
+            line = line.strip()
+            if not line or line.startswith('#'):
+                continue
+            match = self.__re.match(line)
+            if match:
+                data.setdefault(match.group(1), match.group(2))
+
+        _read_bool(self.config, 'kpkg-do-symlinks', 'do_symlinks', True)(data)
+        _read_fail('no_symlinks')(data)
+        _read_fail('reverse_symlink')(data)
+        _read_bool(self.config, 'kpkg-link-in-boot', 'link_in_boot', True)(data)
+        _read_fail('move_image')(data)
+        _read_fail('clobber_modules')(data)
+        _read_fail('do_boot_enable')(data)
+        _read_fail('do_bootfloppy')(data)
+        _read_fail('relative_links')(data)
+        _read_bool(self.config, 'kpkg-do-bootloader', 'do_bootloader', True)(data)
+        _read_bool(self.config, 'kpkg-do-initrd', 'do_initrd', False)(data)
+        _read_fail('warn_initrd')(data)
+        _read_fail('use_hard_links')(data)
+        _read_fail('silent_modules')(data)
+        _read_fail('silent_loader')(data)
+        _read_fail('minimal_swap')(data)
+        _read_fail('ignore_depmod_err')(data)
+        _read_fail('relink_src_link')(data)
+        _read_fail('relink_build_link')(data)
+        _read_fail('force_build_link')(data)
+
+        _read_fail('image_dest')(data)
+        _read(self.config, 'kpkg-postinst-hook', 'postinst_hook', None)(data)
+        _read(self.config, 'kpkg-postrm-hook', 'postrm_hook', None)(data)
+        _read(self.config, 'kpkg-preinst-hook', 'prminst_hook', None)(data)
+        _read(self.config, 'kpkg-prerm-hook', 'prerm_hook', None)(data)
+        _read_fail('mkimage')(data)
+        _read_fail('ramdisk')(data)
+



More information about the Kernel-svn-changes mailing list