From 82527f618f7f674b8040f8e3db0de6ad90e1e70d Mon Sep 17 00:00:00 2001 From: ouuleilei Date: Fri, 14 Jun 2024 19:32:56 +0800 Subject: [PATCH] pylorax: Fix mksparse ftruncate size handling (cherry picked from commit 029f3b5181be1e948080228e79f73194efba0c9d) --- ...Fix-mksparse-ftruncate-size-handling.patch | 33 +++++++++++++++++++ lorax.spec | 7 +++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 0001-pylorax-Fix-mksparse-ftruncate-size-handling.patch diff --git a/0001-pylorax-Fix-mksparse-ftruncate-size-handling.patch b/0001-pylorax-Fix-mksparse-ftruncate-size-handling.patch new file mode 100644 index 0000000..b1fcc82 --- /dev/null +++ b/0001-pylorax-Fix-mksparse-ftruncate-size-handling.patch @@ -0,0 +1,33 @@ +From 8e67d8e2369e6045970aaad632b5bf32fb611b1f Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 11 Jun 2021 09:28:16 -0700 +Subject: [PATCH] pylorax: Fix mksparse ftruncate size handling + +Make sure that os.ftruncate() is called with an int() size. Before python +3.10 it used to handle this internally, but in 3.9 it was deprecated and +in 3.10 it now raises an error: + + TypeError: 'float' object cannot be interpreted as an integer + +This makes sure that the size is truncated to an int(). The value is in +bytes, so truncation does not lose anything. +--- + 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 d38f056..44d5b55 100644 +--- a/src/pylorax/imgutils.py ++++ b/src/pylorax/imgutils.py +@@ -130,7 +130,7 @@ def mkrootfsimg(rootdir, outfile, label, size=2, sysroot=""): + def mksparse(outfile, size): + '''use os.ftruncate to create a sparse file of the given size.''' + fobj = open(outfile, "w") +- os.ftruncate(fobj.fileno(), size) ++ os.ftruncate(fobj.fileno(), int(size)) + + def mkqcow2(outfile, size, options=None): + '''use qemu-img to create a file of the given size. +-- +2.45.2 + diff --git a/lorax.spec b/lorax.spec index aac2cf7..60c373a 100644 --- a/lorax.spec +++ b/lorax.spec @@ -3,7 +3,7 @@ Name: lorax Version: 34.1 -Release: 5 +Release: 6 Summary: A set of tools used to create bootable images License: GPLv2+ URL: https://github.com/weldr/lorax @@ -28,6 +28,7 @@ Patch12: backport-Improve-lmc-no-virt-error-handling.patch Patch13: backport-Add-POSTIN-scriptlet-error-to-the-log-monitor-list.patch Patch14: backport-Remove-LD_PRELOAD-libgomp.so.1-from-lmc-no-virt.patch Patch16: add-param-name_prefix-to-make-name-used-by-register_blueprint-unique.patch +Patch17: 0001-pylorax-Fix-mksparse-ftruncate-size-handling.patch %ifarch loongarch64 Patch100: 0001-support-loongarch-for-lorax.patch %endif @@ -144,6 +145,7 @@ build images, etc. from the command line. %patch13 -p1 %patch14 -p1 %patch16 -p1 +%patch17 -p1 %ifarch loongarch64 %patch100 -p1 %endif @@ -240,6 +242,9 @@ getent passwd weldr >/dev/null 2>&1 || useradd -r -g weldr -d / -s /sbin/nologin %{_mandir}/man1/*.1* %changelog +* Thu Jun 13 2024 ouuleilei - 34.1-6 +- pylorax: Fix mksparse ftruncate size handling + * Wed Aug 09 2023 ouuleilei - 34.1-5 - support riscv64 for lorax -- Gitee