Bunch of stuff to make the xconfig ksdata actually apply. While the default desktop stuff doesn't appear to be used by much, the runlevel setting is more useful.
--jlk
--- pyanaconda/constants.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py index e945bca..d9d5b33 100644 --- a/pyanaconda/constants.py +++ b/pyanaconda/constants.py @@ -91,4 +91,7 @@ DMI_CHASSIS_VENDOR = "/sys/class/dmi/id/chassis_vendor"
# VNC questions USEVNC = _("Start VNC") -USETEXT = _("Use text mode") \ No newline at end of file +USETEXT = _("Use text mode") + +# Runlevel files +RUNLEVELS = {3: 'multi-user.target', 5: 'graphical.target'} \ No newline at end of file
This uses the new constant to link to the right target by name. It also removes any fiddling with /etc/inittab as we don't want/need to touch that any more. --- pyanaconda/desktop.py | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/pyanaconda/desktop.py b/pyanaconda/desktop.py index 263c543..b6207a6 100644 --- a/pyanaconda/desktop.py +++ b/pyanaconda/desktop.py @@ -21,7 +21,7 @@
import string, os from simpleconfig import SimpleConfigFile -from pyanaconda.constants import ROOT_PATH +from pyanaconda.constants import ROOT_PATH, RUNLEVELS
import logging log = logging.getLogger("anaconda") @@ -32,7 +32,7 @@ class Desktop (SimpleConfigFile): # to start in # def setDefaultRunLevel(self, runlevel): - if str(runlevel) != "3" and str(runlevel) != "5": + if int(runlevel) not in RUNLEVELS.keys(): raise RuntimeError, "Desktop::setDefaultRunLevel() - Must specify runlevel as 3 or 5!" self.runlevel = runlevel
@@ -55,26 +55,11 @@ class Desktop (SimpleConfigFile): f.write(str (self)) f.close()
- try: - inittab = open (ROOT_PATH + '/etc/inittab', 'r') - except IOError: - log.warning ("there is no inittab, bad things will happen!") - return - lines = inittab.readlines () - inittab.close () - inittab = open (ROOT_PATH + '/etc/inittab', 'w') - for line in lines: - if len (line) > 3 and line[:3] == "id:": - fields = string.split (line, ':') - fields[1] = str (self.runlevel) - line = string.join (fields, ':') - inittab.write (line) - inittab.close () - if not os.path.isdir(ROOT_PATH + '/etc/systemd/system'): log.warning("there is no /etc/systemd/system directory, cannot update default.target!") return default_target = ROOT_PATH + '/etc/systemd/system/default.target' if os.path.islink(default_target): os.unlink(default_target) - os.symlink('/lib/systemd/system/runlevel' + str(self.runlevel) + '.target', default_target) + os.symlink('/lib/systemd/system/%s' % RUNLEVELS[self.runlevel], + default_target)
@@ -32,7 +32,7 @@ class Desktop (SimpleConfigFile): # to start in # def setDefaultRunLevel(self, runlevel):
if str(runlevel) != "3" and str(runlevel) != "5":
if int(runlevel) not in RUNLEVELS.keys(): raise RuntimeError, "Desktop::setDefaultRunLevel() - Must specify runlevel as 3 or 5!" self.runlevel = runlevel
Just a quick python style note. You can leave off the keys bit there and just check like this:
if int(runlevel) not in RUNLEVELS:
Not that it matters much, and I'm sure I've done the same plenty of places.
- Chris
Get rid of unused import, use super(), remove some spaces --- pyanaconda/desktop.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/desktop.py b/pyanaconda/desktop.py index b6207a6..c65e925 100644 --- a/pyanaconda/desktop.py +++ b/pyanaconda/desktop.py @@ -19,14 +19,14 @@ # Author(s): Matt Wilson msw@redhat.com #
-import string, os +import os from simpleconfig import SimpleConfigFile from pyanaconda.constants import ROOT_PATH, RUNLEVELS
import logging log = logging.getLogger("anaconda")
-class Desktop (SimpleConfigFile): +class Desktop(SimpleConfigFile): # # This class represents the default desktop to run and the default runlevel # to start in @@ -45,14 +45,14 @@ class Desktop (SimpleConfigFile): def getDefaultDesktop(self): return self.get("DESKTOP")
- def __init__ (self): - SimpleConfigFile.__init__ (self) + def __init__(self): + super(Desktop, self).__init__() self.runlevel = 3
def write(self): if self.getDefaultDesktop(): f = open(ROOT_PATH + "/etc/sysconfig/desktop", "w") - f.write(str (self)) + f.write(str(self)) f.close()
if not os.path.isdir(ROOT_PATH + '/etc/systemd/system'):
--- pyanaconda/kickstart.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py index 7823354..0f8a4ef 100644 --- a/pyanaconda/kickstart.py +++ b/pyanaconda/kickstart.py @@ -51,6 +51,7 @@ from pyanaconda import timezone from pyanaconda import localization from pyanaconda.simpleconfig import SimpleConfigFile from pyanaconda.users import getPassAlgo +from pyanaconda.desktop import Desktop
from pykickstart.base import KickstartCommand from pykickstart.constants import * @@ -1395,11 +1396,15 @@ class VolGroupData(commands.volgroup.FC16_VolGroupData):
class XConfig(commands.xconfig.F14_XConfig): def execute(self): + desktop = Desktop() if self.startX: - self.anaconda.desktop.setDefaultRunLevel(5) + desktop.setDefaultRunLevel(5)
if self.defaultdesktop: - self.anaconda.desktop.setDefaultDesktop(self.defaultdesktop) + desktop.setDefaultDesktop(self.defaultdesktop) + + # now write it out + desktop.write()
class ZFCP(commands.zfcp.F14_ZFCP): def parse(self, args):
--- pyanaconda/install.py | 1 + 1 file changed, 1 insertion(+)
diff --git a/pyanaconda/install.py b/pyanaconda/install.py index b6fc3e8..cc0c3d4 100644 --- a/pyanaconda/install.py +++ b/pyanaconda/install.py @@ -66,6 +66,7 @@ def doConfiguration(storage, payload, ksdata, instClass): ksdata.timezone.execute(storage, ksdata, instClass) ksdata.lang.execute(storage, ksdata, instClass) ksdata.firewall.execute(storage, ksdata, instClass) + ksdata.xconfig.execute()
with progress_report(_("Writing network configuration")): writeNetworkConf(storage, ksdata, instClass)
diff --git a/pyanaconda/install.py b/pyanaconda/install.py index b6fc3e8..cc0c3d4 100644 --- a/pyanaconda/install.py +++ b/pyanaconda/install.py @@ -66,6 +66,7 @@ def doConfiguration(storage, payload, ksdata, instClass): ksdata.timezone.execute(storage, ksdata, instClass) ksdata.lang.execute(storage, ksdata, instClass) ksdata.firewall.execute(storage, ksdata, instClass)
ksdata.xconfig.execute()
I'd prefer to keep all execute methods taking the same set of arguments.
- Chris
This removes code duplicated in desktop.py, and will short circuit the routine if the user has indicated that they want a graphical boot by way of kickstart data. --- pyanaconda/packaging/__init__.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index 0108f68..1186569 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -575,11 +575,14 @@ class Payload(object): log.error("systemd is not installed -- can't set default target") return
+ # If X was already requested we don't have to continue + if self.data.xconfig.startX: + return + try: import rpm except ImportError: - log.info("failed to import rpm -- defaulting to multi-user.target") - default_target = "multi-user.target" + log.info("failed to import rpm -- not adjusting default runlevel") else: ts = rpm.TransactionSet(ROOT_PATH)
@@ -587,14 +590,9 @@ class Payload(object): if ts.dbMatch("provides", 'service(graphical-login)').count() and \ ts.dbMatch('provides', 'xorg-x11-server-Xorg').count() and \ not flags.usevnc: - default_target = "graphical.target" - else: - default_target = "multi-user.target" - - symlink_path = ROOT_PATH + '/etc/systemd/system/default.target' - if os.path.islink(symlink_path): - os.unlink(symlink_path) - os.symlink('/usr/lib/systemd/system/' + default_target, symlink_path) + # We only manipulate the ksdata. The symlink is made later + # during the config write out. + self.data.xconfig.startX = True
def dracutSetupArgs(self): args = []
On Mon, 2012-11-12 at 21:50 -0800, Jesse Keating wrote:
Bunch of stuff to make the xconfig ksdata actually apply. While the default desktop stuff doesn't appear to be used by much, the runlevel setting is more useful.
--jlk
These all look good to me for now. However we could get rid of the Desktop class and use functions working directly with ksdata in some future patches.
anaconda-patches@lists.fedorahosted.org