Skip to content

Commit

Permalink
Copy /var/lib/gnome-initial-setup/state to installed system
Browse files Browse the repository at this point in the history
In order to avoid duplicate screens in gnome-initial-setup we need
to let the gnome-initial-setup on the installed system know what
the user did during the live boot.

This commit copies the relevant state file over.
  • Loading branch information
halfline committed Aug 17, 2023
1 parent c95142f commit 46334bf
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
26 changes: 26 additions & 0 deletions pyanaconda/modules/payloads/payload/live_image/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import stat
import requests
import shutil
import blivet.util

from pyanaconda.anaconda_loggers import get_module_logger
Expand Down Expand Up @@ -478,3 +479,28 @@ def run(self):

log.debug("Removing the downloaded image at %s.", self._download_path)
os.unlink(self._download_path)


class CopyTransientLiveDataTask(Task):
"""Task to copy transient configuration from live system to installed system"""

def __init__(self, sysroot, paths):
"""Create a new task."""
super().__init__()
self._sysroot = sysroot
self._paths = paths

@property
def name(self):
"""Name of the task."""
return "Transfer transient live system configuration to installed system"""

def run(self):
"""Run the task."""
for path in self._paths:
destination_path = os.path.join(self._sysroot, path.lstrip('/'))
destination_dir = os.path.dirname(destination_path)
os.makedirs(destination_dir, exist_ok=True)
log.debug(f"Copying {path} to {destination_path}")
if os.path.exists(path):
shutil.copy2(path, destination_path)
13 changes: 9 additions & 4 deletions pyanaconda/modules/payloads/payload/live_os/live_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.modules.common.errors.payload import IncompatibleSourceError
from pyanaconda.modules.payloads.constants import SourceType, PayloadType
from pyanaconda.modules.payloads.payload.live_image.installation import InstallFromImageTask
from pyanaconda.modules.payloads.payload.live_image.installation import InstallFromImageTask, CopyTransientLiveDataTask
from pyanaconda.modules.payloads.payload.live_os.utils import get_kernel_version_list
from pyanaconda.modules.payloads.payload.payload_base import PayloadBase
from pyanaconda.modules.payloads.payload.live_os.live_os_interface import LiveOSInterface
Expand Down Expand Up @@ -66,16 +66,21 @@ def install_with_tasks(self):
log.debug("No Live OS image is available.")
return []

task = InstallFromImageTask(
install_task = InstallFromImageTask(
sysroot=conf.target.system_root,
mount_point=image_source.mount_point
)

task.succeeded_signal.connect(
install_task.succeeded_signal.connect(
lambda: self._update_kernel_version_list(image_source)
)

return [task]
post_install_task = CopyTransientLiveDataTask(
sysroot=conf.target.system_root,
paths=['/var/lib/gnome-initial-setup/state']
)

return [install_task, post_install_task]

def _update_kernel_version_list(self, image_source):
"""Update the kernel versions list."""
Expand Down

0 comments on commit 46334bf

Please sign in to comment.