Add guard before accessing ks.handler.btrfs.btrfsList

This commit is contained in:
Andrew Lukoshko 2023-04-25 18:13:53 +00:00
parent d603d0ca49
commit 8e75cc538d
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From 7c1f3701d5dbb71f5403d36e67a6492426b1b793 Mon Sep 17 00:00:00 2001
From: Koichiro Iwao <meta@FreeBSD.org>
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 <module>
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

View File

@ -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 <alukoshko@almalinux.org> - 011.1-7
- Add guard before accessing ks.handler.btrfs.btrfsList (Koichiro Iwao)
* Mon Aug 23 2021 Pavel Březina <pbrezina@redhat.com> - 011.1-6
- Switch from authconfig to authselect (rhbz#1982158)