Added bootloader configs charset detection patch

i9 changed/i9/pungi-4.3.8-1.el9.inferit
Eugene Zamriy 2 years ago
parent 4481db4099
commit 5f90aad306
Signed by: ezamriy
GPG Key ID: 7EBF95C7DCFA496C

@ -0,0 +1,50 @@
From df408e43ace861fdc2c016aca002bc2e23232837 Mon Sep 17 00:00:00 2001
From: Eugene Zamriy <evgeniy.zamriy@softline.com>
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

@ -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 <ezamriy@msvsphere.ru> - 4.3.8-1.inferit
- buildinstall: Added bootloader configs charset detection patch
- Added python3-chardet requirement
* Thu Mar 30 2023 Haibo Lin <hlin@redhat.com> - 4.3.8-1
- createiso: Update possibly changed file on DVD (lsedlar)
- pkgset: Stop reuse if configuration changed (lsedlar)

Loading…
Cancel
Save