mirror of
https://github.com/BioArchLinux/Packages.git
synced 2025-03-10 12:02:42 +00:00
r-pak: use metadata checks
This commit is contained in:
parent
f5566e12d7
commit
273fa71a63
5 changed files with 123 additions and 43 deletions
|
@ -1,52 +1,70 @@
|
|||
# Maintainer: sukanka <su975853527@gmail.com>
|
||||
# Maintainer: Pekka Ristola <pekkarr [at] protonmail [dot] com>
|
||||
# Contributor: sukanka <su975853527@gmail.com>
|
||||
# Contributor: peippo <christoph+aur@christophfink.com>
|
||||
|
||||
_pkgname=pak
|
||||
_pkgver=0.7.1
|
||||
pkgname=r-${_pkgname,,}
|
||||
pkgver=0.7.1
|
||||
pkgver=${_pkgver//-/.}
|
||||
pkgrel=1
|
||||
pkgdesc='Another Approach to Package Installation'
|
||||
arch=('any')
|
||||
url="https://cran.r-project.org/package=${_pkgname}"
|
||||
license=('GPL')
|
||||
pkgdesc="Another Approach to Package Installation"
|
||||
arch=(any)
|
||||
url="https://cran.r-project.org/package=$_pkgname"
|
||||
license=('GPL-3.0-only')
|
||||
depends=(
|
||||
r
|
||||
)
|
||||
optdepends=(
|
||||
r-callr
|
||||
r-cli
|
||||
r-covr
|
||||
r-curl
|
||||
r-desc
|
||||
r-digest
|
||||
r-distro
|
||||
r-filelock
|
||||
r-gitcreds
|
||||
r-glue
|
||||
r-jsonlite
|
||||
r-mockery
|
||||
r-pingr
|
||||
r-lpsolve
|
||||
r-pkgbuild
|
||||
r-pkgcache
|
||||
r-pkgdepends
|
||||
r-pkgsearch
|
||||
r-prettyunits
|
||||
r-processx
|
||||
r-ps
|
||||
r-rprojroot
|
||||
r-r6
|
||||
r-zip
|
||||
)
|
||||
checkdepends=(
|
||||
r-mockery
|
||||
r-testthat
|
||||
)
|
||||
optdepends=(
|
||||
r-covr
|
||||
r-gitcreds
|
||||
r-glue
|
||||
r-mockery
|
||||
r-pingr
|
||||
r-rstudioapi
|
||||
r-testthat
|
||||
r-withr
|
||||
)
|
||||
source=("https://cran.r-project.org/src/contrib/${_pkgname}_${_pkgver}.tar.gz")
|
||||
sha256sums=('e7e70605cead736ea15b0e10c0aea14c90ff7c3d36afa10142fd8f6a14711965')
|
||||
source=("https://cran.r-project.org/src/contrib/${_pkgname}_${_pkgver}.tar.gz"
|
||||
"system-libs.patch")
|
||||
md5sums=('9eddae8f9345c4e5ad3a9692be09e6f8'
|
||||
'29b1470e2d25f82ebeafc02fe3b2594a')
|
||||
b2sums=('2b5daa9c7c8e97907030933ede18e37a0f879dccfeebab7825b8475639663f757571a37d918e8ba4e724c0e34b8399b51e7ba8ca708acae87eef2291f279ed38'
|
||||
'b422c6a23d6850831433fdcf3e81684189bdaea1735fcc85edeff3202fe084f4167876949ff9ddfd5654cb2ce202ed005800a217dfe9bb12fb8240456880b4f1')
|
||||
|
||||
prepare() {
|
||||
# devendor R dependencies
|
||||
patch -Np1 -i system-libs.patch
|
||||
}
|
||||
|
||||
build() {
|
||||
R CMD INSTALL ${_pkgname}_${_pkgver}.tar.gz -l "${srcdir}"
|
||||
mkdir build
|
||||
R CMD INSTALL -l build "$_pkgname"
|
||||
}
|
||||
|
||||
check() {
|
||||
cd "$_pkgname/tests"
|
||||
R_LIBS="$srcdir/build" NOT_CRAN=true Rscript --vanilla testthat.R
|
||||
}
|
||||
|
||||
package() {
|
||||
install -dm0755 "${pkgdir}/usr/lib/R/library"
|
||||
cp -a --no-preserve=ownership "${_pkgname}" "${pkgdir}/usr/lib/R/library"
|
||||
install -d "$pkgdir/usr/lib/R/library"
|
||||
cp -a --no-preserve=ownership "build/$_pkgname" "$pkgdir/usr/lib/R/library"
|
||||
}
|
||||
# vim:set ts=2 sw=2 et:
|
||||
|
|
|
@ -1,12 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
from lilaclib import *
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.normpath(f'{__file__}/../../../lilac-extensions'))
|
||||
from lilac_r_utils import r_pre_build
|
||||
|
||||
import shutil, tarfile
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
def pre_build():
|
||||
for line in edit_file('PKGBUILD'):
|
||||
if line.startswith('_pkgver='):
|
||||
line = f'_pkgver={_G.newver}'
|
||||
print(line)
|
||||
update_pkgver_and_pkgrel(_G.newver.replace(':', '.').replace('-', '.'))
|
||||
# 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,
|
||||
)
|
||||
|
||||
def post_build():
|
||||
git_pkgbuild_commit()
|
||||
|
|
|
@ -1,9 +1,29 @@
|
|||
build_prefix: extra-x86_64
|
||||
maintainers:
|
||||
- github: sukanka
|
||||
email: su975853527@gmail.com
|
||||
- github: pekkarr
|
||||
email: pekkarr@protonmail.com
|
||||
repo_depends:
|
||||
- r-callr
|
||||
- r-cli
|
||||
- r-curl
|
||||
- r-desc
|
||||
- r-filelock
|
||||
- r-jsonlite
|
||||
- r-lpsolve
|
||||
- r-pkgbuild
|
||||
- r-pkgcache
|
||||
- r-pkgdepends
|
||||
- r-pkgsearch
|
||||
- r-processx
|
||||
- r-ps
|
||||
- r-r6
|
||||
- r-zip
|
||||
repo_makedepends:
|
||||
- r-mockery
|
||||
- r-testthat
|
||||
update_on:
|
||||
- regex: pak_([\d._-]+).tar.gz
|
||||
source: regex
|
||||
url: https://cran.r-project.org/package=pak
|
||||
- alias: r
|
||||
- source: rpkgs
|
||||
pkgname: pak
|
||||
repo: cran
|
||||
md5: true
|
||||
- alias: r
|
||||
|
|
17
BioArchLinux/r-pak/system-libs.patch
Normal file
17
BioArchLinux/r-pak/system-libs.patch
Normal file
|
@ -0,0 +1,17 @@
|
|||
diff --git a/pak/src/Makevars.in b/pak/src/Makevars.in
|
||||
index c6c73fd..f012da3 100644
|
||||
--- a/pak/src/Makevars.in
|
||||
+++ b/pak/src/Makevars.in
|
||||
@@ -7,10 +7,7 @@ clean:
|
||||
@echo Nothing to clean.
|
||||
|
||||
mylibs:
|
||||
- @unset SHLIB R_PACKAGE_NAME R_INSTALL_PKG MAKEFLAGS \
|
||||
- R_DEFAULT_PACKAGES && \
|
||||
- "$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" --vanilla \
|
||||
- "install-embedded.R" --build=$(BUILD_PLATFORM) \
|
||||
- --target=$(TARGET_PLATFORM) 2>&1 | grep -v "^\\*"
|
||||
+ ln -s /usr/lib/R/library $(R_PACKAGE_DIR)
|
||||
+ touch DONE
|
||||
|
||||
.PHONY: all mylibs clean
|
|
@ -32,6 +32,10 @@ def r_update_pkgver_and_pkgrel(newver: str):
|
|||
if oldrel is None:
|
||||
raise Exception("pkgrel is not defined")
|
||||
|
||||
def _r_name_to_arch(r_pkg_name: str) -> str:
|
||||
"""Converts R package name to the corresponding Arch package"""
|
||||
return f"r-{r_pkg_name.lower()}"
|
||||
|
||||
class Description:
|
||||
"""Metadata from the DESCRIPTION file, package names are converted to Arch format"""
|
||||
|
||||
|
@ -87,10 +91,6 @@ class Description:
|
|||
|
||||
return {field.decode(encoding): value.decode(encoding) for field, value in rawdata.items()}
|
||||
|
||||
def _r_name_to_arch(self, r_pkg_name: str) -> str:
|
||||
"""Converts R package name to the corresponding Arch package"""
|
||||
return f"r-{r_pkg_name.lower()}"
|
||||
|
||||
def _parse_deps(self, field: str) -> list:
|
||||
"""Parse a field that contains a list of dependencies"""
|
||||
if field not in self.desc:
|
||||
|
@ -102,7 +102,7 @@ class Description:
|
|||
dep = dep[:i]
|
||||
dep = dep.strip()
|
||||
if dep != "R" and len(dep) > 0:
|
||||
ret.append(self._r_name_to_arch(dep))
|
||||
ret.append(_r_name_to_arch(dep))
|
||||
return ret
|
||||
|
||||
class Pkgbuild:
|
||||
|
@ -236,12 +236,14 @@ class CheckConfig:
|
|||
expect_needscompilation: bool = None,
|
||||
expect_systemrequirements: str = None,
|
||||
expect_title: str = None,
|
||||
extra_r_depends: list = [],
|
||||
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.ignore_fortran_files = ignore_fortran_files
|
||||
|
||||
def check_default_pkgs(pkg: Pkgbuild, desc: Description, cfg: CheckConfig):
|
||||
|
@ -255,10 +257,12 @@ 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))
|
||||
errors = []
|
||||
for dep in pkg.depends:
|
||||
if dep.startswith("r-"):
|
||||
if (dep not in desc.depends) and (dep not in desc.imports):
|
||||
if dep not in expected_depends:
|
||||
errors.append(f"Unnecessary dependency: {dep}")
|
||||
else:
|
||||
implicit_r_dep = True
|
||||
|
@ -266,7 +270,7 @@ def check_depends(pkg: Pkgbuild, desc: Description, cfg: CheckConfig):
|
|||
explicit_r_dep = True
|
||||
|
||||
not_missing = True
|
||||
for dep in desc.depends + desc.imports:
|
||||
for dep in expected_depends:
|
||||
if (dep not in cfg.default_r_pkgs) and (dep not in pkg.depends):
|
||||
not_missing = False
|
||||
errors.append(f"Missing dependency: {dep}")
|
||||
|
@ -398,7 +402,7 @@ def r_check_pkgbuild(newver: str, cfg: CheckConfig):
|
|||
pkgbuild = Pkgbuild()
|
||||
cfg.default_r_pkgs = get_default_r_pkgs()
|
||||
errors = []
|
||||
with tarfile.open(f"{pkgbuild._pkgname}_{newver}.tar.gz", "r") as tar:
|
||||
with tarfile.open(f"{pkgbuild._pkgname}_{newver}.tar.gz", "r:gz") as tar:
|
||||
description = Description(tar, pkgbuild._pkgname)
|
||||
cfg.tar = tar
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue