Author: waldi Date: Wed Mar 5 12:08:17 2008 New Revision: 10710 Log: * lib/dkt/bootconfig/__init__.py: Import gen, gen_linux. * lib/dkt/bootconfig/interfaces.py: Remove description. * lib/dkt/bootconfig/base.py, lib/dkt/bootconfig/entry.py, lib/dkt/bootconfig/gen.py, lib/dkt/bootconfig/gen_linux.py, lib/dkt/bootconfig/linux.py: Add.
Added: people/waldi/dkt/lib/dkt/bootconfig/base.py people/waldi/dkt/lib/dkt/bootconfig/entry.py people/waldi/dkt/lib/dkt/bootconfig/gen.py people/waldi/dkt/lib/dkt/bootconfig/gen_linux.py people/waldi/dkt/lib/dkt/bootconfig/linux.py Modified: people/waldi/dkt/lib/dkt/bootconfig/__init__.py people/waldi/dkt/lib/dkt/bootconfig/interfaces.py Modified: people/waldi/dkt/lib/dkt/bootconfig/__init__.py ============================================================================== --- people/waldi/dkt/lib/dkt/bootconfig/__init__.py (original) +++ people/waldi/dkt/lib/dkt/bootconfig/__init__.py Wed Mar 5 12:08:17 2008 @@ -0,0 +1 @@ +import gen, gen_linux Added: people/waldi/dkt/lib/dkt/bootconfig/base.py ============================================================================== --- (empty file) +++ people/waldi/dkt/lib/dkt/bootconfig/base.py Wed Mar 5 12:08:17 2008 @@ -0,0 +1,42 @@ +from itertools import izip + +from interfaces import IBootBaseConfig +from dkt.imageconfig.interfaces import IImageBaseConfig +from zope.interface import implements + +class BootConfigBase(object): + implements(IBootBaseConfig) + + def __init__(self, config): + self.config = config + + def __cmp__(self, other): + other = IBootBaseConfig(other) + version_self = '-'.split(self.version) + version_other = '-'.split(other.version) + + ret = cmp(len(version_self), len(version_other)) + if ret: + return ret + + for v_self, v_other in izip(version_self, version_other): + part_self = '.'.split(v_self) + part_other = '.'.split(v_other) + + ret = cmp(part_self, part_other) + if ret: + return ret + + features_self = self.features + features_other = other.features + + return cmp(features_self, features_other) + + @property + def features(self): + return IImageBaseConfig(self.config).features + + @property + def version(self): + return IImageBaseConfig(self.config).version + Added: people/waldi/dkt/lib/dkt/bootconfig/entry.py ============================================================================== --- (empty file) +++ people/waldi/dkt/lib/dkt/bootconfig/entry.py Wed Mar 5 12:08:17 2008 @@ -0,0 +1,9 @@ +from interfaces import IBootEntry +from zope.interface import implements + +class BootEntry(object): + implements(IBootEntry) + + def __init__(self, file, commandline): + self.file, self.commandline = file, commandline + Added: people/waldi/dkt/lib/dkt/bootconfig/gen.py ============================================================================== --- (empty file) +++ people/waldi/dkt/lib/dkt/bootconfig/gen.py Wed Mar 5 12:08:17 2008 @@ -0,0 +1,14 @@ +from dkt.hooks import default_registry, register +from dkt.hooks.interfaces import IBootConfigPartition, IBootConfigSort + +class HookPartitionRescue(object): + def boot_config_partition(self, bootconfigs, systemconfig): + return bootconfigs + +class HookSort(object): + def boot_config_sort(self, bootconfigs, systemconfig): + bootconfigs.sort() + return bootconfigs + +register('bootconfig-partition-rescue', IBootConfigPartition, HookPartitionRescue(), default_registry.PRIORITY_FIRST) +register('bootconfig-sort', IBootConfigSort, HookSort(), default_registry.PRIORITY_LAST) Added: people/waldi/dkt/lib/dkt/bootconfig/gen_linux.py ============================================================================== --- (empty file) +++ people/waldi/dkt/lib/dkt/bootconfig/gen_linux.py Wed Mar 5 12:08:17 2008 @@ -0,0 +1,16 @@ +from linux import BootConfigLinux +from dkt.hooks import default_registry, register +from dkt.hooks.interfaces import IBootConfigPrepare +from dkt.imageconfig.interfaces import IImageBaseConfig + +class Hook(object): + def boot_config_prepare(self, bootconfigs, systemconfig, imageconfigs): + for config in imageconfigs.itervalues(): + try: + image = IImageBaseConfig(config) + except: + raise + if image.type == 'linux' and image.subtype is None: + bootconfigs.append(BootConfigLinux(config)) + +register('bootconfig-prepare-linux', IBootConfigPrepare, Hook(), default_registry.PRIORITY_FIRST) Modified: people/waldi/dkt/lib/dkt/bootconfig/interfaces.py ============================================================================== --- people/waldi/dkt/lib/dkt/bootconfig/interfaces.py (original) +++ people/waldi/dkt/lib/dkt/bootconfig/interfaces.py Wed Mar 5 12:08:17 2008 @@ -1,7 +1,6 @@ from dkt.interface import Attribute, Interface class IBootBaseConfig(Interface): - description = Attribute("") features = Attribute("") version = Attribute("") @@ -9,6 +8,8 @@ kernel_entry = Attribute("") initrd_file = Attribute("") + config = Attribute("") + class IBootMultibootConfig(IBootBaseConfig): kernel_entry = Attribute("") module_entries = Attribute("") Added: people/waldi/dkt/lib/dkt/bootconfig/linux.py ============================================================================== --- (empty file) +++ people/waldi/dkt/lib/dkt/bootconfig/linux.py Wed Mar 5 12:08:17 2008 @@ -0,0 +1,19 @@ +from base import BootConfigBase +from entry import BootEntry +from interfaces import IBootMainConfig +from dkt.imageconfig.interfaces import IImageBaseConfig, IImageLinuxInitramfsConfig +#from dkt.hooks.interfaces import +from zope.interface import implements + +class BootConfigLinux(BootConfigBase): + implements(IBootMainConfig) + + def __init__(self, config): + super(BootConfigLinux, self).__init__(config) + + self.kernel_entry = BootEntry(IImageBaseConfig(self.config).file, "") + + @property + def initrd_file(self): + return IImageLinuxInitramfsConfig(self.config).file + _______________________________________________ Kernel-svn-changes mailing list Kernel-svn-changes@lists.alioth.debian.org http://lists.alioth.debian.org/mailman/listinfo/kernel-svn-changes