r-pak: fix build, get dependencies from a callback

This commit is contained in:
Pekka Ristola 2024-02-19 21:37:07 +02:00
parent bc1722ee8a
commit ba5c799083
No known key found for this signature in database
GPG key ID: 2C20BE716E05213E
2 changed files with 16 additions and 18 deletions

View file

@ -6,26 +6,22 @@ import sys
sys.path.append(os.path.normpath(f'{__file__}/../../../lilac-extensions'))
from lilac_r_utils import r_pre_build
import tarfile
def get_depends(tar):
# Get the names of dependencies in embedded library
prefix = "pak/src/library/"
for member in tar.getmembers():
name = member.name
if not name.startswith(prefix) or not member.isdir():
continue
name = name[len(prefix):]
if "/" not in name:
yield name
def pre_build():
# Get the names of dependencies in embedded library
deps = []
newver = _G.newver.rsplit("#", 1)[0]
with tarfile.open(f"pak_{newver}.tar.gz", "r:gz") as tar:
prefix = "pak/src/library/"
for member in tar.getmembers():
name = member.name
if not name.startswith(prefix) or not member.isdir():
continue
name = name[len(prefix):]
if "/" not in name:
deps.append(name)
r_pre_build(
_G,
expect_needscompilation = True,
extra_r_depends = deps,
extra_r_depends_cb = get_depends,
)
def post_build():

View file

@ -236,14 +236,14 @@ class CheckConfig:
expect_needscompilation: bool = None,
expect_systemrequirements: str = None,
expect_title: str = None,
extra_r_depends: list = [],
extra_r_depends_cb = None,
ignore_fortran_files: bool = False,
):
self.expect_license = expect_license
self.expect_needscompilation = expect_needscompilation
self.expect_systemrequirements = expect_systemrequirements
self.expect_title = expect_title
self.extra_r_depends = extra_r_depends
self.extra_r_depends_cb = extra_r_depends_cb
self.ignore_fortran_files = ignore_fortran_files
def check_default_pkgs(pkg: Pkgbuild, desc: Description, cfg: CheckConfig):
@ -258,7 +258,9 @@ def check_default_pkgs(pkg: Pkgbuild, desc: Description, cfg: CheckConfig):
def check_depends(pkg: Pkgbuild, desc: Description, cfg: CheckConfig):
implicit_r_dep = explicit_r_dep = False
expected_depends = set(desc.depends + desc.imports)
expected_depends.update((_r_name_to_arch(dep) for dep in cfg.extra_r_depends))
cb = cfg.extra_r_depends_cb
if cb is not None:
expected_depends.update((_r_name_to_arch(dep) for dep in cb(cfg.tar)))
errors = []
for dep in pkg.depends:
if dep.startswith("r-"):