From 8e3223a677a1813ba6c15faead5fb6759b0f80c0 Mon Sep 17 00:00:00 2001 From: Vladimir Slavik Date: Jan 10 2022 14:30:35 +0000 Subject: Create the LVM devices file (#2011329) Write the LVM devices file with all PVs, to keep the previous behavior. Then, copy it to the new system. Remove the %post script that did the same. Bumps required blivet version. Resolves: rhbz#2011329 --- diff --git a/anaconda.spec.in b/anaconda.spec.in index 737a83a..3ec389f 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -37,7 +37,7 @@ Source0: %{name}-%{version}.tar.bz2 %define nmver 1.0 %define pykickstartver 3.32.2-1 %define pypartedver 2.5-2 -%define pythonblivetver 1:3.4.0-1 +%define pythonblivetver 1:3.4.0-10 %define rpmver 4.10.0 %define simplelinever 1.1-1 %define subscriptionmanagerver 1.26 diff --git a/data/post-scripts/70-generate-lvm-device-file.ks b/data/post-scripts/70-generate-lvm-device-file.ks deleted file mode 100644 index 4176dee..0000000 --- a/data/post-scripts/70-generate-lvm-device-file.ks +++ /dev/null @@ -1,11 +0,0 @@ -# Generate LVM devices file -# /etc/lvm/devices/system.devices -# This is a temporary workaround and should be reverted once blivet supports -# manipulation of the file. -# See: https://bugzilla.redhat.com/show_bug.cgi?id=2002550 - -%post - -[ -e /usr/sbin/vgimportdevices ] && vgimportdevices -a - -%end diff --git a/data/post-scripts/Makefile.am b/data/post-scripts/Makefile.am index b4f0daf..7d78d4b 100644 --- a/data/post-scripts/Makefile.am +++ b/data/post-scripts/Makefile.am @@ -16,5 +16,5 @@ # along with this program. If not, see . postscriptsdir = $(datadir)/$(PACKAGE_NAME)/post-scripts -dist_postscripts_DATA = 70-generate-lvm-device-file.ks 80-setfilecons.ks 90-copy-screenshots.ks 99-copy-logs.ks +dist_postscripts_DATA = 80-setfilecons.ks 90-copy-screenshots.ks 99-copy-logs.ks MAINTAINERCLEANFILES = Makefile.in diff --git a/pyanaconda/modules/storage/installation.py b/pyanaconda/modules/storage/installation.py index 2b974ef..a547b9e 100644 --- a/pyanaconda/modules/storage/installation.py +++ b/pyanaconda/modules/storage/installation.py @@ -18,6 +18,7 @@ # Red Hat, Inc. # import os +import shutil import parted from datetime import timedelta @@ -26,9 +27,11 @@ from time import sleep from blivet import callbacks as blivet_callbacks, util as blivet_util, arch from blivet.errors import FSResizeError, FormatResizeError, StorageError from blivet.util import get_current_entropy +from blivet.devicelibs.lvm import HAVE_LVMDEVICES from pyanaconda.anaconda_loggers import get_module_logger from pyanaconda.core.i18n import _ +from pyanaconda.core.util import join_paths, mkdirChain from pyanaconda.core.configuration.anaconda import conf from pyanaconda.modules.common.constants.objects import ISCSI, FCOE, ZFCP from pyanaconda.modules.common.constants.services import STORAGE @@ -281,6 +284,8 @@ class WriteConfigurationTask(Task): storage.make_mtab() storage.fsset.write() + self._write_lvm_devices_file(self._storage, sysroot) + iscsi_proxy = STORAGE.get_proxy(ISCSI) iscsi_proxy.WriteConfiguration() @@ -327,6 +332,25 @@ class WriteConfigurationTask(Task): log.debug("escrow: write_escrow_packets done") + def _write_lvm_devices_file(self, storage, sysroot): + """Create the LVM devices file for the target system. + + Adds all present PVs according to https://bugzilla.redhat.com/show_bug.cgi?id=2011329#c9 + + :param Blivet storage: instance of Blivet or a subclass + :param str sysroot: path to the target OS installation + """ + for device in storage.devices: + if device.format and device.format.type == "lvmpv" and HAVE_LVMDEVICES: + device.format.lvmdevices_add() + + in_filename = "/etc/lvm/devices/system.devices" + out_filename = join_paths(sysroot, in_filename) + + if os.path.exists(in_filename): + mkdirChain(os.path.dirname(out_filename)) + shutil.copyfile(in_filename, out_filename) + def _write_dasd_conf(self, storage, sysroot): """Write DASD configuration to sysroot.