From 8e5c545c22ef7744a8b9ad672f8385311a47c9de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 26 May 2025 09:32:21 +0300 Subject: [PATCH] Fix tests on Python 3.14 (cherry picked from commit 40a6fe451dab89ed180b89cadd4c32e3a9328700) --- 1840.patch | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++ pungi.spec | 6 ++- 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 1840.patch diff --git a/1840.patch b/1840.patch new file mode 100644 index 00000000..32afed23 --- /dev/null +++ b/1840.patch @@ -0,0 +1,122 @@ +From ab11e0e4a9e0b70e1b78399931d357f92f3a27aa Mon Sep 17 00:00:00 2001 +From: Lubomír Sedlář +Date: May 21 2025 13:45:18 +0000 +Subject: linker: Drop ability to link dirs recursively + + +Nothing in the code base uses this functionality, and the semantins are +not well defined anyway when it comes to symlinks. + +Now the tests are failing in Python 3.14 rebuild when hardlinking +symlinks. Rather than trying to fix the unused code, we could just drop +it. + +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2367780 +Signed-off-by: Lubomír Sedlář + +--- + +diff --git a/pungi/linker.py b/pungi/linker.py +index 0bcadc4..097e52b 100644 +--- a/pungi/linker.py ++++ b/pungi/linker.py +@@ -228,20 +228,7 @@ class Linker(kobo.log.LoggingBase): + raise ValueError("Unknown link_type: %s" % link_type) + + def link(self, src, dst, link_type="hardlink-or-copy"): +- """Link directories recursively.""" +- if os.path.isfile(src) or os.path.islink(src): +- self._link_file(src, dst, link_type) +- return +- +- if os.path.isfile(dst): +- raise OSError(errno.EEXIST, "File exists") +- +- if not self.test: +- if not os.path.exists(dst): +- makedirs(dst) +- shutil.copystat(src, dst) ++ if os.path.isdir(src): ++ raise RuntimeError("Linking directories recursively is not supported") + +- for i in os.listdir(src): +- src_path = os.path.join(src, i) +- dst_path = os.path.join(dst, i) +- self.link(src_path, dst_path, link_type) ++ self._link_file(src, dst, link_type) +diff --git a/tests/test_linker.py b/tests/test_linker.py +index 87c5a3c..7dcd74d 100644 +--- a/tests/test_linker.py ++++ b/tests/test_linker.py +@@ -280,70 +280,3 @@ class TestLinkerLink(TestLinkerBase): + self.file2, + link_type="hardlink-or-copy", + ) +- +- def test_link_dir_hardlink(self): +- self.linker.link(self.src_dir, self.dst_dir, link_type="hardlink") +- self.assertTrue(os.path.isfile(self.dst_file1)) +- self.assertTrue(self.same_inode(self.file1, self.dst_file1)) +- self.assertTrue(self.same_inode(self.file3, self.dst_file3)) +- self.assertSameStat( +- os.path.dirname(self.file3), os.path.dirname(self.dst_file3) +- ) +- +- # always preserve symlinks +- self.assertEqual(os.readlink(self.dst_symlink1), "../file1") +- self.assertEqual(os.readlink(self.dst_symlink2), "subdir") +- self.assertEqual(os.readlink(self.dst_symlink3), "does-not-exist") +- +- def test_link_dir_copy(self): +- self.linker.link(self.src_dir, self.dst_dir, link_type="copy") +- self.assertTrue(os.path.isfile(self.dst_file1)) +- self.assertFalse(self.same_inode(self.file1, self.dst_file1)) +- self.assertFalse(self.same_inode(self.file3, self.dst_file3)) +- self.assertSameStat( +- os.path.dirname(self.file3), os.path.dirname(self.dst_file3) +- ) +- +- # always preserve symlinks +- self.assertEqual(os.readlink(self.dst_symlink1), "../file1") +- self.assertEqual(os.readlink(self.dst_symlink2), "subdir") +- self.assertEqual(os.readlink(self.dst_symlink3), "does-not-exist") +- +- def test_link_dir_copy_test_mode(self): +- # turn test mode on +- self.linker = linker.Linker(logger=self.logger, test=True) +- self.linker.link(self.src_dir, self.dst_dir, link_type="copy") +- +- # dst_dir should not even exist +- self.assertFalse(os.path.isdir(self.dst_dir)) +- +- def test_link_dir_symlink(self): +- self.linker.link(self.src_dir, self.dst_dir, link_type="symlink") +- self.assertTrue(os.path.isfile(self.dst_file1)) +- self.assertTrue(os.path.islink(self.dst_file1)) +- self.assertTrue(os.path.isdir(os.path.dirname(self.file3))) +- +- # always preserve symlinks +- self.assertEqual(os.readlink(self.dst_symlink1), "../file1") +- self.assertEqual(os.readlink(self.dst_symlink2), "subdir") +- self.assertEqual(os.readlink(self.dst_symlink3), "does-not-exist") +- +- def test_link_dir_abspath_symlink(self): +- self.linker.link(self.src_dir, self.dst_dir, link_type="abspath-symlink") +- self.assertTrue(os.path.isfile(self.dst_file1)) +- self.assertTrue(os.path.islink(self.dst_file1)) +- self.assertEqual(os.readlink(self.dst_file1), self.file1) +- self.assertSameStat( +- os.path.dirname(self.file3), os.path.dirname(self.dst_file3) +- ) +- self.assertTrue(os.path.isdir(os.path.dirname(self.file3))) +- +- # always preserve symlinks +- self.assertEqual(os.readlink(self.dst_symlink1), "../file1") +- self.assertEqual(os.readlink(self.dst_symlink2), "subdir") +- self.assertEqual(os.readlink(self.dst_symlink3), "does-not-exist") +- +- def test_copy_preserve_hardlinks(self): +- self.assertTrue(self.same_inode(self.file1, self.hardlink1)) +- self.linker.link(self.src_dir, self.dst_dir, link_type="copy") +- self.assertTrue(self.same_inode(self.dst_file1, self.dst_hardlink1)) + diff --git a/pungi.spec b/pungi.spec index 491189f2..1d4b2f7d 100644 --- a/pungi.spec +++ b/pungi.spec @@ -2,12 +2,13 @@ Name: pungi Version: 4.9.2 -Release: 1%{?dist}.alma.1 +Release: 2%{?dist}.alma.1 Summary: Distribution compose tool License: GPL-2.0-only URL: https://pagure.io/pungi Source0: %{name}-%{version}.tar.bz2 +Patch: https://pagure.io/pungi/pull-request/1840.patch BuildRequires: make BuildRequires: python3-pytest @@ -172,6 +173,9 @@ gzip _build/man/pungi.1 %{_bindir}/%{name}-cache-cleanup %changelog +* Mon May 26 2025 Lubomír Sedlář - 4.9.2-2 +- Fix tests on Python 3.14 + * Tue May 06 2025 Lubomír Sedlář - 4.9.2-1 - Drop compatibility with Koji < 1.32 (lsedlar) - kiwibuild: Add support for use_buildroot_repo option (lsedlar)