2016-04-10 04:00:00 +00:00
|
|
|
#!/usr/bin/python3
|
2011-01-18 09:24:57 +00:00
|
|
|
#
|
|
|
|
# anaconda: The Red Hat Linux Installation program
|
|
|
|
#
|
2014-04-07 12:38:09 +00:00
|
|
|
# Copyright (C) 1999-2013
|
2011-01-18 09:24:57 +00:00
|
|
|
# Red Hat, Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
# 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; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
# This toplevel file is a little messy at the moment... (2001-06-22)
|
|
|
|
# ...still messy (2013-07-12)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
import os
|
|
|
|
import site
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
coverage = None
|
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
proc_cmdline = open("/proc/cmdline", "r").read()
|
2015-03-23 11:36:12 +00:00
|
|
|
proc_cmdline = proc_cmdline.split()
|
2017-01-09 02:09:07 +00:00
|
|
|
if ("inst.debug=1" in proc_cmdline) or ("inst.debug" in proc_cmdline):
|
2015-03-23 11:36:12 +00:00
|
|
|
import coverage
|
2017-01-09 02:09:07 +00:00
|
|
|
pyanaconda_dir = "pyanaconda"
|
|
|
|
for sitepkg in site.getsitepackages():
|
|
|
|
possible_dir = os.path.join(sitepkg, "pyanaconda")
|
|
|
|
if os.path.isdir(possible_dir):
|
|
|
|
pyanaconda_dir = possible_dir
|
|
|
|
break
|
2015-03-23 11:36:12 +00:00
|
|
|
cov = coverage.coverage(data_file="/mnt/sysimage/root/anaconda.coverage",
|
|
|
|
branch=True,
|
2017-01-09 02:09:07 +00:00
|
|
|
source=["/usr/sbin/anaconda", pyanaconda_dir]
|
2015-03-23 11:36:12 +00:00
|
|
|
)
|
|
|
|
cov.start()
|
|
|
|
|
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
import atexit, sys, time, signal
|
2016-04-10 04:00:00 +00:00
|
|
|
import pid
|
2015-03-23 11:36:12 +00:00
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
def exitHandler(rebootData, storage):
|
2015-03-23 11:36:12 +00:00
|
|
|
# Clear the list of watched PIDs.
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.unwatchAllProcesses()
|
2015-03-23 11:36:12 +00:00
|
|
|
|
|
|
|
# stop and save coverage here b/c later the file system may be unavailable
|
|
|
|
if coverage is not None:
|
|
|
|
cov.stop()
|
|
|
|
if os.path.isdir('/mnt/sysimage/root'):
|
|
|
|
cov.save()
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if flags.usevnc:
|
|
|
|
vnc.shutdownServer()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if "nokill" in flags.cmdline:
|
|
|
|
iutil.vtActivate(1)
|
2015-03-23 11:36:12 +00:00
|
|
|
print("anaconda halting due to nokill flag.")
|
|
|
|
print("The system will be rebooted when you press Ctrl-Alt-Delete.")
|
2013-01-23 17:28:19 +00:00
|
|
|
while True:
|
|
|
|
time.sleep(10000)
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
if anaconda.dbus_inhibit_id:
|
|
|
|
from pyanaconda.screensaver import uninhibit_screensaver
|
|
|
|
uninhibit_screensaver(anaconda.dbus_session_connection, anaconda.dbus_inhibit_id)
|
|
|
|
anaconda.dbus_inhibit_id = None
|
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
# Unsetup the payload, which most usefully unmounts live images
|
|
|
|
if anaconda.payload:
|
|
|
|
anaconda.payload.unsetup()
|
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
if image_count or flags.dirInstall:
|
|
|
|
anaconda.storage.umount_filesystems(swapoff=False)
|
|
|
|
devicetree = anaconda.storage.devicetree
|
|
|
|
devicetree.teardown_all()
|
|
|
|
for imageName in devicetree.disk_images:
|
|
|
|
dev = devicetree.get_device_by_name(imageName)
|
|
|
|
for loop in dev.parents:
|
|
|
|
loop.controllable = True
|
|
|
|
dev.deactivate(recursive=True)
|
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
# Clean up the PID file
|
2016-04-10 04:00:00 +00:00
|
|
|
if pidfile:
|
|
|
|
pidfile.close()
|
2015-05-30 11:20:59 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if not flags.imageInstall and not flags.livecdInstall \
|
|
|
|
and not flags.dirInstall:
|
|
|
|
from pykickstart.constants import KS_SHUTDOWN, KS_WAIT
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if flags.eject or rebootData.eject:
|
2017-01-09 02:09:07 +00:00
|
|
|
for cdrom in (d for d in storage.devices if d.type == "cdrom"):
|
|
|
|
if iutil.get_mount_paths(cdrom.path):
|
|
|
|
iutil.dracut_eject(cdrom.path)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
if flags.kexec:
|
2017-01-09 02:09:07 +00:00
|
|
|
iutil.execWithRedirect("systemctl", ["--no-wall", "kexec"])
|
2016-04-10 04:00:00 +00:00
|
|
|
while True:
|
|
|
|
time.sleep(10000)
|
|
|
|
elif rebootData.action == KS_SHUTDOWN:
|
2017-01-09 02:09:07 +00:00
|
|
|
iutil.execWithRedirect("systemctl", ["--no-wall", "poweroff"])
|
2013-01-23 17:28:19 +00:00
|
|
|
elif rebootData.action == KS_WAIT:
|
2017-01-09 02:09:07 +00:00
|
|
|
iutil.execWithRedirect("systemctl", ["--no-wall", "halt"])
|
2015-03-23 11:36:12 +00:00
|
|
|
else: # reboot action is KS_REBOOT or None
|
2017-01-09 02:09:07 +00:00
|
|
|
iutil.execWithRedirect("systemctl", ["--no-wall", "reboot"])
|
2014-04-07 12:38:09 +00:00
|
|
|
|
|
|
|
def startSpiceVDAgent():
|
|
|
|
status = iutil.execWithRedirect("spice-vdagent", [])
|
|
|
|
|
|
|
|
if status:
|
|
|
|
log.info("spice-vdagent exited with status %d", status)
|
|
|
|
else:
|
|
|
|
log.info("Started spice-vdagent.")
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
def startX11():
|
2016-04-10 04:00:00 +00:00
|
|
|
import subprocess
|
2015-03-23 11:36:12 +00:00
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
# Start Xorg and wait for it become ready
|
|
|
|
iutil.startX(["Xorg", "-br", "-logfile", "/tmp/X.log",
|
|
|
|
":%s" % constants.X_DISPLAY_NUMBER, "vt6", "-s", "1440", "-ac",
|
|
|
|
"-nolisten", "tcp", "-dpi", "96",
|
2016-04-10 04:00:00 +00:00
|
|
|
"-noreset"], output_redirect=subprocess.DEVNULL)
|
2015-03-23 11:36:12 +00:00
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
# function to handle X startup special issues for anaconda
|
|
|
|
def doStartupX11Actions():
|
|
|
|
"""Start window manager"""
|
2015-03-23 11:36:12 +00:00
|
|
|
# When metacity actually connects to the X server is unknowable, but
|
|
|
|
# fortunately it doesn't matter. metacity does not need to be the first
|
|
|
|
# connection to Xorg, and if anaconda starts up before metacity, metacity
|
|
|
|
# will just take over and maximize the window and make everything right,
|
|
|
|
# fingers crossed.
|
2015-05-30 11:20:59 +00:00
|
|
|
# Add XDG_DATA_DIRS to the environment to pull in our overridden schema
|
|
|
|
# files.
|
2017-01-09 02:09:07 +00:00
|
|
|
datadir = os.environ.get('ANACONDA_DATADIR', '/usr/share/anaconda')
|
2015-05-30 11:20:59 +00:00
|
|
|
if 'XDG_DATA_DIRS' in os.environ:
|
2017-01-09 02:09:07 +00:00
|
|
|
xdg_data_dirs = datadir + '/window-manager:' + os.environ['XDG_DATA_DIRS']
|
2015-05-30 11:20:59 +00:00
|
|
|
else:
|
2017-01-09 02:09:07 +00:00
|
|
|
xdg_data_dirs = datadir + '/window-manager:/usr/share'
|
2015-03-23 11:36:12 +00:00
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
childproc = iutil.startProgram(["metacity", "--display", ":1", "--sm-disable"],
|
|
|
|
env_add={'XDG_DATA_DIRS': xdg_data_dirs})
|
|
|
|
iutil.watchProcess(childproc, "metacity")
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
def set_x_resolution(runres):
|
2015-03-23 11:36:12 +00:00
|
|
|
if runres and opts.display_mode == 'g' and not flags.usevnc:
|
2011-01-18 09:24:57 +00:00
|
|
|
try:
|
2013-01-23 17:28:19 +00:00
|
|
|
log.info("Setting the screen resolution to: %s.", runres)
|
2014-04-07 12:38:09 +00:00
|
|
|
iutil.execWithRedirect("xrandr",
|
|
|
|
["-d", ":1", "-s", runres])
|
|
|
|
except RuntimeError:
|
2013-01-23 17:28:19 +00:00
|
|
|
log.error("The X resolution not set")
|
|
|
|
iutil.execWithRedirect("xrandr",
|
2014-04-07 12:38:09 +00:00
|
|
|
["-d", ":1", "-q"])
|
|
|
|
|
|
|
|
def doExtraX11Actions(runres):
|
|
|
|
"""Perform X11 actions not related to startup"""
|
|
|
|
|
|
|
|
set_x_resolution(runres)
|
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
# Load the system-wide Xresources
|
|
|
|
iutil.execWithRedirect("xrdb",
|
|
|
|
["-nocpp", "-merge", "/etc/X11/Xresources"])
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
startSpiceVDAgent()
|
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
def setupPythonUpdates():
|
|
|
|
from distutils.sysconfig import get_python_lib
|
2014-04-07 12:38:09 +00:00
|
|
|
import gi.overrides
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
if "ANACONDA_WIDGETS_OVERRIDES" in os.environ:
|
|
|
|
for p in os.environ["ANACONDA_WIDGETS_OVERRIDES"].split(":"):
|
|
|
|
gi.overrides.__path__.insert(0, os.path.abspath(p))
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# Temporary hack for F18 alpha to symlink updates and product directories
|
|
|
|
# into tmpfs. To be removed after beta in order to directly use content
|
|
|
|
# from /run/install/ -- JLK
|
|
|
|
for dirname in ("updates", "product"):
|
|
|
|
if os.path.exists("/run/install/%s" % dirname):
|
|
|
|
if os.path.islink("/tmp/%s" % dirname):
|
|
|
|
# Assume updates have already been setup
|
|
|
|
return
|
|
|
|
os.symlink("/run/install/%s" % dirname,
|
|
|
|
"/tmp/%s" % dirname)
|
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
if not os.path.exists("/tmp/updates"):
|
|
|
|
return
|
|
|
|
|
|
|
|
for pkg in os.listdir("/tmp/updates"):
|
|
|
|
d = "/tmp/updates/%s" % pkg
|
|
|
|
|
|
|
|
if not os.path.isdir(d):
|
|
|
|
continue
|
|
|
|
|
|
|
|
# See if the package exists in /usr/lib{64,}/python/?.?/site-packages.
|
|
|
|
# If it does, we can set it up as an update. If not, the pkg is
|
|
|
|
# likely a completely new directory and should not be looked at.
|
|
|
|
dest = "%s/%s" % (get_python_lib(), pkg)
|
|
|
|
if not os.access(dest, os.R_OK):
|
|
|
|
dest = "%s/%s" % (get_python_lib(1), pkg)
|
|
|
|
if not os.access(dest, os.R_OK):
|
|
|
|
continue
|
|
|
|
# Symlink over everything that's in the python libdir but not in
|
|
|
|
# the updates directory.
|
2013-01-23 17:28:19 +00:00
|
|
|
symlink_updates(dest, d)
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
gi.overrides.__path__.insert(0, "/run/install/updates")
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
import glob
|
|
|
|
import shutil
|
|
|
|
for rule in glob.glob("/tmp/updates/*.rules"):
|
|
|
|
target = "/etc/udev/rules.d/" + rule.split('/')[-1]
|
|
|
|
shutil.copyfile(rule, target)
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
def symlink_updates(dest_dir, update_dir):
|
2013-01-23 17:28:19 +00:00
|
|
|
contents = os.listdir(update_dir)
|
|
|
|
|
|
|
|
for f in os.listdir(dest_dir):
|
|
|
|
dest_path = os.path.join(dest_dir, f)
|
|
|
|
update_path = os.path.join(update_dir, f)
|
|
|
|
if f in contents:
|
|
|
|
# recurse into directories, there might be files missing in updates
|
|
|
|
if os.path.isdir(dest_path) and os.path.isdir(update_path):
|
|
|
|
symlink_updates(dest_path, update_path)
|
|
|
|
else:
|
2011-01-18 09:24:57 +00:00
|
|
|
if f.endswith(".pyc") or f.endswith(".pyo"):
|
|
|
|
continue
|
2013-01-23 17:28:19 +00:00
|
|
|
os.symlink(dest_path, update_path)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
def getAnacondaVersionString():
|
|
|
|
# we are importing the startup module directly so that it can be replaced
|
|
|
|
# by updates image, if it was replaced before the updates image can be
|
|
|
|
# loaded, it could not be easily replaced
|
|
|
|
from pyanaconda import startup_utils
|
|
|
|
return startup_utils.get_anaconda_version_string()
|
|
|
|
|
|
|
|
|
|
|
|
def parseArguments(argv=None, boot_cmdline=None):
|
2017-01-09 02:09:07 +00:00
|
|
|
from pyanaconda.anaconda_argparse import getArgumentParser
|
|
|
|
ap = getArgumentParser(getAnacondaVersionString(), boot_cmdline)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
namespace = ap.parse_args(argv, boot_cmdline=boot_cmdline)
|
|
|
|
return (namespace, ap.deprecated_bootargs)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
def setupPythonPath():
|
2013-01-23 17:28:19 +00:00
|
|
|
# First add our updates path
|
|
|
|
sys.path.insert(0, '/tmp/updates/')
|
2014-04-07 12:38:09 +00:00
|
|
|
|
|
|
|
from pyanaconda.constants import ADDON_PATHS
|
|
|
|
# append ADDON_PATHS dirs at the end
|
|
|
|
sys.path.extend(ADDON_PATHS)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
def setupEnvironment():
|
2015-05-30 11:20:59 +00:00
|
|
|
# This method is run before any threads are started, so this is the one
|
|
|
|
# point where it's ok to modify the environment.
|
|
|
|
# pylint: disable=environment-modify
|
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
# Silly GNOME stuff
|
2015-03-23 11:36:12 +00:00
|
|
|
if 'HOME' in os.environ and not "XAUTHORITY" in os.environ:
|
2011-01-18 09:24:57 +00:00
|
|
|
os.environ['XAUTHORITY'] = os.environ['HOME'] + '/.Xauthority'
|
|
|
|
os.environ['HOME'] = '/tmp'
|
|
|
|
os.environ['LC_NUMERIC'] = 'C'
|
|
|
|
os.environ["GCONF_GLOBAL_LOCKS"] = "1"
|
|
|
|
|
|
|
|
# In theory, this gets rid of our LVM file descriptor warnings
|
|
|
|
os.environ["LVM_SUPPRESS_FD_WARNINGS"] = "1"
|
|
|
|
|
|
|
|
# make sure we have /sbin and /usr/sbin in our path
|
|
|
|
os.environ["PATH"] += ":/sbin:/usr/sbin"
|
|
|
|
|
|
|
|
# we can't let the LD_PRELOAD hang around because it will leak into
|
|
|
|
# rpm %post and the like. ick :/
|
2015-03-23 11:36:12 +00:00
|
|
|
if "LD_PRELOAD" in os.environ:
|
2011-01-18 09:24:57 +00:00
|
|
|
del os.environ["LD_PRELOAD"]
|
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
# Go ahead and set $DISPLAY whether we're going to use X or not
|
|
|
|
if 'DISPLAY' in os.environ:
|
|
|
|
flags.preexisting_x11 = True
|
|
|
|
else:
|
|
|
|
os.environ["DISPLAY"] = ":%s" % constants.X_DISPLAY_NUMBER
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
def setupLoggingFromOpts(options):
|
2015-03-23 11:36:12 +00:00
|
|
|
if (options.debug or options.updateSrc) and not options.loglevel:
|
|
|
|
# debugging means debug logging if an explicit level hasn't been st
|
2014-04-07 12:38:09 +00:00
|
|
|
options.loglevel = "debug"
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
if options.loglevel and options.loglevel in anaconda_log.logLevelMap:
|
|
|
|
log.info("Switching logging level to %s", options.loglevel)
|
|
|
|
level = anaconda_log.logLevelMap[options.loglevel]
|
2015-05-30 11:20:59 +00:00
|
|
|
anaconda_log.logger.loglevel = level
|
2011-01-18 09:24:57 +00:00
|
|
|
anaconda_log.setHandlersLevel(log, level)
|
2013-01-23 17:28:19 +00:00
|
|
|
storage_log = logging.getLogger("storage")
|
|
|
|
anaconda_log.setHandlersLevel(storage_log, level)
|
2015-03-23 11:36:12 +00:00
|
|
|
packaging_log = logging.getLogger("packaging")
|
|
|
|
anaconda_log.setHandlersLevel(packaging_log, level)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
if can_touch_runtime_system("syslog setup"):
|
|
|
|
if options.syslog:
|
|
|
|
anaconda_log.logger.updateRemote(options.syslog)
|
|
|
|
|
|
|
|
if options.remotelog:
|
|
|
|
try:
|
|
|
|
host, port = options.remotelog.split(":", 1)
|
|
|
|
port = int(port)
|
|
|
|
anaconda_log.logger.setup_remotelog(host, port)
|
|
|
|
except ValueError:
|
|
|
|
log.error("Could not setup remotelog with %s", options.remotelog)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
def gtk_warning(title, reason):
|
2016-04-10 04:00:00 +00:00
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "3.0")
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
from gi.repository import Gtk
|
2015-03-23 11:36:12 +00:00
|
|
|
dialog = Gtk.MessageDialog(type=Gtk.MessageType.ERROR,
|
|
|
|
buttons=Gtk.ButtonsType.CLOSE,
|
2013-01-23 17:28:19 +00:00
|
|
|
message_format=reason)
|
|
|
|
dialog.set_title(title)
|
|
|
|
dialog.run()
|
|
|
|
dialog.destroy()
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# pylint: disable=redefined-outer-name
|
2014-04-07 12:38:09 +00:00
|
|
|
def check_memory(anaconda, options, display_mode=None):
|
2015-03-23 11:36:12 +00:00
|
|
|
from pyanaconda import isys
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
reason_strict = _("%(product_name)s requires %(needed_ram)s MB of memory to "
|
|
|
|
"install, but you only have %(total_ram)s MB on this machine.\n")
|
|
|
|
reason_graphical = _("The %(product_name)s graphical installer requires %(needed_ram)s "
|
2015-03-23 11:36:12 +00:00
|
|
|
"MB of memory, but you only have %(total_ram)s MB\n.")
|
2013-01-23 17:28:19 +00:00
|
|
|
|
|
|
|
reboot_extra = _('\n'
|
2017-01-09 02:09:07 +00:00
|
|
|
'Press [Enter] to reboot your system.\n')
|
2013-01-23 17:28:19 +00:00
|
|
|
livecd_title = _("Not enough RAM")
|
2015-03-23 11:36:12 +00:00
|
|
|
livecd_extra = _(" Try the text mode installer by running:\n\n"
|
|
|
|
"'/usr/bin/liveinst -T'\n\n from a root "
|
|
|
|
"terminal.")
|
2013-01-23 17:28:19 +00:00
|
|
|
nolivecd_extra = _(" Starting text mode.")
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if options.rescue:
|
|
|
|
return
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if not display_mode:
|
|
|
|
display_mode = anaconda.displayMode
|
|
|
|
|
|
|
|
reason = reason_strict
|
2017-01-09 02:09:07 +00:00
|
|
|
total_ram = int(isys.total_memory() / 1024)
|
2015-03-23 11:36:12 +00:00
|
|
|
needed_ram = int(isys.MIN_RAM)
|
|
|
|
graphical_ram = int(isys.MIN_GUI_RAM)
|
|
|
|
|
|
|
|
# count the squashfs.img in if it is kept in RAM
|
2017-01-09 02:09:07 +00:00
|
|
|
if not iutil.persistent_root_image():
|
2015-03-23 11:36:12 +00:00
|
|
|
needed_ram += isys.SQUASHFS_EXTRA_RAM
|
|
|
|
graphical_ram += isys.SQUASHFS_EXTRA_RAM
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
log.info("check_memory(): total:%s, needed:%s, graphical:%s",
|
|
|
|
total_ram, needed_ram, graphical_ram)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if not options.memcheck:
|
2013-01-23 17:28:19 +00:00
|
|
|
log.warning("CHECK_MEMORY DISABLED")
|
|
|
|
return
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
reason_args = {"product_name": product.productName,
|
|
|
|
"needed_ram": needed_ram,
|
|
|
|
"total_ram": total_ram}
|
2013-01-23 17:28:19 +00:00
|
|
|
if needed_ram > total_ram:
|
2014-04-07 12:38:09 +00:00
|
|
|
if options.liveinst:
|
2015-03-23 11:36:12 +00:00
|
|
|
# pylint: disable=logging-not-lazy
|
|
|
|
stdoutLog.warning(reason % reason_args)
|
2014-04-07 12:38:09 +00:00
|
|
|
gtk_warning(livecd_title, reason % reason_args)
|
2013-01-23 17:28:19 +00:00
|
|
|
else:
|
|
|
|
reason += reboot_extra
|
2016-04-10 04:00:00 +00:00
|
|
|
print(reason % reason_args)
|
|
|
|
print(_("The installation cannot continue and the system will be rebooted"))
|
|
|
|
print(_("Press ENTER to continue"))
|
|
|
|
input()
|
2015-05-30 11:20:59 +00:00
|
|
|
|
|
|
|
iutil.ipmi_report(constants.IPMI_ABORTED)
|
2013-01-23 17:28:19 +00:00
|
|
|
sys.exit(1)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# override display mode if machine cannot nicely run X
|
|
|
|
if display_mode not in ('t', 'c', 's') and not flags.usevnc:
|
2015-03-23 11:36:12 +00:00
|
|
|
needed_ram = graphical_ram
|
2014-04-07 12:38:09 +00:00
|
|
|
reason_args["needed_ram"] = graphical_ram
|
2013-01-23 17:28:19 +00:00
|
|
|
reason = reason_graphical
|
|
|
|
|
|
|
|
if needed_ram > total_ram:
|
2014-04-07 12:38:09 +00:00
|
|
|
if options.liveinst:
|
2013-01-23 17:28:19 +00:00
|
|
|
reason += livecd_extra
|
2015-03-23 11:36:12 +00:00
|
|
|
# pylint: disable=logging-not-lazy
|
|
|
|
stdoutLog.warning(reason % reason_args)
|
2013-01-23 17:28:19 +00:00
|
|
|
title = livecd_title
|
2014-04-07 12:38:09 +00:00
|
|
|
gtk_warning(title, reason % reason_args)
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.ipmi_report(constants.IPMI_ABORTED)
|
2013-01-23 17:28:19 +00:00
|
|
|
sys.exit(1)
|
2011-01-18 09:24:57 +00:00
|
|
|
else:
|
2013-01-23 17:28:19 +00:00
|
|
|
reason += nolivecd_extra
|
2015-03-23 11:36:12 +00:00
|
|
|
# pylint: disable=logging-not-lazy
|
|
|
|
stdoutLog.warning(reason % reason_args)
|
2013-01-23 17:28:19 +00:00
|
|
|
anaconda.displayMode = 't'
|
|
|
|
time.sleep(2)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
def startDebugger(signum, frame):
|
2015-03-23 11:36:12 +00:00
|
|
|
# pylint: disable=import-error
|
2013-01-23 17:28:19 +00:00
|
|
|
import epdb
|
|
|
|
epdb.serve(skip=1)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# pylint: disable=redefined-outer-name
|
2014-04-07 12:38:09 +00:00
|
|
|
def setupDisplay(anaconda, options, addons=None):
|
2013-01-23 17:28:19 +00:00
|
|
|
from pyanaconda.ui.tui.simpleline import App
|
|
|
|
from pyanaconda.ui.tui.spokes.askvnc import AskVNCSpoke
|
|
|
|
from pykickstart.constants import DISPLAY_MODE_TEXT
|
2014-04-07 12:38:09 +00:00
|
|
|
from pyanaconda.nm import nm_is_connected, nm_is_connecting
|
|
|
|
from blivet import arch
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
graphical_failed = 0
|
|
|
|
vncS = vnc.VncServer() # The vnc Server object.
|
|
|
|
vncS.anaconda = anaconda
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
anaconda.displayMode = options.display_mode
|
2017-01-09 02:09:07 +00:00
|
|
|
anaconda.isHeadless = arch.is_s390()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if options.vnc:
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.usevnc = True
|
2013-01-23 17:28:19 +00:00
|
|
|
anaconda.displayMode = 'g'
|
2014-04-07 12:38:09 +00:00
|
|
|
vncS.password = options.vncpassword
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# Only consider vncconnect when vnc is a param
|
2014-04-07 12:38:09 +00:00
|
|
|
if options.vncconnect:
|
2015-05-30 11:20:59 +00:00
|
|
|
cargs = options.vncconnect.split(":")
|
2013-01-23 17:28:19 +00:00
|
|
|
vncS.vncconnecthost = cargs[0]
|
|
|
|
if len(cargs) > 1 and len(cargs[1]) > 0:
|
|
|
|
if len(cargs[1]) > 0:
|
|
|
|
vncS.vncconnectport = cargs[1]
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if options.xdriver:
|
|
|
|
anaconda.xdriver = options.xdriver
|
2013-01-23 17:28:19 +00:00
|
|
|
anaconda.writeXdriver(root="/")
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
if flags.rescue_mode:
|
2011-01-18 09:24:57 +00:00
|
|
|
return
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if anaconda.ksdata.vnc.enabled:
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.usevnc = True
|
2013-01-23 17:28:19 +00:00
|
|
|
anaconda.displayMode = 'g'
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if vncS.password == "":
|
|
|
|
vncS.password = anaconda.ksdata.vnc.password
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if vncS.vncconnecthost == "":
|
|
|
|
vncS.vncconnecthost = anaconda.ksdata.vnc.host
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if vncS.vncconnectport == "":
|
|
|
|
vncS.vncconnectport = anaconda.ksdata.vnc.port
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
if anaconda.displayMode == "g":
|
|
|
|
import pkgutil
|
|
|
|
import pyanaconda.ui
|
|
|
|
|
|
|
|
mods = (tup[1] for tup in pkgutil.iter_modules(pyanaconda.ui.__path__, "pyanaconda.ui."))
|
|
|
|
if "pyanaconda.ui.gui" not in mods:
|
|
|
|
stdoutLog.warning("Graphical user interface not available, falling back to text mode")
|
|
|
|
anaconda.displayMode = "t"
|
|
|
|
flags.usevnc = False
|
|
|
|
flags.vncquestion = False
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# disable VNC over text question when not enough memory is available
|
2014-04-07 12:38:09 +00:00
|
|
|
if blivet.util.total_memory() < isys.MIN_GUI_RAM:
|
|
|
|
stdoutLog.warning("Not asking for VNC because current memory (%d) < MIN_GUI_RAM (%d)", blivet.util.total_memory(), isys.MIN_GUI_RAM)
|
2013-01-23 17:28:19 +00:00
|
|
|
flags.vncquestion = False
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# disable VNC question if text mode is requested and this is a ks install
|
|
|
|
if anaconda.displayMode == 't' and flags.automatedInstall:
|
2014-04-07 12:38:09 +00:00
|
|
|
stdoutLog.warning("Not asking for VNC because of an automated install")
|
2013-01-23 17:28:19 +00:00
|
|
|
flags.vncquestion = False
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# disable VNC question if we were explicitly asked for text in kickstart
|
|
|
|
if anaconda.ksdata.displaymode.displayMode == DISPLAY_MODE_TEXT:
|
2014-04-07 12:38:09 +00:00
|
|
|
stdoutLog.warning("Not asking for VNC because text mode was explicitly asked for in kickstart")
|
2013-01-23 17:28:19 +00:00
|
|
|
flags.vncquestion = False
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# disable VNC question if we don't have network
|
2014-04-07 12:38:09 +00:00
|
|
|
if not nm_is_connecting() and not nm_is_connected():
|
|
|
|
stdoutLog.warning("Not asking for VNC because we don't have a network")
|
2013-01-23 17:28:19 +00:00
|
|
|
flags.vncquestion = False
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
# disable VNC question if we don't have Xvnc
|
2013-01-23 17:28:19 +00:00
|
|
|
if not os.access('/usr/bin/Xvnc', os.X_OK):
|
2014-04-07 12:38:09 +00:00
|
|
|
stdoutLog.warning("Not asking for VNC because we don't have Xvnc")
|
2013-01-23 17:28:19 +00:00
|
|
|
flags.vncquestion = False
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# Should we try to start Xorg?
|
|
|
|
want_x = anaconda.displayMode == 'g' and \
|
|
|
|
not (flags.preexisting_x11 or flags.usevnc)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# X on a headless (e.g. s390) system? Nonsense!
|
|
|
|
if want_x and anaconda.isHeadless:
|
|
|
|
stdoutLog.warning(_("DISPLAY variable not set. Starting text mode."))
|
|
|
|
anaconda.displayMode = 't'
|
|
|
|
graphical_failed = 1
|
|
|
|
time.sleep(2)
|
|
|
|
want_x = False
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# Is Xorg is actually available?
|
|
|
|
if want_x and not os.access("/usr/bin/Xorg", os.X_OK):
|
|
|
|
stdoutLog.warning(_("Graphical installation is not available. "
|
|
|
|
"Starting text mode."))
|
|
|
|
time.sleep(2)
|
|
|
|
anaconda.displayMode = 't'
|
|
|
|
want_x = False
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if anaconda.displayMode == 't' and flags.vncquestion:
|
|
|
|
#we prefer vnc over text mode, so ask about that
|
|
|
|
message = _("Text mode provides a limited set of installation "
|
|
|
|
"options. It does not offer custom partitioning for "
|
|
|
|
"full control over the disk layout. Would you like "
|
|
|
|
"to use VNC mode instead?")
|
|
|
|
|
|
|
|
app = App("VNC Question")
|
|
|
|
spoke = AskVNCSpoke(app, anaconda.ksdata, message=message)
|
|
|
|
app.schedule_screen(spoke)
|
|
|
|
app.run()
|
|
|
|
|
|
|
|
if anaconda.ksdata.vnc.enabled:
|
|
|
|
anaconda.displayMode = 'g'
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.usevnc = True
|
2014-04-07 12:38:09 +00:00
|
|
|
vncS.password = anaconda.ksdata.vnc.password
|
2016-04-10 04:00:00 +00:00
|
|
|
else:
|
|
|
|
# user has explicitly specified text mode
|
|
|
|
flags.vncquestion = False
|
2014-04-07 12:38:09 +00:00
|
|
|
|
|
|
|
log.info("Display mode = %s", anaconda.displayMode)
|
|
|
|
check_memory(anaconda, options)
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# check_memory may have changed the display mode
|
|
|
|
want_x = want_x and (anaconda.displayMode == "g")
|
2013-01-23 17:28:19 +00:00
|
|
|
if want_x:
|
|
|
|
try:
|
2015-03-23 11:36:12 +00:00
|
|
|
startX11()
|
2013-01-23 17:28:19 +00:00
|
|
|
doStartupX11Actions()
|
2015-03-23 11:36:12 +00:00
|
|
|
except (OSError, RuntimeError) as e:
|
|
|
|
log.warning("X startup failed: %s", e)
|
2017-09-04 00:11:01 +00:00
|
|
|
stdoutLog.warning("X startup failed, aborting installation")
|
|
|
|
stdoutLog.error("X startup failed, aborting installation")
|
|
|
|
print(_("The installation cannot continue and the system will be rebooted"))
|
|
|
|
print(_("Press ENTER to continue"))
|
|
|
|
input()
|
|
|
|
iutil.ipmi_report(constants.IPMI_ABORTED)
|
|
|
|
sys.exit(1)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if not graphical_failed:
|
|
|
|
doExtraX11Actions(options.runres)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
|
|
|
if anaconda.displayMode == 't' and graphical_failed and \
|
|
|
|
flags.vncquestion and not anaconda.ksdata.vnc.enabled:
|
|
|
|
app = App("VNC Question")
|
|
|
|
spoke = AskVNCSpoke(app, anaconda.ksdata)
|
|
|
|
app.schedule_screen(spoke)
|
|
|
|
app.run()
|
|
|
|
|
|
|
|
if anaconda.ksdata.vnc.enabled:
|
|
|
|
anaconda.displayMode = 'g'
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.usevnc = True
|
2013-01-23 17:28:19 +00:00
|
|
|
vncS.password = anaconda.ksdata.vnc.password
|
|
|
|
|
|
|
|
# if they want us to use VNC do that now
|
|
|
|
if anaconda.displayMode == 'g' and flags.usevnc:
|
|
|
|
vncS.startServer()
|
|
|
|
doStartupX11Actions()
|
|
|
|
|
|
|
|
# with X running we can initialize the UI interface
|
2014-04-07 12:38:09 +00:00
|
|
|
anaconda.initInterface(addons)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
|
|
|
anaconda.instClass.configure(anaconda)
|
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
# report if starting the GUI failed
|
|
|
|
anaconda.gui_startup_failed = bool(graphical_failed)
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
def prompt_for_ssh():
|
|
|
|
# Do some work here to get the ip addr / hostname to pass
|
|
|
|
# to the user.
|
|
|
|
import socket
|
|
|
|
|
|
|
|
ip = network.getFirstRealIP()
|
|
|
|
|
|
|
|
if not ip:
|
|
|
|
stdoutLog.error("No IP addresses found, cannot continue installation.")
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.ipmi_report(constants.IPMI_ABORTED)
|
2013-01-23 17:28:19 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
ipstr = ip
|
|
|
|
|
|
|
|
try:
|
|
|
|
hinfo = socket.gethostbyaddr(ipstr)
|
2014-04-07 12:38:09 +00:00
|
|
|
except socket.herror as e:
|
|
|
|
stdoutLog.debug("Exception caught trying to get host name of %s: %s", ipstr, e)
|
|
|
|
name = network.getHostname()
|
2013-01-23 17:28:19 +00:00
|
|
|
else:
|
|
|
|
if len(hinfo) == 3:
|
|
|
|
name = hinfo[0]
|
|
|
|
|
|
|
|
if ip.find(':') != -1:
|
|
|
|
ipstr = "[%s]" % (ip,)
|
|
|
|
|
|
|
|
if (name is not None) and (not name.startswith('localhost')) and (ipstr is not None):
|
|
|
|
connxinfo = "%s (%s)" % (socket.getfqdn(name=name), ipstr,)
|
|
|
|
elif ipstr is not None:
|
|
|
|
connxinfo = "%s" % (ipstr,)
|
|
|
|
else:
|
|
|
|
connxinfo = None
|
|
|
|
|
|
|
|
if connxinfo:
|
2014-04-07 12:38:09 +00:00
|
|
|
stdoutLog.info(_("Please ssh install@%s to begin the install."), connxinfo)
|
2013-01-23 17:28:19 +00:00
|
|
|
else:
|
2017-01-09 02:09:07 +00:00
|
|
|
stdoutLog.info(_("Please ssh install@HOSTNAME to continue installation."))
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
def cleanPStore():
|
|
|
|
"""remove files stored in nonvolatile ram created by the pstore subsystem"""
|
|
|
|
|
|
|
|
# files in pstore are linux (not distribution) specific, but we want to
|
|
|
|
# make sure the entirity of them are removed so as to ensure that there
|
|
|
|
# is sufficient free space on the flash part. On some machines this will
|
|
|
|
# take effect immediately, which is the best case. Unfortunately on some,
|
|
|
|
# an intervening reboot is needed."""
|
2017-01-09 02:09:07 +00:00
|
|
|
iutil.dir_tree_map("/sys/fs/pstore", os.unlink, files=True, dirs=False)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2015-03-23 11:36:12 +00:00
|
|
|
# check if the CLI help is requested and return it at once,
|
|
|
|
# without importing random stuff and spamming stdout
|
|
|
|
if ("--help" in sys.argv) or ("-h" in sys.argv) or ("--version" in sys.argv):
|
|
|
|
# we skip the full logging initialisation, but we need to do at least
|
|
|
|
# this much (redirect any log messages to stdout) to get rid of the
|
|
|
|
# harmless but annoying "no handlers found" message on stdout
|
|
|
|
import logging
|
|
|
|
log = logging.getLogger("anaconda")
|
|
|
|
log.addHandler(logging.StreamHandler(stream=sys.stdout))
|
|
|
|
parseArguments()
|
|
|
|
|
|
|
|
print("Starting installer, one moment...")
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
# Allow a file to be loaded as early as possible
|
|
|
|
try:
|
2015-03-23 11:36:12 +00:00
|
|
|
# pylint: disable=import-error,unused-import
|
2011-01-18 09:24:57 +00:00
|
|
|
import updates_disk_hook
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# this handles setting up updates for pypackages to minimize the set needed
|
|
|
|
setupPythonUpdates()
|
|
|
|
setupPythonPath()
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
# init threading before Gtk can do anything and before we start using threads
|
|
|
|
# initThreading initializes the threadMgr instance, import it afterwards
|
|
|
|
from pyanaconda.threads import initThreading, AnacondaThread
|
|
|
|
initThreading()
|
|
|
|
from pyanaconda.threads import threadMgr
|
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
from pyanaconda.i18n import _
|
2014-04-07 12:38:09 +00:00
|
|
|
|
|
|
|
from pyanaconda import constants
|
|
|
|
from pyanaconda.addons import collect_addon_paths
|
|
|
|
from pyanaconda import geoloc
|
2017-01-09 02:09:07 +00:00
|
|
|
from pyanaconda import iutil
|
2014-04-07 12:38:09 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# do this early so we can set flags before initializing logging
|
2014-04-07 12:38:09 +00:00
|
|
|
from pyanaconda.flags import flags, can_touch_runtime_system
|
2015-03-23 11:36:12 +00:00
|
|
|
(opts, depr) = parseArguments(boot_cmdline=flags.cmdline)
|
2014-04-07 12:38:09 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
if opts.images:
|
|
|
|
flags.imageInstall = True
|
|
|
|
elif opts.dirinstall:
|
|
|
|
flags.dirInstall = True
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
# Set up logging as early as possible.
|
|
|
|
import logging
|
2013-01-23 17:28:19 +00:00
|
|
|
from pyanaconda import anaconda_log
|
|
|
|
anaconda_log.init()
|
|
|
|
anaconda_log.logger.setupVirtio()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
from pyanaconda import network
|
|
|
|
network.setup_ifcfg_log()
|
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
log = logging.getLogger("anaconda")
|
|
|
|
stdoutLog = logging.getLogger("anaconda.stdout")
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if os.geteuid() != 0:
|
|
|
|
stdoutLog.error("anaconda must be run as root.")
|
2015-03-23 11:36:12 +00:00
|
|
|
sys.exit(1)
|
2014-04-07 12:38:09 +00:00
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
# check if input kickstart should be saved
|
|
|
|
if flags.nosave_input_ks:
|
|
|
|
log.warning("Input kickstart will not be saved to the installed system due to the nosave option.")
|
|
|
|
iutil.touch('/tmp/NOSAVE_INPUT_KS')
|
|
|
|
|
|
|
|
# check if logs should be saved
|
|
|
|
if flags.nosave_logs:
|
|
|
|
log.warning("Installation logs will not be saved to the installed system due to the nosave option.")
|
|
|
|
iutil.touch('/tmp/NOSAVE_LOGS')
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# see if we're on s390x and if we've got an ssh connection
|
|
|
|
uname = os.uname()
|
|
|
|
if uname[4] == 's390x':
|
2015-05-30 11:20:59 +00:00
|
|
|
if 'TMUX' not in os.environ and 'ks' not in flags.cmdline and not flags.imageInstall:
|
2013-01-23 17:28:19 +00:00
|
|
|
prompt_for_ssh()
|
|
|
|
sys.exit(0)
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
log.info("%s %s", sys.argv[0], getAnacondaVersionString())
|
|
|
|
if os.path.exists("/tmp/updates"):
|
|
|
|
log.info("Using updates in /tmp/updates/ from %s", opts.updateSrc)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
|
|
|
# TODO: uncomment this when we're sure that we're doing the right thing
|
|
|
|
# with flags.cmdline *everywhere* it appears...
|
|
|
|
#for arg in depr:
|
|
|
|
# stdoutLog.warn("Boot argument '%s' is deprecated. "
|
|
|
|
# "In the future, use 'inst.%s'.", arg, arg)
|
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
# pull this in to get product name and versioning
|
2013-01-23 17:28:19 +00:00
|
|
|
from pyanaconda import product
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
from pyanaconda import isys
|
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.ipmi_report(constants.IPMI_STARTED)
|
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
if (opts.images or opts.dirinstall) and opts.liveinst:
|
|
|
|
stdoutLog.error("--liveinst cannot be used with --images or --dirinstall")
|
|
|
|
iutil.ipmi_report(constants.IPMI_ABORTED)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
if opts.images and opts.dirinstall:
|
|
|
|
stdoutLog.error("--images and --dirinstall cannot be used at the same time")
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.ipmi_report(constants.IPMI_ABORTED)
|
2015-03-23 11:36:12 +00:00
|
|
|
sys.exit(1)
|
|
|
|
elif opts.dirinstall:
|
2017-01-09 02:09:07 +00:00
|
|
|
root_path = opts.dirinstall
|
2015-03-23 11:36:12 +00:00
|
|
|
iutil.setTargetPhysicalRoot(root_path)
|
|
|
|
iutil.setSysroot(root_path)
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
from pyanaconda import vnc
|
|
|
|
from pyanaconda import kickstart
|
|
|
|
from pyanaconda import ntp
|
|
|
|
from pyanaconda import keyboard
|
2015-03-23 11:36:12 +00:00
|
|
|
from pyanaconda.iutil import ProxyString, ProxyStringError
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
verdesc = "%s for %s %s" % (getAnacondaVersionString(),
|
2013-01-23 17:28:19 +00:00
|
|
|
product.productName, product.productVersion)
|
2015-03-23 11:36:12 +00:00
|
|
|
|
|
|
|
logs_note = " * installation log files are stored in /tmp during the installation"
|
|
|
|
shell_and_tmux_note = " * shell is available on TTY2"
|
|
|
|
shell_only_note = " * shell is available on TTY2 and in second TMUX pane (ctrl+b, then press 2)"
|
|
|
|
tmux_only_note = " * shell is available in second TMUX pane (ctrl+b, then press 2)"
|
|
|
|
text_mode_note = " * if the graphical installation interface fails to start, try again with the\n"\
|
|
|
|
" inst.text bootoption to start text installation"
|
|
|
|
separate_attachements_note = " * when reporting a bug add logs from /tmp as separate text/plain attachments"
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if product.isFinal:
|
2015-03-23 11:36:12 +00:00
|
|
|
print("anaconda %s started." % verdesc)
|
2013-01-23 17:28:19 +00:00
|
|
|
else:
|
2015-03-23 11:36:12 +00:00
|
|
|
print("anaconda %s (pre-release) started." % verdesc)
|
|
|
|
|
|
|
|
# we are past the --version and --help shortcut so we can import Blivet
|
|
|
|
# now without slowing down anything critical
|
|
|
|
|
|
|
|
# pylint: disable=import-error
|
|
|
|
from blivet import arch
|
|
|
|
|
|
|
|
if not opts.images and not opts.dirinstall:
|
|
|
|
print(logs_note)
|
|
|
|
# no fancy stuff like TTYs on a s390...
|
2017-01-09 02:09:07 +00:00
|
|
|
if not arch.is_s390():
|
2015-03-23 11:36:12 +00:00
|
|
|
if "TMUX" in os.environ and os.environ.get("TERM") == "screen":
|
|
|
|
print(shell_and_tmux_note)
|
|
|
|
else:
|
|
|
|
print(shell_only_note) # TMUX is not running
|
|
|
|
# ...but there is apparently TMUX during the manual installation on s390!
|
|
|
|
elif not opts.ksfile:
|
|
|
|
print(tmux_only_note) # but not during kickstart installation
|
|
|
|
# no need to tell users how to switch to text mode
|
|
|
|
# if already in text mode
|
|
|
|
if opts.display_mode == 'g':
|
|
|
|
print(text_mode_note)
|
|
|
|
print(separate_attachements_note)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
from pyanaconda.anaconda import Anaconda
|
2011-01-18 09:24:57 +00:00
|
|
|
anaconda = Anaconda()
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.setup_translations()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
# reset python's default SIGINT handler
|
2014-04-07 12:38:09 +00:00
|
|
|
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
|
|
|
signal.signal(signal.SIGTERM, lambda num, frame: sys.exit(1))
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
# synchronously-delivered signals such as SIGSEGV and SIGILL cannot be
|
|
|
|
# handled properly from python, so install signal handlers from the C
|
|
|
|
# function in isys.
|
|
|
|
isys.installSyncSignalHandlers()
|
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
setupEnvironment()
|
2015-05-30 11:20:59 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# make sure we have /var/log soon, some programs fail to start without it
|
|
|
|
iutil.mkdirChain("/var/log")
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
# Create a PID file. The exit handler, installed later, will clean it up.
|
|
|
|
pidfile = pid.PidFile(pidname='anaconda', register_term_signal_handler=False)
|
2015-05-30 11:20:59 +00:00
|
|
|
|
|
|
|
try:
|
2016-04-10 04:00:00 +00:00
|
|
|
pidfile.create()
|
|
|
|
except pid.PidFileError as e:
|
|
|
|
log.error("Unable to create %s, exiting", pidfile.filename)
|
2015-05-30 11:20:59 +00:00
|
|
|
|
|
|
|
# If we had a $DISPLAY at start and zenity is available, we may be
|
|
|
|
# running in a live environment and we can display an error dialog.
|
|
|
|
# Otherwise just print an error.
|
|
|
|
if flags.preexisting_x11 and os.access("/usr/bin/zenity", os.X_OK):
|
|
|
|
# The module-level _() calls are ok here because the language may
|
|
|
|
# be set from the live environment in this case, and anaconda's
|
|
|
|
# language setup hasn't happened yet.
|
|
|
|
# pylint: disable=found-_-in-module-class
|
|
|
|
iutil.execWithRedirect("zenity",
|
|
|
|
["--error", "--title", _("Unable to create PID file"), "--text",
|
|
|
|
_("Anaconda is unable to create %s because the file" +
|
|
|
|
" already exists. Anaconda is already running, or a previous instance" +
|
2016-04-10 04:00:00 +00:00
|
|
|
" of anaconda has crashed.") % pidfile.filename])
|
2015-05-30 11:20:59 +00:00
|
|
|
else:
|
2016-04-10 04:00:00 +00:00
|
|
|
print("%s already exists, exiting" % pidfile.filename)
|
2015-05-30 11:20:59 +00:00
|
|
|
|
|
|
|
iutil.ipmi_report(constants.IPMI_FAILED)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
# add our own additional signal handlers
|
|
|
|
signal.signal(signal.SIGHUP, startDebugger)
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
anaconda.opts = opts
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# check memory, just the text mode for now:
|
|
|
|
check_memory(anaconda, opts, 't')
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
# Now that we've got arguments, do some extra processing.
|
|
|
|
setupLoggingFromOpts(opts)
|
|
|
|
|
|
|
|
# Default is to prompt to mount the installed system.
|
|
|
|
anaconda.rescue_mount = not opts.rescue_nomount
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# assign the other anaconda variables from options
|
|
|
|
anaconda.proxy = opts.proxy
|
|
|
|
anaconda.updateSrc = opts.updateSrc
|
|
|
|
anaconda.methodstr = opts.method
|
|
|
|
anaconda.stage2 = opts.stage2
|
|
|
|
flags.rescue_mode = opts.rescue
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2011-01-18 09:24:57 +00:00
|
|
|
if opts.liveinst:
|
2015-03-23 11:36:12 +00:00
|
|
|
from pyanaconda.screensaver import inhibit_screensaver
|
|
|
|
from pyanaconda import safe_dbus
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.livecdInstall = True
|
2014-04-07 12:38:09 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
try:
|
|
|
|
anaconda.dbus_session_connection = safe_dbus.get_new_session_connection()
|
|
|
|
except safe_dbus.DBusCallError as e:
|
|
|
|
log.info("Unable to connect to DBus session bus: %s", e)
|
|
|
|
else:
|
|
|
|
anaconda.dbus_inhibit_id = inhibit_screensaver(anaconda.dbus_session_connection)
|
|
|
|
elif "LIVECMD" in os.environ:
|
|
|
|
log.warning("Running via liveinst, but not setting flags.livecdInstall - this is for testing only")
|
2014-04-07 12:38:09 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# set flags
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.noverifyssl = opts.noverifyssl
|
|
|
|
flags.armPlatform = opts.armPlatform
|
|
|
|
flags.extlinux = opts.extlinux
|
|
|
|
flags.nombr = opts.nombr
|
|
|
|
flags.mpathFriendlyNames = opts.mpathfriendlynames
|
|
|
|
flags.debug = opts.debug
|
|
|
|
flags.askmethod = opts.askmethod
|
2011-01-18 09:24:57 +00:00
|
|
|
flags.dmraid = opts.dmraid
|
|
|
|
flags.mpath = opts.mpath
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.ibft = opts.ibft
|
2011-01-18 09:24:57 +00:00
|
|
|
flags.selinux = opts.selinux
|
2014-04-07 12:38:09 +00:00
|
|
|
flags.eject = opts.eject
|
2016-04-10 04:00:00 +00:00
|
|
|
flags.kexec = opts.kexec
|
2017-01-09 02:09:07 +00:00
|
|
|
flags.singlelang = opts.singlelang
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# Switch to tty1 on exception in case something goes wrong during X start.
|
|
|
|
# This way if, for example, metacity doesn't start, we switch back to a
|
|
|
|
# text console with a traceback instead of being left looking at a blank
|
|
|
|
# screen. python-meh will replace this excepthook with its own handler
|
|
|
|
# once it gets going.
|
2015-05-30 11:20:59 +00:00
|
|
|
if can_touch_runtime_system("early exception handler"):
|
2015-03-23 11:36:12 +00:00
|
|
|
def _earlyExceptionHandler(ty, value, traceback):
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.ipmi_report(constants.IPMI_FAILED)
|
2015-03-23 11:36:12 +00:00
|
|
|
iutil.vtActivate(1)
|
|
|
|
return sys.__excepthook__(ty, value, traceback)
|
|
|
|
|
|
|
|
sys.excepthook = _earlyExceptionHandler
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if can_touch_runtime_system("start audit daemon"):
|
2015-05-30 11:20:59 +00:00
|
|
|
# auditd will turn into a daemon and exit. Ignore startup errors
|
|
|
|
try:
|
|
|
|
iutil.execWithRedirect("/sbin/auditd", [])
|
|
|
|
except OSError:
|
|
|
|
pass
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
# setup links required for all install types
|
2015-03-23 11:36:12 +00:00
|
|
|
for i in ("services", "protocols", "nsswitch.conf", "joe", "selinux",
|
|
|
|
"mke2fs.conf"):
|
2011-01-18 09:24:57 +00:00
|
|
|
try:
|
|
|
|
if os.path.exists("/mnt/runtime/etc/" + i):
|
2015-03-23 11:36:12 +00:00
|
|
|
os.symlink("../mnt/runtime/etc/" + i, "/etc/" + i)
|
2014-04-07 12:38:09 +00:00
|
|
|
except OSError:
|
2011-01-18 09:24:57 +00:00
|
|
|
pass
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
log.info("anaconda called with cmdline = %s", sys.argv)
|
|
|
|
log.info("Default encoding = %s ", sys.getdefaultencoding())
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
# Collect all addon paths
|
|
|
|
addon_paths = collect_addon_paths(constants.ADDON_PATHS)
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# If we were given a kickstart file on the command line, parse (but do not
|
|
|
|
# execute) that now. Otherwise, load in defaults from kickstart files
|
|
|
|
# shipped with the installation media.
|
|
|
|
ksdata = None
|
2015-03-23 11:36:12 +00:00
|
|
|
if opts.ksfile and not opts.liveinst:
|
2015-05-30 11:20:59 +00:00
|
|
|
if not os.path.exists(opts.ksfile):
|
|
|
|
stdoutLog.error("Kickstart file %s is missing.", opts.ksfile)
|
|
|
|
iutil.ipmi_report(constants.IPMI_ABORTED)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
flags.automatedInstall = True
|
2014-04-07 12:38:09 +00:00
|
|
|
flags.eject = False
|
|
|
|
ksFiles = [opts.ksfile]
|
2017-01-09 02:09:07 +00:00
|
|
|
elif os.path.exists("/run/install/ks.cfg") and not opts.liveinst:
|
|
|
|
# this is to handle such cases where a user has pre-loaded a
|
|
|
|
# ks.cfg onto an OEMDRV labeled device
|
|
|
|
flags.automatedInstall = True
|
|
|
|
flags.eject = False
|
|
|
|
ksFiles = ["/run/install/ks.cfg"]
|
2013-01-23 17:28:19 +00:00
|
|
|
else:
|
2014-04-07 12:38:09 +00:00
|
|
|
ksFiles = ["/tmp/updates/interactive-defaults.ks",
|
|
|
|
"/usr/share/anaconda/interactive-defaults.ks"]
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
for ks in ksFiles:
|
|
|
|
if not os.path.exists(ks):
|
2013-01-23 17:28:19 +00:00
|
|
|
continue
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
kickstart.preScriptPass(ks)
|
2015-03-23 11:36:12 +00:00
|
|
|
log.info("Parsing kickstart: " + ks)
|
2014-04-07 12:38:09 +00:00
|
|
|
ksdata = kickstart.parseKickstart(ks)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# Only load the first defaults file we find.
|
|
|
|
break
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if not ksdata:
|
2014-04-07 12:38:09 +00:00
|
|
|
ksdata = kickstart.AnacondaKSHandler(addon_paths["ks"])
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# Pick up any changes from interactive-defaults.ks that would
|
|
|
|
# otherwise be covered by the dracut KS parser.
|
|
|
|
if ksdata.bootloader.extlinux:
|
|
|
|
flags.extlinux = True
|
2013-01-23 17:28:19 +00:00
|
|
|
if ksdata.rescue.rescue:
|
2015-03-23 11:36:12 +00:00
|
|
|
flags.rescue_mode = True
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
# reboot with kexec
|
|
|
|
if ksdata.reboot.kexec:
|
|
|
|
flags.kexec = True
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# Some kickstart commands must be executed immediately, as they affect
|
|
|
|
# how anaconda operates.
|
|
|
|
ksdata.logging.execute()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
anaconda.ksdata = ksdata
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# setup keyboard layout from the command line option and let
|
|
|
|
# it override from kickstart if/when X is initialized
|
|
|
|
if opts.keymap:
|
|
|
|
if not ksdata.keyboard.keyboard:
|
|
|
|
ksdata.keyboard.keyboard = opts.keymap
|
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
if ksdata.keyboard.keyboard:
|
|
|
|
if can_touch_runtime_system("activate keyboard"):
|
|
|
|
keyboard.activate_keyboard(ksdata.keyboard)
|
|
|
|
else:
|
|
|
|
# at least make sure we have all the values
|
|
|
|
keyboard.populate_missing_items(ksdata.keyboard)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
|
|
|
# Some post-install parts of anaconda are implemented as kickstart
|
|
|
|
# scripts. Add those to the ksdata now.
|
|
|
|
kickstart.appendPostScripts(ksdata)
|
|
|
|
|
|
|
|
# cmdline flags override kickstart settings
|
2014-04-07 12:38:09 +00:00
|
|
|
if anaconda.proxy:
|
|
|
|
ksdata.method.proxy = anaconda.proxy
|
2015-03-23 11:36:12 +00:00
|
|
|
|
|
|
|
# Setup proxy environmental variables so that pre/post scripts use it
|
|
|
|
# as well as libreport
|
|
|
|
try:
|
|
|
|
proxy = ProxyString(anaconda.proxy)
|
|
|
|
except ProxyStringError as e:
|
|
|
|
log.info("Failed to parse proxy \"%s\": %s", anaconda.proxy, e)
|
|
|
|
else:
|
|
|
|
# Set environmental variables to be used by pre/post scripts
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.setenv("PROXY", proxy.noauth_url)
|
|
|
|
iutil.setenv("PROXY_USER", proxy.username or "")
|
|
|
|
iutil.setenv("PROXY_PASSWORD", proxy.password or "")
|
2015-03-23 11:36:12 +00:00
|
|
|
|
|
|
|
# Variables used by curl, libreport, etc.
|
2015-05-30 11:20:59 +00:00
|
|
|
iutil.setenv("http_proxy", proxy.url)
|
|
|
|
iutil.setenv("ftp_proxy", proxy.url)
|
|
|
|
iutil.setenv("HTTPS_PROXY", proxy.url)
|
2015-03-23 11:36:12 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if flags.noverifyssl:
|
|
|
|
ksdata.method.noverifyssl = flags.noverifyssl
|
|
|
|
if opts.multiLib:
|
2016-04-10 04:00:00 +00:00
|
|
|
# sets dnf's multilib_policy to "all" (as opposed to "best")
|
2014-04-07 12:38:09 +00:00
|
|
|
ksdata.packages.multiLib = opts.multiLib
|
2013-01-23 17:28:19 +00:00
|
|
|
|
|
|
|
# set ksdata.method based on anaconda.method if it isn't already set
|
2014-04-07 12:38:09 +00:00
|
|
|
if anaconda.methodstr and not ksdata.method.seen:
|
2013-01-23 17:28:19 +00:00
|
|
|
if anaconda.methodstr.startswith("cdrom"):
|
|
|
|
ksdata.method.method = "cdrom"
|
|
|
|
elif anaconda.methodstr.startswith("nfs"):
|
|
|
|
ksdata.method.method = "nfs"
|
2014-04-07 12:38:09 +00:00
|
|
|
(nfsOptions, server, path) = iutil.parseNfsUrl(anaconda.methodstr)
|
2013-01-23 17:28:19 +00:00
|
|
|
ksdata.method.server = server
|
|
|
|
ksdata.method.dir = path
|
2014-04-07 12:38:09 +00:00
|
|
|
ksdata.method.opts = nfsOptions
|
2013-01-23 17:28:19 +00:00
|
|
|
elif anaconda.methodstr.startswith("hd:"):
|
|
|
|
ksdata.method.method = "harddrive"
|
|
|
|
url = anaconda.methodstr.split(":", 1)[1]
|
|
|
|
url_parts = url.split(":")
|
|
|
|
device = url_parts[0]
|
|
|
|
path = ""
|
|
|
|
if len(url_parts) == 2:
|
|
|
|
path = url_parts[1]
|
|
|
|
elif len(url_parts) == 3:
|
|
|
|
fstype = url_parts[1] # XXX not used
|
|
|
|
path = url_parts[2]
|
|
|
|
|
|
|
|
ksdata.method.partition = device
|
|
|
|
ksdata.method.dir = path
|
|
|
|
elif anaconda.methodstr.startswith("http") or \
|
2015-03-23 11:36:12 +00:00
|
|
|
anaconda.methodstr.startswith("ftp") or \
|
|
|
|
anaconda.methodstr.startswith("file"):
|
2013-01-23 17:28:19 +00:00
|
|
|
ksdata.method.method = "url"
|
|
|
|
ksdata.method.url = anaconda.methodstr
|
2014-04-07 12:38:09 +00:00
|
|
|
# installation source specified by bootoption
|
|
|
|
# overrides source set from kickstart;
|
|
|
|
# the kickstart might have specified a mirror list,
|
|
|
|
# so we need to clear it here if plain url source is provided
|
|
|
|
# by a bootoption, because having both url & mirror list
|
2016-04-10 04:00:00 +00:00
|
|
|
# set at once is not supported and breaks dnf in
|
2014-04-07 12:38:09 +00:00
|
|
|
# unpredictable ways
|
2016-04-10 04:00:00 +00:00
|
|
|
# FIXME: Is this still needed for dnf?
|
2014-04-07 12:38:09 +00:00
|
|
|
ksdata.method.mirrorlist = None
|
2013-01-23 17:28:19 +00:00
|
|
|
elif anaconda.methodstr.startswith("livecd"):
|
2014-04-07 12:38:09 +00:00
|
|
|
ksdata.method.method = "harddrive"
|
2013-01-23 17:28:19 +00:00
|
|
|
device = anaconda.methodstr.split(":", 1)[1]
|
|
|
|
ksdata.method.partition = os.path.normpath(device)
|
|
|
|
else:
|
2014-04-07 12:38:09 +00:00
|
|
|
log.error("Unknown method: %s", anaconda.methodstr)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# Override the selinux state from kickstart if set on the command line
|
|
|
|
if flags.selinux != constants.SELINUX_DEFAULT:
|
|
|
|
ksdata.selinux.selinux = flags.selinux
|
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
from pyanaconda import localization
|
2013-01-23 17:28:19 +00:00
|
|
|
# Set the language before loading an interface, when it may be too late.
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
# If the language was set on the command line, copy that to kickstart
|
2015-05-30 11:20:59 +00:00
|
|
|
if opts.lang:
|
2016-04-10 04:00:00 +00:00
|
|
|
ksdata.lang.lang = opts.lang
|
2015-05-30 11:20:59 +00:00
|
|
|
ksdata.lang.seen = True
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
# Setup the locale environment
|
|
|
|
if ksdata.lang.seen:
|
|
|
|
locale_option = ksdata.lang.lang
|
2014-04-07 12:38:09 +00:00
|
|
|
else:
|
2016-04-10 04:00:00 +00:00
|
|
|
locale_option = None
|
|
|
|
localization.setup_locale_environment(locale_option, opts.display_mode != "g")
|
2015-05-30 11:20:59 +00:00
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
# Now that LANG is set, do something with it
|
|
|
|
localization.setup_locale(os.environ["LANG"], ksdata.lang, opts.display_mode != "g")
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
import blivet
|
|
|
|
blivet.enable_installer_mode()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-05-30 11:20:59 +00:00
|
|
|
# Initialize the network now, in case the display needs it
|
|
|
|
from pyanaconda.network import networkInitialize, wait_for_connecting_NM_thread
|
|
|
|
|
|
|
|
networkInitialize(ksdata)
|
|
|
|
threadMgr.add(AnacondaThread(name=constants.THREAD_WAIT_FOR_CONNECTING_NM, target=wait_for_connecting_NM_thread, args=(ksdata,)))
|
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
# initialize the screen access manager before launching the UI
|
|
|
|
from pyanaconda import screen_access
|
|
|
|
screen_access.initSAM()
|
|
|
|
# try to open any existing config file
|
|
|
|
# (might be created by pre-anaconda helper tools, injected during image
|
|
|
|
# generation, etc.)
|
|
|
|
screen_access.sam.open_config_file()
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# now start the interface
|
2014-04-07 12:38:09 +00:00
|
|
|
setupDisplay(anaconda, opts, addon_paths)
|
2016-04-10 04:00:00 +00:00
|
|
|
if anaconda.gui_startup_failed:
|
|
|
|
# we need to reinitialize the locale if GUI startup failed,
|
|
|
|
# as we might now be in text mode, which might not be able to display
|
|
|
|
# the characters from our current locale
|
|
|
|
log.warning("reinitializing locale due to failed attempt to start the GUI")
|
|
|
|
localization.setup_locale(os.environ["LANG"], ksdata.lang, anaconda.displayMode != "g")
|
2014-04-07 12:38:09 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# we now know in which mode we are going to run so store the information
|
|
|
|
from pykickstart.constants import DISPLAY_MODE_GRAPHICAL, DISPLAY_MODE_CMDLINE, DISPLAY_MODE_TEXT
|
|
|
|
mode_char_to_const = {'g': DISPLAY_MODE_GRAPHICAL, 't': DISPLAY_MODE_TEXT, 'c': DISPLAY_MODE_CMDLINE}
|
|
|
|
ksdata.displaymode.displayMode = mode_char_to_const[anaconda.displayMode]
|
|
|
|
|
|
|
|
# if we're in text mode, the resulting system should be too
|
|
|
|
# ...unless the kickstart specified otherwise
|
|
|
|
if anaconda.displayMode != 'g' and not anaconda.ksdata.xconfig.startX:
|
|
|
|
anaconda.ksdata.skipx.skipx = True
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# Set flag to prompt for missing ks data
|
|
|
|
if anaconda.displayMode == 'c':
|
|
|
|
flags.ksprompt = False
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
from pyanaconda.anaconda_argparse import name_path_pairs
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
image_count = 0
|
|
|
|
try:
|
|
|
|
for (name, path) in name_path_pairs(opts.images):
|
|
|
|
log.info("naming disk image '%s' '%s'", path, name)
|
2017-01-09 02:09:07 +00:00
|
|
|
anaconda.storage.config.disk_images[name] = path
|
2015-03-23 11:36:12 +00:00
|
|
|
image_count += 1
|
|
|
|
flags.imageInstall = True
|
|
|
|
except ValueError as e:
|
|
|
|
stdoutLog.error("error specifying image file: %s", e)
|
2017-01-09 02:09:07 +00:00
|
|
|
iutil.ipmi_abort(scripts=ksdata.scripts)
|
2015-03-23 11:36:12 +00:00
|
|
|
sys.exit(1)
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
if image_count:
|
2017-01-09 02:09:07 +00:00
|
|
|
anaconda.storage.setup_disk_images()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2017-01-09 02:09:07 +00:00
|
|
|
from blivet.osinstall import storage_initialize
|
2015-03-23 11:36:12 +00:00
|
|
|
from pyanaconda.packaging import payloadMgr
|
2014-04-07 12:38:09 +00:00
|
|
|
from pyanaconda.timezone import time_initialize
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
if not flags.dirInstall:
|
2017-01-09 02:09:07 +00:00
|
|
|
threadMgr.add(AnacondaThread(name=constants.THREAD_STORAGE, target=storage_initialize,
|
2014-04-07 12:38:09 +00:00
|
|
|
args=(anaconda.storage, ksdata, anaconda.protected)))
|
2016-04-10 04:00:00 +00:00
|
|
|
|
|
|
|
if can_touch_runtime_system("initialize time", touch_live=True):
|
2014-04-07 12:38:09 +00:00
|
|
|
threadMgr.add(AnacondaThread(name=constants.THREAD_TIME_INIT, target=time_initialize,
|
|
|
|
args=(ksdata.timezone, anaconda.storage, anaconda.bootloader)))
|
|
|
|
|
2016-04-10 04:00:00 +00:00
|
|
|
if flags.rescue_mode:
|
|
|
|
from pyanaconda.ui.tui.simpleline import App
|
|
|
|
from pyanaconda.rescue import RescueMode
|
|
|
|
app = App("Rescue Mode")
|
|
|
|
spoke = RescueMode(app, anaconda.ksdata, anaconda.storage)
|
|
|
|
app.schedule_screen(spoke)
|
|
|
|
app.run()
|
|
|
|
else:
|
|
|
|
cleanPStore()
|
|
|
|
|
|
|
|
# only install interactive exception handler in interactive modes
|
|
|
|
if ksdata.displaymode.displayMode != DISPLAY_MODE_CMDLINE or flags.debug:
|
|
|
|
from pyanaconda import exception
|
|
|
|
anaconda.mehConfig = exception.initExceptionHandling(anaconda)
|
|
|
|
|
|
|
|
# add our own additional signal handlers
|
|
|
|
signal.signal(signal.SIGUSR1, lambda signum, frame:
|
|
|
|
exception.test_exception_handling())
|
|
|
|
signal.signal(signal.SIGUSR2, lambda signum, frame: anaconda.dumpState())
|
|
|
|
atexit.register(exitHandler, ksdata.reboot, anaconda.storage)
|
|
|
|
|
|
|
|
from pyanaconda import exception
|
|
|
|
anaconda.mehConfig = exception.initExceptionHandling(anaconda)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2015-03-23 11:36:12 +00:00
|
|
|
# Fallback to default for interactive or for a kickstart with no installation method.
|
|
|
|
fallback = not (flags.automatedInstall and ksdata.method.method)
|
|
|
|
payloadMgr.restartThread(anaconda.storage, ksdata, anaconda.payload, anaconda.instClass,
|
|
|
|
fallback=fallback)
|
2013-01-23 17:28:19 +00:00
|
|
|
|
2014-04-07 12:38:09 +00:00
|
|
|
# check if geolocation should be enabled for this type of installation
|
|
|
|
use_geolocation = True
|
2015-03-23 11:36:12 +00:00
|
|
|
if flags.imageInstall or flags.dirInstall or flags.automatedInstall:
|
2014-04-07 12:38:09 +00:00
|
|
|
use_geolocation = False
|
|
|
|
# and also check if it was not disabled by boot option
|
|
|
|
else:
|
|
|
|
# flags.cmdline.getbool is used as it handles values such as
|
|
|
|
# 0, no, off and also nogeoloc as False
|
|
|
|
# and other values or geoloc not being present as True
|
|
|
|
use_geolocation = flags.cmdline.getbool('geoloc', True)
|
|
|
|
|
|
|
|
if use_geolocation:
|
|
|
|
provider_id = constants.GEOLOC_DEFAULT_PROVIDER
|
|
|
|
# check if a provider was specified by an option
|
|
|
|
if opts.geoloc is not None:
|
|
|
|
parsed_id = geoloc.get_provider_id_from_option(opts.geoloc)
|
|
|
|
if parsed_id is None:
|
|
|
|
log.error('geoloc: wrong provider id specified: %s', opts.geoloc)
|
|
|
|
else:
|
|
|
|
provider_id = parsed_id
|
|
|
|
# instantiate the geolocation module and start location data refresh
|
|
|
|
geoloc.init_geolocation(provider_id=provider_id)
|
|
|
|
geoloc.refresh()
|
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# setup ntp servers and start NTP daemon if not requested otherwise
|
2014-04-07 12:38:09 +00:00
|
|
|
if can_touch_runtime_system("start chronyd"):
|
|
|
|
if anaconda.ksdata.timezone.ntpservers:
|
2015-05-30 11:20:59 +00:00
|
|
|
pools, servers = ntp.internal_to_pools_and_servers(anaconda.ksdata.timezone.ntpservers)
|
|
|
|
ntp.save_servers_to_config(pools, servers)
|
2014-04-07 12:38:09 +00:00
|
|
|
|
|
|
|
if not anaconda.ksdata.timezone.nontp:
|
|
|
|
iutil.start_service("chronyd")
|
2011-01-18 09:24:57 +00:00
|
|
|
|
2013-01-23 17:28:19 +00:00
|
|
|
# FIXME: This will need to be made cleaner once this file starts to take
|
|
|
|
# shape with the new UI code.
|
|
|
|
anaconda._intf.setup(ksdata)
|
|
|
|
anaconda._intf.run()
|
2011-01-18 09:24:57 +00:00
|
|
|
|
|
|
|
# vim:tw=78:ts=4:et:sw=4
|