From: Gui Chen Date: Tue, 25 Jun 2013 07:44:18 +0000 (-0400) Subject: kickstart: add the installerfw KS command X-Git-Tag: 0.20~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d52080c23dc6f9974466e0d8450d14616d7c65b0;p=tools%2Fmic.git kickstart: add the installerfw KS command This command will be used in the KS file and it will specify the list legacy MIC features which have to be disabled. Instead of these feature, the general installer framework infrastructure mechanisms will be used. The first option will be "extlinux" which will disable the legacy extlinux installation feature. At some point, installerfw=all will be supported, it will disable all the legacy features (for keyboard, fstab, users, etc). Along with the option, introduce a helper function which checks if a the installer framework has to be used for a feature. Usage example: if use_installerfw(ks, "extlinux"): # do not execute MIC's built-in extlinux installation code else: # the compatibility legacy mode original written by Artem Artem: added the use_installerfw() function. Signed-off-by: Gui Chen Signed-off-by: Artem Bityutskiy --- diff --git a/mic/kickstart/__init__.py b/mic/kickstart/__init__.py index eb8bee2..f9a5334 100644 --- a/mic/kickstart/__init__.py +++ b/mic/kickstart/__init__.py @@ -32,7 +32,7 @@ from pykickstart.handlers.control import dataMap from mic import msger from mic.utils import errors, misc, runner, fs_related as fs -from custom_commands import desktop, micrepo, micboot, partition +from custom_commands import desktop, micrepo, micboot, partition, installerfw AUTH_URL_PTN = r"(?P.*)://(?P.*)(:?P.*)?@(?P.*)" @@ -101,6 +101,7 @@ def read_kickstart(path): commandMap[using_version]["bootloader"] = micboot.Mic_Bootloader commandMap[using_version]["part"] = partition.Mic_Partition commandMap[using_version]["partition"] = partition.Mic_Partition + commandMap[using_version]["installerfw"] = installerfw.Mic_installerfw dataMap[using_version]["RepoData"] = micrepo.Mic_RepoData dataMap[using_version]["PartData"] = partition.Mic_PartData superclass = ksversion.returnClassForVersion(version=using_version) @@ -636,6 +637,15 @@ class NetworkConfig(KickstartConfig): self.write_hosts(hostname) self.write_resolv(nodns, nameservers) +def use_installerfw(ks, feature): + """ Check if the installer framework has to be used for a feature + "feature". """ + + features = ks.handler.installerfw.features + if features: + if feature in features or "all" in features: + return True + return False def get_image_size(ks, default = None): __size = 0 diff --git a/mic/kickstart/custom_commands/__init__.py b/mic/kickstart/custom_commands/__init__.py index d9a1fe5..5f4c440 100644 --- a/mic/kickstart/custom_commands/__init__.py +++ b/mic/kickstart/custom_commands/__init__.py @@ -1,11 +1,12 @@ from desktop import Mic_Desktop from micrepo import Mic_Repo, Mic_RepoData from partition import Mic_Partition - +from installerfw import Mic_installerfw __all__ = ( "Mic_Desktop", "Mic_Repo", "Mic_RepoData", "Mic_Partition", -) \ No newline at end of file + "Mic_installerfw", +) diff --git a/mic/kickstart/custom_commands/installerfw.py b/mic/kickstart/custom_commands/installerfw.py new file mode 100644 index 0000000..2466f1d --- /dev/null +++ b/mic/kickstart/custom_commands/installerfw.py @@ -0,0 +1,63 @@ +#!/usr/bin/python -tt +# +# Copyright (c) 2013 Intel, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., 59 +# Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +from pykickstart.base import * +from pykickstart.options import * + +class Mic_installerfw(KickstartCommand): + """ This class implements the "installerfw" KS option. The argument + of the option is a comman-separated list of MIC features which have to be + disabled and instead, will be done in the installer. For example, + "installerfw=extlinux" disables all the MIC code which installs extlinux to + the target images, and instead, the extlinux or whatever boot-loader will + be installed by the installer instead. + + The installer is a tool which is external to MIC, it comes from the + installation repositories and can be executed by MIC in order to perform + various configuration actions. The main point here is to make sure MIC has + no hard-wired knoledge about the target OS configuration. """ + + removedKeywords = KickstartCommand.removedKeywords + removedAttrs = KickstartCommand.removedAttrs + + def __init__(self, *args, **kwargs): + KickstartCommand.__init__(self, *args, **kwargs) + self.op = self._getParser() + self.features = kwargs.get("installerfw", None) + + def __str__(self): + retval = KickstartCommand.__str__(self) + + if self.features: + retval += "# Enable installer framework features\ninstallerfw\n" + + return retval + + def _getParser(self): + op = KSOptionParser() + return op + + def parse(self, args): + (_, extra) = self.op.parse_args(args=args, lineno=self.lineno) + + if len(extra) != 1: + msg = "Kickstart command \"installerfw\" requires one " \ + "argumet - a list of legacy features to disable" + raise KickstartValueError, formatErrorMsg(self.lineno, msg = msg) + + self.features = extra[0].split(",") + return self