chore(merge): merge feat/installer-live-log into Main
The installer progress screen can now tail the FWS logs live, so a stalled progress bar can be told apart from a slow mirror without switching to a console.
This commit is contained in:
2 files changed
+294
-2
No files matched your search
@@ -14,7 +14,7 @@ set -euo pipefail
|
||||
# ~3 Mo générés, vs 222 Mo pour le paquet glibc-locales complet.
|
||||
locale-gen
|
||||
|
||||
# --- Overlays pyanaconda (écran de progression FWS) ---------------------------
|
||||
# --- Overlays pyanaconda (écran de progression FWS, journal en direct) ---------------------------
|
||||
# mkarchiso copie l'airootfs AVANT le pacstrap (cf. fws/mkarchiso :
|
||||
# _make_custom_airootfs puis _make_packages) : un fichier de l'airootfs qui
|
||||
# remplace un fichier du paquet « anaconda » fait échouer pacman (« exists in
|
||||
@@ -28,7 +28,8 @@ if [ -d /usr/local/share/fws/anaconda-overlay/pyanaconda ]; then
|
||||
|
||||
# Le build doit s'arrêter net si l'overlay n'a pas atterri : sans lui, plus
|
||||
# d'écran de progression détaillé (mais l'installateur fonctionne quand même).
|
||||
for _f in modules/runtime/scripts/runtime.py modules/boss/installation.py; do
|
||||
for _f in modules/runtime/scripts/runtime.py modules/boss/installation.py \
|
||||
ui/gui/spokes/installation_progress.py; do
|
||||
if [ ! -f "/usr/lib/python3.14/site-packages/pyanaconda/${_f}" ]; then
|
||||
echo "[FWS] overlay pyanaconda manquant : ${_f}" >&2
|
||||
exit 1
|
||||
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
#
|
||||
# Copyright (C) 2011-2013 Red Hat, Inc.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions of
|
||||
# the GNU General Public License v.2, or (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY expressed or implied, including the implied warranties 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., 31 Milk Street #960789 Boston, MA
|
||||
# 02196 USA. Any Red Hat trademarks that are incorporated in the
|
||||
# source code or documentation are not subject to the GNU General Public
|
||||
# License and may only be used or replicated with the express permission of
|
||||
# Red Hat, Inc.
|
||||
#
|
||||
# FWS: this file is an overlay of the upstream Anaconda spoke. The only
|
||||
# addition is a "journal" toggle under the progress bar that reveals a live
|
||||
# tail of the FWS installation logs: the %pre and %post --nochroot logs on
|
||||
# the live, and the chrooted %post log on the target. Without it, a user who
|
||||
# saw the bar stop could not tell a slow mirror from a crash short of
|
||||
# switching to a console, and the failures that matter (no EFI partition,
|
||||
# no initramfs) are written as CRITIQUE in exactly those files.
|
||||
#
|
||||
import os
|
||||
|
||||
import gi
|
||||
|
||||
from pykickstart.constants import KS_REBOOT, KS_SHUTDOWN
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib, Gtk
|
||||
|
||||
from pyanaconda.anaconda_loggers import get_module_logger
|
||||
from pyanaconda.core import util
|
||||
from pyanaconda.core.configuration.anaconda import conf
|
||||
from pyanaconda.core.constants import IPMI_FINISHED
|
||||
from pyanaconda.core.i18n import C_, _
|
||||
from pyanaconda.core.product import get_product_name
|
||||
from pyanaconda.flags import flags
|
||||
from pyanaconda.modules.common.constants.services import RUNTIME
|
||||
from pyanaconda.modules.common.structures.reboot import RebootData
|
||||
from pyanaconda.ui.gui.hubs.summary import SummaryHub
|
||||
from pyanaconda.ui.gui.spokes import StandaloneSpoke
|
||||
from pyanaconda.ui.gui.utils import gtk_call_once
|
||||
from pyanaconda.ui.lib.installation_progress_error import InstallationProgressErrorMixin
|
||||
|
||||
log = get_module_logger(__name__)
|
||||
|
||||
__all__ = ["ProgressSpoke"]
|
||||
|
||||
# Logs shown by the journal toggle, in the order the installation writes them.
|
||||
# The target path is completed with conf.target.system_root at runtime.
|
||||
FWS_LOGS = (
|
||||
("pré-installation (live)", "/tmp/fws-pre.log"),
|
||||
("préparation du disque (live)", "/tmp/fws-post-nochroot.log"),
|
||||
("système installé", "var/log/fws-post.log"),
|
||||
)
|
||||
FWS_LOG_POLL_MS = 1000
|
||||
# A log that is already large when the view opens is shown from its tail.
|
||||
FWS_LOG_BACKLOG = 256 * 1024
|
||||
FWS_LOG_MAX_CHARS = 2_000_000
|
||||
|
||||
|
||||
class ProgressSpoke(StandaloneSpoke, InstallationProgressErrorMixin):
|
||||
"""
|
||||
.. inheritance-diagram:: ProgressSpoke
|
||||
:parts: 3
|
||||
"""
|
||||
|
||||
builderObjects = ["progressWindow"]
|
||||
mainWidgetName = "progressWindow"
|
||||
uiFile = "spokes/installation_progress.glade"
|
||||
postForHub = SummaryHub
|
||||
|
||||
@staticmethod
|
||||
def get_screen_id():
|
||||
"""Return a unique id of this UI screen."""
|
||||
return "installation-progress"
|
||||
|
||||
def __init__(self, data, storage, payload):
|
||||
super().__init__(data, storage, payload)
|
||||
self._progressBar = self.builder.get_object("progressBar")
|
||||
self._progressLabel = self.builder.get_object("progressLabel")
|
||||
self._progressNotebook = self.builder.get_object("progressNotebook")
|
||||
self._spinner = self.builder.get_object("progressSpinner")
|
||||
self._task_proxy = None
|
||||
self._fws_build_log_view()
|
||||
|
||||
@property
|
||||
def completed(self):
|
||||
"""This spoke is never completed, initially."""
|
||||
return False
|
||||
|
||||
def apply(self):
|
||||
"""There is nothing to apply."""
|
||||
pass
|
||||
|
||||
def _on_installation_done(self):
|
||||
log.debug("The installation has finished.")
|
||||
|
||||
# Stop the spinner.
|
||||
gtk_call_once(self._spinner.stop)
|
||||
gtk_call_once(self._spinner.hide)
|
||||
|
||||
# Finish the installation task. Re-raise tracebacks if any.
|
||||
self._task_proxy.Finish()
|
||||
|
||||
util.ipmi_report(IPMI_FINISHED)
|
||||
|
||||
if conf.license.eula:
|
||||
self.set_warning(_("Use of this product is subject to the license agreement "
|
||||
"found at %s") % conf.license.eula)
|
||||
self.window.show_all()
|
||||
|
||||
# Show the reboot message.
|
||||
self._progressNotebook.set_current_page(1)
|
||||
|
||||
# Enable the continue button.
|
||||
self.window.set_may_continue(True)
|
||||
|
||||
# Hide the quit button.
|
||||
quit_button = self.window.get_quit_button()
|
||||
quit_button.hide()
|
||||
|
||||
runtime_proxy = RUNTIME.get_proxy()
|
||||
reboot_data = RebootData.from_structure(runtime_proxy.Reboot)
|
||||
# kickstart install, continue automatically if reboot or shutdown selected
|
||||
if flags.automatedInstall and reboot_data.action in [KS_REBOOT, KS_SHUTDOWN]:
|
||||
self.window.emit("continue-clicked")
|
||||
|
||||
def initialize(self):
|
||||
super().initialize()
|
||||
# Disable the continue button.
|
||||
self.window.set_may_continue(False)
|
||||
|
||||
# Set the label of the continue button.
|
||||
if conf.target.is_hardware and conf.system.can_reboot:
|
||||
continue_label = C_("GUI|Progress", "_Reboot System")
|
||||
else:
|
||||
continue_label = C_("GUI|Progress", "_Finish Installation")
|
||||
|
||||
continue_button = self.window.get_continue_button()
|
||||
continue_button.set_label(continue_label)
|
||||
|
||||
# Set the reboot label.
|
||||
if conf.target.is_hardware:
|
||||
continue_text = _(
|
||||
"%s is now successfully installed and ready for you to use!\n"
|
||||
"Go ahead and reboot your system to start using it!"
|
||||
) % get_product_name()
|
||||
else:
|
||||
continue_text = _(
|
||||
"%s is now successfully installed and ready for you to use!\n"
|
||||
"Go ahead and quit the application to start using it!"
|
||||
) % get_product_name()
|
||||
|
||||
label = self.builder.get_object("rebootLabel")
|
||||
label.set_text(continue_text)
|
||||
|
||||
# Don't show the reboot message.
|
||||
self._progressNotebook.set_current_page(0)
|
||||
|
||||
def refresh(self):
|
||||
from pyanaconda.core.dbus import DBus
|
||||
from pyanaconda.core.threads import thread_manager
|
||||
from pyanaconda.modules.common.constants.services import BOSS
|
||||
|
||||
super().refresh()
|
||||
|
||||
# Wait for background threads to finish
|
||||
if thread_manager.running > 1:
|
||||
log.debug("Waiting for %s threads to finish...", thread_manager.running - 1)
|
||||
for name in thread_manager.names:
|
||||
log.debug("Thread %s is still running", name)
|
||||
thread_manager.wait_all()
|
||||
log.debug("No more threads are running, continuing with installation.")
|
||||
|
||||
# Initialize the progress bar
|
||||
gtk_call_once(self._progressBar.set_fraction, 0.0)
|
||||
|
||||
# Start the installation task via D-Bus
|
||||
boss_proxy = BOSS.get_proxy()
|
||||
task_path = boss_proxy.InstallWithTasks()[0]
|
||||
self._task_proxy = DBus.get_proxy(BOSS.service_name, task_path)
|
||||
|
||||
self._task_proxy.ProgressChanged.connect(self._on_progress_changed)
|
||||
self._task_proxy.ErrorRaised.connect(self._on_error_raised)
|
||||
self._task_proxy.Stopped.connect(self._on_installation_done)
|
||||
|
||||
self._task_proxy.Start()
|
||||
|
||||
# Start the spinner
|
||||
gtk_call_once(self._spinner.start)
|
||||
|
||||
log.debug("The installation has started.")
|
||||
|
||||
# ---- FWS: live journal -------------------------------------------------
|
||||
|
||||
def _fws_build_log_view(self):
|
||||
box = self.builder.get_object("progressBox")
|
||||
|
||||
self._fws_toggle = Gtk.ToggleButton(label="Afficher le journal")
|
||||
self._fws_toggle.set_halign(Gtk.Align.START)
|
||||
self._fws_toggle.connect("toggled", self._fws_on_toggled)
|
||||
box.pack_start(self._fws_toggle, False, False, 6)
|
||||
self._fws_toggle.show()
|
||||
|
||||
self._fws_text = Gtk.TextView(editable=False, cursor_visible=False,
|
||||
monospace=True)
|
||||
self._fws_text.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
|
||||
self._fws_buffer = self._fws_text.get_buffer()
|
||||
self._fws_end = self._fws_buffer.create_mark(
|
||||
None, self._fws_buffer.get_end_iter(), False)
|
||||
self._fws_scroll = Gtk.ScrolledWindow(vexpand=True, hexpand=True)
|
||||
self._fws_scroll.set_policy(Gtk.PolicyType.AUTOMATIC,
|
||||
Gtk.PolicyType.AUTOMATIC)
|
||||
self._fws_scroll.set_min_content_height(260)
|
||||
self._fws_scroll.set_shadow_type(Gtk.ShadowType.IN)
|
||||
self._fws_scroll.add(self._fws_text)
|
||||
self._fws_text.show()
|
||||
# Hidden until the user asks for it: the plain progress screen stays
|
||||
# the default.
|
||||
box.pack_start(self._fws_scroll, True, True, 0)
|
||||
|
||||
root = conf.target.system_root
|
||||
self._fws_logs = [
|
||||
{"tag": tag, "path": path if path.startswith("/")
|
||||
else os.path.join(root, path), "offset": None}
|
||||
for tag, path in FWS_LOGS
|
||||
]
|
||||
self._fws_last_tag = None
|
||||
self._fws_timer = None
|
||||
|
||||
def _fws_on_toggled(self, button):
|
||||
if button.get_active():
|
||||
button.set_label("Masquer le journal")
|
||||
self._fws_scroll.show()
|
||||
self._fws_poll()
|
||||
if self._fws_timer is None:
|
||||
self._fws_timer = GLib.timeout_add(FWS_LOG_POLL_MS,
|
||||
self._fws_poll)
|
||||
else:
|
||||
button.set_label("Afficher le journal")
|
||||
self._fws_scroll.hide()
|
||||
if self._fws_timer is not None:
|
||||
GLib.source_remove(self._fws_timer)
|
||||
self._fws_timer = None
|
||||
|
||||
def _fws_poll(self):
|
||||
"""Append what each log gained since the last poll. Always True so the
|
||||
GLib timer keeps running while the view is shown."""
|
||||
for entry in self._fws_logs:
|
||||
try:
|
||||
with open(entry["path"], "rb") as fh:
|
||||
if entry["offset"] is None:
|
||||
fh.seek(0, os.SEEK_END)
|
||||
entry["offset"] = max(0, fh.tell() - FWS_LOG_BACKLOG)
|
||||
fh.seek(entry["offset"])
|
||||
data = fh.read()
|
||||
except OSError:
|
||||
# Not written yet: the chrooted %post has not started, or the
|
||||
# log lives on the target which is not mounted yet.
|
||||
continue
|
||||
if not data:
|
||||
continue
|
||||
entry["offset"] += len(data)
|
||||
text = data.decode("utf-8", errors="replace")
|
||||
if self._fws_last_tag != entry["tag"]:
|
||||
text = f"\n── {entry['tag']} : {entry['path']} ──\n{text}"
|
||||
self._fws_last_tag = entry["tag"]
|
||||
self._fws_append(text)
|
||||
return True
|
||||
|
||||
def _fws_append(self, text):
|
||||
buf = self._fws_buffer
|
||||
buf.insert(buf.get_end_iter(), text)
|
||||
if buf.get_char_count() > FWS_LOG_MAX_CHARS:
|
||||
cut = buf.get_iter_at_offset(buf.get_char_count() - FWS_LOG_MAX_CHARS)
|
||||
cut.forward_line()
|
||||
buf.delete(buf.get_start_iter(), cut)
|
||||
self._fws_text.scroll_to_mark(self._fws_end, 0.0, True, 0.0, 1.0)
|
||||
|
||||
def _on_progress_changed(self, step, message):
|
||||
"""Handle a new progress report."""
|
||||
if message:
|
||||
gtk_call_once(self._progressLabel.set_text, message)
|
||||
|
||||
if self._task_proxy.Steps > 0:
|
||||
gtk_call_once(self._progressBar.set_fraction, step/self._task_proxy.Steps)
|
||||
Reference in new issue
Block a user