From b0185d379b448af3a37e187a99ce7049a5e5257a Mon Sep 17 00:00:00 2001 From: sisungo Date: Wed, 8 Jul 2026 01:00:53 +0800 Subject: [PATCH] feat: add pkgmanifest recommendations support Signed-off-by: sisungo --- lib/make.py | 16 +++++++++++++--- x.py | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/make.py b/lib/make.py index 433a5ea..c87fbbe 100644 --- a/lib/make.py +++ b/lib/make.py @@ -11,6 +11,7 @@ _key_on_pack = "on_pack" _key_arch_any = "arch_any" _key_links = "links" _key_dependencies = "dependencies" +_key_recommendations = "recommendations" _key_provides = "provides" _current_pkgname: str = _key_global @@ -19,6 +20,7 @@ _pkginfo: dict[str, dict[str, typing.Any]] = { _key_links: [], _key_dependencies: [], _key_provides: [], + _key_recommendations: [], }, } _supported_arch: typing.Callable[[str], bool] = lambda x: True @@ -73,12 +75,20 @@ def provide(s: str): ] -def dep(s: str): - _pkginfo[_current_pkgname][_key_dependencies] += [ +def _translate_dep_spec(s: str) -> str: + return ( s.replace("(same)", "(same-version) @same-arch") .replace("(same-version)", f"(={_pkginfo[_current_pkgname][_key_version]})") .replace("@same-arch", f"@{arch.get_target()}") - ] + ) + + +def dep(s: str): + _pkginfo[_current_pkgname][_key_dependencies] += [_translate_dep_spec(s)] + + +def recommend(s: str): + _pkginfo[_current_pkgname][_key_recommendations] += [_translate_dep_spec(s)] def link(src: str, dst: str, default: bool = True): diff --git a/x.py b/x.py index f1ebe41..7215caf 100644 --- a/x.py +++ b/x.py @@ -115,6 +115,7 @@ def run_build_package(package: str): "arch": pkgarch, "dependencies": pkginfo[lib.make._key_dependencies], "provides": pkginfo[lib.make._key_provides], + "recommendations": pkginfo[lib.make._key_recommendations], } composer.write_manifest(manifest) composer.write_links(pkginfo[lib.make._key_links]) -- 2.55.0