From 6293a0d7244f745c1f30cc3102ee9eb20202846b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Br=C3=A9nainn=20Woodsend?= Date: Sun, 27 Oct 2024 23:08:03 +0000 Subject: [PATCH] Mark Fedora 41 as default/latest release --- README.rst | 2 +- docs/source/example-library.rst | 12 ++++++------ docs/source/fedora.rst | 4 ++-- polycotylus/_fedora.py | 19 ++++++++++--------- tests/test_fedora.py | 31 +++++++++++++++++++++++++------ 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/README.rst b/README.rst index ec2315c..7db1c4c 100644 --- a/README.rst +++ b/README.rst @@ -70,7 +70,7 @@ Distributions Supported versions Alpine_ 3.17-3.20, edge Arch_ rolling Debian_ 13 (pre-release) -Fedora_ 37-40, 41 (pre-release), 42 (rawhide) +Fedora_ 37-41, 42 (rawhide) Manjaro_ rolling O̶p̶e̶n̶S̶U̶S̶E Redacted due to too many upstream issues Ubuntu_ 23.04-24.10 diff --git a/docs/source/example-library.rst b/docs/source/example-library.rst index 7cef919..0284a77 100644 --- a/docs/source/example-library.rst +++ b/docs/source/example-library.rst @@ -324,7 +324,7 @@ see :ref:`the package manager cheat sheet `). ... [user@manjaro-2212 io]$ sudo yum whatprovides '*/Python.h' ... - python3-devel-3.11.2-1.fc39.x86_64 : Libraries and header files needed for + python3-devel-3.11.2-1.fc41.x86_64 : Libraries and header files needed for : Python development Repo : fedora Matched from: @@ -332,14 +332,14 @@ see :ref:`the package manager cheat sheet `). ... [user@manjaro-2212 io]$ sudo yum whatprovides '*/brotli/decode.h' ... - brotli-devel-1.0.9-11.fc39.x86_64 : Lossless compression algorithm + brotli-devel-1.0.9-11.fc41.x86_64 : Lossless compression algorithm : (development files) Repo : fedora Matched from: Filename : /usr/include/brotli/decode.h [user@manjaro-2212 io]$ sudo yum whatprovides '*/libbrotlienc*' ... - libbrotli-1.0.9-11.fc39.x86_64 : Library for brotli lossless compression algorithm + libbrotli-1.0.9-11.fc41.x86_64 : Library for brotli lossless compression algorithm Repo : fedora Matched from: Filename : /usr/lib64/libbrotlienc.so.1 @@ -369,9 +369,9 @@ These are ``gcc``, ``libbrotli``, ``brotli-devel`` and ``python3-devel``. The next ``polycotylus fedora`` run takes us to the end. :: Built 3 artifacts: - debuginfo: .polycotylus/fedora/x86_64/python3-ubrotli-debuginfo-0.1.0-1.fc39.x86_64.rpm - debugsource: .polycotylus/fedora/x86_64/python3-ubrotli-debugsource-0.1.0-1.fc39.x86_64.rpm - main: .polycotylus/fedora/x86_64/python3-ubrotli-0.1.0-1.fc39.x86_64.rpm + debuginfo: .polycotylus/fedora/x86_64/python3-ubrotli-debuginfo-0.1.0-1.fc41.x86_64.rpm + debugsource: .polycotylus/fedora/x86_64/python3-ubrotli-debugsource-0.1.0-1.fc41.x86_64.rpm + main: .polycotylus/fedora/x86_64/python3-ubrotli-0.1.0-1.fc41.x86_64.rpm You'll notice that this time, there are three packages produced. The one labelled ``main`` is the one you'd distribute. See :ref:`building for Fedora diff --git a/docs/source/fedora.rst b/docs/source/fedora.rst index 3b16c32..84e9dfb 100644 --- a/docs/source/fedora.rst +++ b/docs/source/fedora.rst @@ -43,8 +43,8 @@ or newer using the commands below respectively. :: polycotylus fedora:37 polycotylus fedora:38 polycotylus fedora:39 - polycotylus fedora:40 # default - polycotylus fedora:41 # pre-release + polycotylus fedora:40 + polycotylus fedora:41 # default polycotylus fedora:42 # raw hide Installing a package built for a different release of Fedora will usually mean diff --git a/polycotylus/_fedora.py b/polycotylus/_fedora.py index 6d422f2..a11976b 100644 --- a/polycotylus/_fedora.py +++ b/polycotylus/_fedora.py @@ -23,7 +23,7 @@ class Fedora(GPGBased, BaseDistribution): name = "fedora" - version = "40" + version = "41" python_extras = { "tkinter": ["python3-tkinter"], } @@ -73,8 +73,9 @@ def python_package_convention(cls, name): @classmethod @lru_cache() def python_version(cls): - command = ["python3", "-c", "import sys; print('{}.{}.{}'.format(*sys.version_info))"] - return _docker.run(cls.base_image, command, tty=True).output.strip() + command = ["dnf", "info", "python3"] + output = _docker.run(cls.base_image, command, volumes=cls._mounted_caches, verbosity=0).output + return re.search(r"Version\s*:\s*(.+)", output)[1] @classmethod def python_package(cls, requirement, _=None): @@ -256,9 +257,9 @@ def generate(self): path.unlink() _misc.unix_write(self.distro_root / f"{self.package_name}.spec", self.spec()) - @property - def _mounted_caches(self): - if int(self.version) >= 42: + @_misc.classproperty + def _mounted_caches(_, cls): + if int(cls.version) >= 41: dnf_cache = cache_root / f"fedora-libdnf5-{_docker.docker.variant}" dnf_cache.mkdir(parents=True, exist_ok=True) return [(dnf_cache, "/var/cache/libdnf5")] @@ -343,11 +344,11 @@ class Fedora39(Fedora): version = "39" -Fedora40 = Fedora +class Fedora40(Fedora): + version = "40" -class Fedora41(Fedora): - version = "41" +Fedora41 = Fedora class Fedora42(Fedora): diff --git a/tests/test_fedora.py b/tests/test_fedora.py index de0dc9f..e6846fc 100644 --- a/tests/test_fedora.py +++ b/tests/test_fedora.py @@ -6,13 +6,14 @@ import tarfile import io import contextlib +import time import toml import pytest from polycotylus import _docker, _exceptions, _misc from polycotylus._project import Project -from polycotylus._fedora import Fedora, Fedora37, Fedora42 +from polycotylus._fedora import Fedora, Fedora37, Fedora40, Fedora41, Fedora42 from polycotylus.__main__ import cli import shared @@ -28,6 +29,24 @@ def _check_values_align(spec): assert len(line[2]) >= 2 +@pytest.mark.parametrize("Fedora", [Fedora37, Fedora40, Fedora41, Fedora42]) +def test_dnf_cache(Fedora): + mounts = Fedora._mounted_caches + before = time.time() + _docker.run(Fedora.base_image, f""" + find /var/cache -name 'libretls*.rpm' -exec rm {{}} \\; + {Fedora.dnf_config_install} + dnf install --refresh -y libretls + """, volumes=mounts) + changed_files = [] + for (source, _) in mounts: + changed_files += [i.name for i in source.rglob("*") if i.stat().st_mtime > before] + assert changed_files + assert [i for i in changed_files if i.endswith(".xml.zck")] + assert [i for i in changed_files if i.endswith(".rpm")] + time.sleep(3) + + def test_pretty_spec(): self = Fedora(Project.from_root(shared.dumb_text_viewer)) spec = self.spec() @@ -41,7 +60,7 @@ def test_python_extras(): {Fedora.dnf_config_install} dnf install -y {shlex.join(packages)} python3 python3 -c 'import {", ".join(imports)}' - """, volumes=Fedora._mounted_caches.fget(Fedora)) + """, volumes=Fedora._mounted_caches) def test_python_package(): @@ -50,8 +69,8 @@ def test_python_package(): if i != "zope.deferredimport"] script = Fedora.dnf_config_install + "\ndnf install --assumeno " + shlex.join(packages) container = _docker.run(Fedora.base_image, script, check=False, - volumes=Fedora._mounted_caches.fget(Fedora)) - assert "Operation aborted." in container.output + volumes=Fedora._mounted_caches) + assert "Operation aborted" in container.output def test_ubrotli(): @@ -130,10 +149,10 @@ def test_kitchen_sink(monkeypatch): }, { "distribution": "fedora", - "tag": "40", + "tag": "41", "architecture": "noarch", "variant": "main", - "path": ".polycotylus/fedora/noarch/python3-99-s1lly-name-packag3-x-y-z-1.2.3-1.fc40.noarch.rpm", + "path": ".polycotylus/fedora/noarch/python3-99-s1lly-name-packag3-x-y-z-1.2.3-1.fc41.noarch.rpm", "signature_path": null } ]"""