Skip to content

Commit

Permalink
Mark Fedora 41 as default/latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoodsend committed Nov 11, 2024
1 parent 6dd7618 commit 6293a0d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions docs/source/example-library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -324,22 +324,22 @@ see :ref:`the package manager cheat sheet <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:
Filename : /usr/include/python3.11/Python.h
...
[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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/source/fedora.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions polycotylus/_fedora.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class Fedora(GPGBased, BaseDistribution):
name = "fedora"
version = "40"
version = "41"
python_extras = {
"tkinter": ["python3-tkinter"],
}
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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):
Expand Down
31 changes: 25 additions & 6 deletions tests/test_fedora.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand All @@ -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():
Expand All @@ -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():
Expand Down Expand Up @@ -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
}
]"""
Expand Down

0 comments on commit 6293a0d

Please sign in to comment.