From 3d846a96033931e4f8d0539d38776cf5782909a1 Mon Sep 17 00:00:00 2001 From: Sergey Cherevko Date: Mon, 23 Dec 2024 16:59:25 +0300 Subject: [PATCH] MSVSphere changing --- ...01-Backport-dracut-chroot-umount-fix.patch | 25 +++++++++ ...02-Fix-replace-command-utf8-handling.patch | 51 +++++++++++++++++++ SOURCES/0003-Add-iconv-template-command.patch | 41 +++++++++++++++ ...sun16-as-default-font-instead-of-eur.patch | 28 ++++++++++ SPECS/lorax.spec | 14 ++++- 5 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0001-Backport-dracut-chroot-umount-fix.patch create mode 100644 SOURCES/0002-Fix-replace-command-utf8-handling.patch create mode 100644 SOURCES/0003-Add-iconv-template-command.patch create mode 100644 SOURCES/0004-Set-latarcyrheb-sun16-as-default-font-instead-of-eur.patch diff --git a/SOURCES/0001-Backport-dracut-chroot-umount-fix.patch b/SOURCES/0001-Backport-dracut-chroot-umount-fix.patch new file mode 100644 index 0000000..37489a5 --- /dev/null +++ b/SOURCES/0001-Backport-dracut-chroot-umount-fix.patch @@ -0,0 +1,25 @@ +From 2df6e5fe31bd7c3625c06feb264ddf800ab0acbb Mon Sep 17 00:00:00 2001 +From: Eugene Zamriy +Date: Thu, 6 Apr 2023 21:16:26 +0300 +Subject: [PATCH 1/4] Backport dracut chroot umount fix + +--- + src/pylorax/imgutils.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py +index 9a08773..389b52d 100644 +--- a/src/pylorax/imgutils.py ++++ b/src/pylorax/imgutils.py +@@ -511,7 +511,7 @@ class ProcMount(object): + for _, d in self.bind: + # In case parallel building of two or more images + # some mounts in /var/tmp/lorax can be busy at the moment of unmounting +- umount(self.root + d, maxretry=10, retrysleep=5, delete=False) ++ umount(self.root + d, maxretry=200, retrysleep=5, delete=False) + + class DracutChroot(ProcMount): + def __init__(self, root, bind=None): +-- +2.43.5 + diff --git a/SOURCES/0002-Fix-replace-command-utf8-handling.patch b/SOURCES/0002-Fix-replace-command-utf8-handling.patch new file mode 100644 index 0000000..b22a4e5 --- /dev/null +++ b/SOURCES/0002-Fix-replace-command-utf8-handling.patch @@ -0,0 +1,51 @@ +From a82cdfeb41579480534b04d8ad1d667593f3e2d4 Mon Sep 17 00:00:00 2001 +From: Eugene Zamriy +Date: Wed, 26 Jul 2023 22:45:32 +0300 +Subject: [PATCH 2/4] Fix replace command utf8 handling + +This change allows using non-latin UTF-8 symbols in files modified +from Lorax templates using the "replace" command. + +Note: fileinput.input doesn't support encoding argument in the +in-place mode, so we replaced it with StringIO. +--- + src/pylorax/sysutils.py | 15 +++++++-------- + 1 file changed, 7 insertions(+), 8 deletions(-) + +diff --git a/src/pylorax/sysutils.py b/src/pylorax/sysutils.py +index 35f8b0f..81dc20a 100644 +--- a/src/pylorax/sysutils.py ++++ b/src/pylorax/sysutils.py +@@ -25,7 +25,7 @@ __all__ = ["joinpaths", "touch", "replace", "chown_", "chmod_", "remove", + import sys + import os + import re +-import fileinput ++import io + import pwd + import grp + import glob +@@ -50,14 +50,13 @@ def touch(fname): + + + def replace(fname, find, sub): +- fin = fileinput.input(fname, inplace=1) + pattern = re.compile(find) +- +- for line in fin: +- line = pattern.sub(sub, line) +- sys.stdout.write(line) +- +- fin.close() ++ with open(fname, "r", encoding="utf-8") as fd: ++ fin = io.StringIO(fd.read()) ++ with open(fname, "w", encoding="utf-8") as fd: ++ for line in fin: ++ line = pattern.sub(sub, line) ++ fd.write(line) + + + def chown_(path, user=None, group=None, recursive=False): +-- +2.43.5 + diff --git a/SOURCES/0003-Add-iconv-template-command.patch b/SOURCES/0003-Add-iconv-template-command.patch new file mode 100644 index 0000000..449215c --- /dev/null +++ b/SOURCES/0003-Add-iconv-template-command.patch @@ -0,0 +1,41 @@ +From ec4ff67267b4b33715754ed9f947c4572c541f0e Mon Sep 17 00:00:00 2001 +From: Eugene Zamriy +Date: Wed, 26 Jul 2023 22:55:04 +0300 +Subject: [PATCH 3/4] Add iconv template command + +Adds the "iconv" template command that converts file(s) from UTF-8 +to a specified encoding. This change was required to add Russian +localization to the BIOS mode bootloader. +--- + src/pylorax/ltmpl.py | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py +index 77fb4ff..f2844fc 100644 +--- a/src/pylorax/ltmpl.py ++++ b/src/pylorax/ltmpl.py +@@ -414,6 +414,21 @@ class LoraxTemplateRunner(TemplateRunner, InstallpkgMixin): + f.write("\n".join(sorted(debug_pkgs))) + f.write("\n") + ++ def iconv(self, encoding, *fileglobs): ++ ''' ++ iconv ENCODING [FILEGLOB ...] ++ Convert given files from UTF-8 to a specified encoding. ++ ++ Examples: ++ iconv 'cp866' ${BOOTDIR}/isolinux.cfg ++ ''' ++ for g in fileglobs: ++ for f in rglob(self._out(g)): ++ with open(f, "r", encoding="utf-8") as fd: ++ content = fd.read() ++ with open(f, "wb") as fd: ++ fd.write(content.encode(encoding)) ++ + def install(self, srcglob, dest): + ''' + install SRC DEST +-- +2.43.5 + diff --git a/SOURCES/0004-Set-latarcyrheb-sun16-as-default-font-instead-of-eur.patch b/SOURCES/0004-Set-latarcyrheb-sun16-as-default-font-instead-of-eur.patch new file mode 100644 index 0000000..2a95b23 --- /dev/null +++ b/SOURCES/0004-Set-latarcyrheb-sun16-as-default-font-instead-of-eur.patch @@ -0,0 +1,28 @@ +From 5d5f091774649427f573649ce4995b34e0d01950 Mon Sep 17 00:00:00 2001 +From: tigro +Date: Mon, 12 Aug 2024 12:15:27 +0300 +Subject: [PATCH 4/4] Set latarcyrheb-sun16 as default font instead of eurlatgr + +--- + share/templates.d/99-generic/config_files/common/i18n | 2 +- + share/templates.d/99-generic/config_files/common/vconsole.conf | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/share/templates.d/99-generic/config_files/common/i18n b/share/templates.d/99-generic/config_files/common/i18n +index b254232..7b4682c 100644 +--- a/share/templates.d/99-generic/config_files/common/i18n ++++ b/share/templates.d/99-generic/config_files/common/i18n +@@ -1 +1 @@ +-SYSFONT="eurlatgr" ++SYSFONT="LatGrkCyr-8x16" +diff --git a/share/templates.d/99-generic/config_files/common/vconsole.conf b/share/templates.d/99-generic/config_files/common/vconsole.conf +index 2bd7892..4eff1d3 100644 +--- a/share/templates.d/99-generic/config_files/common/vconsole.conf ++++ b/share/templates.d/99-generic/config_files/common/vconsole.conf +@@ -1,2 +1,2 @@ + KEYMAP=us +-FONT=eurlatgr ++FONT=latarcyrheb-sun16 +-- +2.43.5 + diff --git a/SPECS/lorax.spec b/SPECS/lorax.spec index d24fe82..7881b3a 100644 --- a/SPECS/lorax.spec +++ b/SPECS/lorax.spec @@ -4,7 +4,7 @@ Name: lorax Version: 40.5.6 -Release: 1%{?dist} +Release: 1%{?dist}.inferit Summary: Tool for creating the anaconda install images License: GPL-2.0-or-later @@ -15,6 +15,12 @@ URL: https://github.com/weldr/lorax # tito build --tgz Source0: %{name}-%{version}.tar.gz +# MSVSphere patches +Patch1001: 0001-Backport-dracut-chroot-umount-fix.patch +Patch1002: 0002-Fix-replace-command-utf8-handling.patch +Patch1003: 0003-Add-iconv-template-command.patch +Patch1004: 0004-Set-latarcyrheb-sun16-as-default-font-instead-of-eur.patch + BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: make @@ -182,6 +188,12 @@ make DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} install %{_datadir}/lorax/templates.d/* %changelog +* Mon Dec 23 2024 Sergey Cherevko - 40.5.6-1.inferit +- Backport dracut chroot umount fix +- Fix replace command utf8 handling +- Add iconv template command +- Set latarcyrheb-sun16 as default font instead of eurlatgr + * Tue Nov 26 2024 MSVSphere Packaging Team - 40.5.6-1 - Rebuilt for MSVSphere 10