From 5f90aad306a5809008f4b205ef7bae73438590d9 Mon Sep 17 00:00:00 2001 From: Eugene Zamriy Date: Fri, 28 Jul 2023 00:05:53 +0300 Subject: [PATCH] Added bootloader configs charset detection patch --- ...d-charset-detection-to-tweak_configs.patch | 50 +++++++++++++++++++ SPECS/pungi.spec | 11 +++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0001-Add-charset-detection-to-tweak_configs.patch diff --git a/SOURCES/0001-Add-charset-detection-to-tweak_configs.patch b/SOURCES/0001-Add-charset-detection-to-tweak_configs.patch new file mode 100644 index 0000000..5cfc32d --- /dev/null +++ b/SOURCES/0001-Add-charset-detection-to-tweak_configs.patch @@ -0,0 +1,50 @@ +From df408e43ace861fdc2c016aca002bc2e23232837 Mon Sep 17 00:00:00 2001 +From: Eugene Zamriy +Date: Thu, 27 Jul 2023 23:48:40 +0300 +Subject: [PATCH] Add charset detection to tweak_configs + +This patch is required for making Pungi work with isolinux.cfg +files in cp866 encoding. +--- + pungi/phases/buildinstall.py | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/pungi/phases/buildinstall.py b/pungi/phases/buildinstall.py +index 354c47a..a6efc59 100644 +--- a/pungi/phases/buildinstall.py ++++ b/pungi/phases/buildinstall.py +@@ -22,6 +22,7 @@ import re + from six.moves import cPickle as pickle + from copy import copy + ++import chardet + from kobo.threads import ThreadPool, WorkerThread + from kobo.shortcuts import run, force_list + import kobo.rpmlib +@@ -383,8 +384,10 @@ def tweak_configs(path, volid, ks_file, configs=BOOT_CONFIGS, logger=None): + if not os.path.exists(config_path): + continue + +- with open(config_path, "r") as f: +- data = original_data = f.read() ++ with open(config_path, "rb") as f: ++ byte_data = f.read() ++ encoding = chardet.detect(byte_data)["encoding"] ++ data = original_data = byte_data.decode(encoding) + os.unlink(config_path) # break hadlink by removing file writing a new one + + # double-escape volid in yaboot.conf +@@ -398,8 +401,8 @@ def tweak_configs(path, volid, ks_file, configs=BOOT_CONFIGS, logger=None): + data = re.sub(r":LABEL=[^ \n]*", r":LABEL=%s%s" % (new_volid, ks), data) + data = re.sub(r"(search .* -l) '[^'\n]*'", r"\1 '%s'" % volid, data) + +- with open(config_path, "w") as f: +- f.write(data) ++ with open(config_path, "wb") as f: ++ f.write(data.encode(encoding)) + + if data != original_data: + found_configs.append(config) +-- +2.41.0 + diff --git a/SPECS/pungi.spec b/SPECS/pungi.spec index 12defd0..ad273b9 100644 --- a/SPECS/pungi.spec +++ b/SPECS/pungi.spec @@ -2,13 +2,16 @@ Name: pungi Version: 4.3.8 -Release: 1%{?dist} +Release: 1%{?dist}.inferit Summary: Distribution compose tool License: GPL-2.0-only URL: https://pagure.io/pungi Source0: https://pagure.io/releases/%{name}/%{name}-%{version}.tar.bz2 +# MSVSphere patches +Patch1001: 0001-Add-charset-detection-to-tweak_configs.patch + BuildRequires: make BuildRequires: python3-pytest BuildRequires: python3-mock @@ -56,6 +59,8 @@ Requires: python3-gobject Requires: python3-createrepo_c Requires: python3-PyYAML Requires: python3-productmd >= 1.28 +# MSVSphere changes +Requires: python3-chardet # This package is not available on i686, hence we cannot require it # See https://bugzilla.redhat.com/show_bug.cgi?id=1743421 @@ -138,6 +143,10 @@ rm %{buildroot}%{_bindir}/pungi %{_bindir}/%{name}-wait-for-signed-ostree-handler %changelog +* Thu Jul 27 2023 Eugene Zamriy - 4.3.8-1.inferit +- buildinstall: Added bootloader configs charset detection patch +- Added python3-chardet requirement + * Thu Mar 30 2023 Haibo Lin - 4.3.8-1 - createiso: Update possibly changed file on DVD (lsedlar) - pkgset: Stop reuse if configuration changed (lsedlar)