commit: 7f06ee40e6983474942fd5d7fb6faf6122803d4e
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 18 10:38:17 2023 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jan 18 10:38:17 2023 +0000
URL: https://gitweb.gentoo.org/proj/gentoopm.git/commit/?id=7f06ee40
repo: Add .arches
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
gentoopm/basepm/repo.py | 36 ++++++++++++++++++++++++++++++++++++
gentoopm/basepm/stack.py | 10 +++++++++-
gentoopm/pkgcorepm/repo.py | 11 ++++++++++-
3 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/gentoopm/basepm/repo.py b/gentoopm/basepm/repo.py
index fe3ee38..960ee88 100644
--- a/gentoopm/basepm/repo.py
+++ b/gentoopm/basepm/repo.py
@@ -106,6 +106,13 @@ class UseExpand(typing.NamedTuple):
}
+class ArchDesc(typing.NamedTuple):
+ """Architecture defined by arch.list + arches.desc"""
+
+ name: str
+ stability: typing.Optional[str] = None
+
+
class PMEbuildRepository(PMRepository, FillMissingComparisons):
"""
Base abstract class for an ebuild repository (on livefs).
@@ -176,6 +183,35 @@ class PMEbuildRepository(PMRepository,
FillMissingComparisons):
def use_expand(self) -> dict[str, UseExpand]:
"""Get dict of USE_EXPAND groups"""
+ @property
+ def arches(self) -> dict[str, ArchDesc]:
+ """Get dict of known architectures"""
+
+ arches = {}
+
+ try:
+ with open(Path(self.path) / "profiles/arch.list", "r") as f:
+ for line in f:
+ line = line.strip()
+ if line and line[0] != "#":
+ arches[line] = ArchDesc(line)
+ except FileNotFoundError:
+ pass
+
+ try:
+ with open(Path(self.path) / "profiles/arches.desc", "r") as f:
+ for line in f:
+ line = line.strip()
+ if not line or line[0] == "#":
+ continue
+ arch, stability, *_ = line.split()
+ arches[arch] = ArchDesc(name=arch,
+ stability=stability)
+ except FileNotFoundError:
+ pass
+
+ return arches
+
@abstractmethod
def __lt__(self, other):
pass
diff --git a/gentoopm/basepm/stack.py b/gentoopm/basepm/stack.py
index 5088db2..868fb81 100644
--- a/gentoopm/basepm/stack.py
+++ b/gentoopm/basepm/stack.py
@@ -3,7 +3,7 @@
# (c) 2011 Michał Górny <[email protected]>
# Released under the terms of the 2-clause BSD license.
-from .repo import PMRepository, GlobalUseFlag, UseExpand
+from .repo import PMRepository, GlobalUseFlag, UseExpand, ArchDesc
from .pkgset import PMPackageSet
@@ -39,6 +39,14 @@ class PMRepoStackWrapper(PMRepository):
ret.update(r.use_expand)
return ret
+ @property
+ def arches(self) -> dict[str, ArchDesc]:
+ """Get dict of known architectures"""
+ ret = {}
+ for r in self._repos:
+ ret.update(r.arches)
+ return ret
+
class PMFilteredStackPackageSet(PMPackageSet):
"""
diff --git a/gentoopm/pkgcorepm/repo.py b/gentoopm/pkgcorepm/repo.py
index 6558e14..e2e32ee 100644
--- a/gentoopm/pkgcorepm/repo.py
+++ b/gentoopm/pkgcorepm/repo.py
@@ -16,7 +16,7 @@ except ImportError:
from pkgcore.ebuild.repository import _UnconfiguredTree as UnconfiguredTree
from ..basepm.repo import (PMRepository, PMRepositoryDict, PMEbuildRepository,
- GlobalUseFlag, UseExpand,
+ GlobalUseFlag, UseExpand, ArchDesc,
)
from ..util import FillMissingComparisons
@@ -161,6 +161,15 @@ class PkgCoreEbuildRepo(PkgCoreRepository,
PMEbuildRepository, FillMissingCompar
values=values))
return dict(inner())
+ @property
+ def arches(self) -> dict[str, ArchDesc]:
+ arches = {arch: ArchDesc(arch) for arch in self._repo.known_arches}
+ for stability, st_arches in self._repo.config.arches_desc.items():
+ for arch in st_arches:
+ arches[arch] = ArchDesc(name=arch,
+ stability=stability)
+ return arches
+
def __lt__(self, other):
return other._index < self._index