From 8e75cc538d8a1a3d3b762762361cb3afc389a3dc Mon Sep 17 00:00:00 2001 From: Andrew Lukoshko Date: Tue, 25 Apr 2023 18:13:53 +0000 Subject: [PATCH] Add guard before accessing ks.handler.btrfs.btrfsList --- ...accessing-ks.handler.btrfs.btrfsList.patch | 48 +++++++++++++++++++ SPECS/appliance-tools.spec | 6 ++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0003-Add-guard-before-accessing-ks.handler.btrfs.btrfsList.patch diff --git a/SOURCES/0003-Add-guard-before-accessing-ks.handler.btrfs.btrfsList.patch b/SOURCES/0003-Add-guard-before-accessing-ks.handler.btrfs.btrfsList.patch new file mode 100644 index 0000000..c7f3df5 --- /dev/null +++ b/SOURCES/0003-Add-guard-before-accessing-ks.handler.btrfs.btrfsList.patch @@ -0,0 +1,48 @@ +From 7c1f3701d5dbb71f5403d36e67a6492426b1b793 Mon Sep 17 00:00:00 2001 +From: Koichiro Iwao +Date: Thu, 20 Apr 2023 10:57:03 +0900 +Subject: [PATCH 3/3] Add guard before accessing ks.handler.btrfs.btrfsList + +Fixes the following error. + +``` +Traceback (most recent call last): + File "/bin/appliance-creator", line 193, in + sys.exit(main()) + File "/bin/appliance-creator", line 155, in main + creator.configure() + File "/usr/lib/python3.9/site-packages/imgcreate/creator.py", line 799, in configure + self._create_bootconfig() + File "/usr/lib/python3.9/site-packages/appcreate/appliance.py", line 619, in _create_bootconfig + self._create_grub_config() + File "/usr/lib/python3.9/site-packages/appcreate/appliance.py", line 337, in _create_grub_config + options = self._kernel_cmdline_append() + File "/usr/lib/python3.9/site-packages/appcreate/appliance.py", line 268, in _kernel_cmdline_append + for s in self.ks.handler.btrfs.btrfsList: +AttributeError: 'RHEL9_BTRFS' object has no attribute 'btrfsList' +``` +--- + appcreate/appliance.py | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/appcreate/appliance.py b/appcreate/appliance.py +index 474a3b9..e9ff5bf 100644 +--- a/appcreate/appliance.py ++++ b/appcreate/appliance.py +@@ -265,9 +265,10 @@ class ApplianceImageCreator(ImageCreator): + lang = self.ks.handler.lang.lang + if lang != '': + options = '%s LANG=%s' % (options, lang) +- for s in self.ks.handler.btrfs.btrfsList: +- if s.subvol and s.name == "root": +- options = '%s rootflags=subvol=root' % options ++ if (hasattr(self.ks.handler.btrfs, "btrfsList")): ++ for s in self.ks.handler.btrfs.btrfsList: ++ if s.subvol and s.name == "root": ++ options = '%s rootflags=subvol=root' % options + return options + + def _create_grub_devices(self, grubversion = 1): +-- +2.27.0 + diff --git a/SPECS/appliance-tools.spec b/SPECS/appliance-tools.spec index 5979ae6..f706b3e 100644 --- a/SPECS/appliance-tools.spec +++ b/SPECS/appliance-tools.spec @@ -21,7 +21,7 @@ Name: appliance-tools Summary: Tools for building Appliances Version: 011.1 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv2 URL: https://pagure.io/appliance-tools @@ -30,6 +30,7 @@ Source0: https://releases.pagure.org/%{name}/%{name}-%{version}.tar.bz2 # Backports from upstream Patch0001: 0001-Ignore-grub2-install-errors-if-they-are-expected.patch Patch0002: 0002-switch-from-authconfig-to-authselect.patch +Patch0003: 0003-Add-guard-before-accessing-ks.handler.btrfs.btrfsList.patch # Ensure system deps are installed (rhbz#1409536) Requires: python%{python_pkgversion}-imgcreate %{?min_imgcrate_evr:>= %{min_imgcreate_evr}} @@ -78,6 +79,9 @@ rm -rf %{buildroot}%{_datadir}/doc/%{name} %{python_sitelib}/ec2convert/ %changelog +* Tue Apr 25 2023 Andrew Lukoshko - 011.1-7 +- Add guard before accessing ks.handler.btrfs.btrfsList (Koichiro Iwao) + * Mon Aug 23 2021 Pavel Březina - 011.1-6 - Switch from authconfig to authselect (rhbz#1982158)