dev-util/pkgcheck: Sync with Gentoo

It's from Gentoo commit 73d14684113ef377a34369d2ec1b357453d325fc.
This commit is contained in:
Flatcar Buildbot 2025-08-04 07:14:29 +00:00
parent 2b9bea545e
commit 2efdf21290
5 changed files with 177 additions and 1 deletions

View File

@ -1,2 +1,3 @@
DIST pkgcheck-0.10.34.tar.gz 382566 BLAKE2B d91302f673326bf4756e06c2bad1ad89b10f14a08ac54a24a6a00d7a95d4313e5e1755393aefa55e1057a396483b023cc38e67902238e2620a76961feb8b2a81 SHA512 57ec0ccea00cde4187219f85d23f755878e2298f6219cb9b18eb35f927a685aac2d9b9c73045f6750f90959abb6313a1ed99dedaae4f0ec6b59f08585253a410
DIST pkgcheck-0.10.36.tar.gz 383659 BLAKE2B 1129695650790409d338f0a885d305dd4713c7f5222ae812ea6381c004b4c28321929df963240cd2a27c5dd0db7dd96f1a2829fff72dc627cdbd1399c600bb4e SHA512 c6c87ccd2d63e558efd7613142b2ac6dcfe4b4ea55b0e78d4502760d508015158189debebe26579e0cb26447fc4529ccb779fa4462d78af75e1c216f8a85177b
DIST pkgcheck-0.10.37.tar.gz 388402 BLAKE2B 8e93290da49ed9d8231550a7602300c93d16f2dc4be040f88690bf4cf996b51f8aac3cb26b2478345b10dfb1faddc185d6316810d5bac091fc5cae504ced459d SHA512 84c1717fad6a7f41dcc069dbdb68e73062606d7e0497286cba7255e415e8b317cb4aa396d9bc46f873712a65fa0e3cd95216df368ca73381f81c160308329f15

View File

@ -0,0 +1,66 @@
Subject: [PATCH] bash: update support to tree-sitter~=0.25
Also add backward compatible code for tree-sitter < 0.25.
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -6,7 +6,7 @@ requires = [
"lazy-object-proxy",
"lxml",
"pathspec",
- "tree-sitter~=0.24.0",
+ "tree-sitter~=0.25.0",
"tree-sitter-bash~=0.23.1",
"snakeoil~=0.10.11",
"pkgcore~=0.12.30",
@@ -45,7 +45,7 @@ dependencies = [
"lazy-object-proxy",
"lxml",
"pathspec",
- "tree-sitter~=0.24.0",
+ "tree-sitter~=0.25.0",
"tree-sitter-bash~=0.23.1",
"snakeoil~=0.10.11",
"pkgcore~=0.12.30",
--- a/src/pkgcheck/bash/__init__.py
+++ b/src/pkgcheck/bash/__init__.py
@@ -6,7 +6,17 @@ import tree_sitter_bash
from tree_sitter import Language, Parser, Query
lang = Language(tree_sitter_bash.language())
-query = lang.query
+
+try:
+ from tree_sitter import QueryCursor
+
+ def query(query_str: str) -> "QueryCursor":
+ return QueryCursor(Query(lang, query_str))
+except ImportError: # tree-sitter < 0.25
+ QueryCursor = Query
+ query = lang.query
+
+
parser = Parser(language=lang)
# various parse tree queries
@@ -29,14 +39,14 @@ class ParseTree:
"""Return the ebuild string associated with a given parse tree node."""
return self.data[node.start_byte : node.end_byte].decode("utf8")
- def global_query(self, query: Query):
+ def global_query(self, query: QueryCursor):
"""Run a given parse tree query returning only those nodes in global scope."""
for x in self.tree.root_node.children:
# skip nodes in function scope
if x.type != "function_definition":
yield from chain.from_iterable(query.captures(x).values())
- def func_query(self, query: Query):
+ def func_query(self, query: QueryCursor):
"""Run a given parse tree query returning only those nodes in function scope."""
for x in self.tree.root_node.children:
# only return nodes in function scope
--
2.50.1

View File

@ -55,8 +55,13 @@ BDEPEND="${RDEPEND}
)
"
PATCHES=(
"${FILESDIR}"/${P}-ts0.25.patch
)
SITEFILE="50${PN}-gentoo.el"
EPYTEST_PLUGINS=( pkgcore )
distutils_enable_tests pytest
export USE_SYSTEM_TREE_SITTER_BASH=1

View File

@ -0,0 +1,102 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_USE_PEP517=standalone
PYTHON_COMPAT=( python3_{11..14} )
inherit elisp-common distutils-r1 optfeature
if [[ ${PV} == *9999 ]] ; then
EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/pkgcore/pkgcheck.git
https://github.com/pkgcore/pkgcheck.git"
inherit git-r3
else
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-macos"
inherit pypi
fi
DESCRIPTION="pkgcore-based QA utility for ebuild repos"
HOMEPAGE="https://github.com/pkgcore/pkgcheck"
LICENSE="BSD MIT"
SLOT="0"
IUSE="emacs"
if [[ ${PV} == *9999 ]]; then
RDEPEND="
~dev-python/snakeoil-9999[${PYTHON_USEDEP}]
~sys-apps/pkgcore-9999[${PYTHON_USEDEP}]"
else
RDEPEND="
>=dev-python/snakeoil-0.10.11[${PYTHON_USEDEP}]
>=sys-apps/pkgcore-0.12.30[${PYTHON_USEDEP}]"
fi
RDEPEND+="
app-arch/zstd
>=dev-libs/tree-sitter-bash-0.21.0[python,${PYTHON_USEDEP}]
dev-python/chardet[${PYTHON_USEDEP}]
dev-python/lazy-object-proxy[${PYTHON_USEDEP}]
dev-python/lxml[${PYTHON_USEDEP}]
dev-python/pathspec[${PYTHON_USEDEP}]
>=dev-python/tree-sitter-0.25.0[${PYTHON_USEDEP}]
emacs? (
>=app-editors/emacs-24.1:*
app-emacs/ebuild-mode
app-emacs/flycheck
)
"
BDEPEND="${RDEPEND}
>=dev-python/flit-core-3.8[${PYTHON_USEDEP}]
test? (
dev-python/pytest[${PYTHON_USEDEP}]
dev-python/requests[${PYTHON_USEDEP}]
dev-vcs/git
)
"
SITEFILE="50${PN}-gentoo.el"
EPYTEST_PLUGINS=( pkgcore )
distutils_enable_tests pytest
export USE_SYSTEM_TREE_SITTER_BASH=1
src_prepare() {
distutils-r1_src_prepare
# unpin dependencies
sed -i -e 's:~=:>=:' pyproject.toml || die
}
src_compile() {
distutils-r1_src_compile
if use emacs ; then
pushd "${S}"/contrib/emacs >/dev/null || die
elisp-compile *.el
popd >/dev/null || die
fi
}
python_install_all() {
local DOCS=( NEWS.rst )
[[ ${PV} == *9999 ]] || doman build/sphinx/man/*
distutils-r1_python_install_all
if use emacs ; then
elisp-install ${PN} "${S}"/contrib/emacs/*.el{,c}
elisp-site-file-install "${FILESDIR}/${SITEFILE}"
fi
}
pkg_postinst() {
use emacs && elisp-site-regen
optfeature "Network check support" dev-python/requests
optfeature "Perl module version check support" dev-perl/Gentoo-PerlMod-Version
}
pkg_postrm() {
use emacs && elisp-site-regen
}

View File

@ -33,12 +33,13 @@ else
>=sys-apps/pkgcore-0.12.30[${PYTHON_USEDEP}]"
fi
RDEPEND+="
app-arch/zstd
>=dev-libs/tree-sitter-bash-0.21.0[python,${PYTHON_USEDEP}]
dev-python/chardet[${PYTHON_USEDEP}]
dev-python/lazy-object-proxy[${PYTHON_USEDEP}]
dev-python/lxml[${PYTHON_USEDEP}]
dev-python/pathspec[${PYTHON_USEDEP}]
>=dev-python/tree-sitter-0.23.0[${PYTHON_USEDEP}]
>=dev-python/tree-sitter-0.25.0[${PYTHON_USEDEP}]
emacs? (
>=app-editors/emacs-24.1:*
app-emacs/ebuild-mode
@ -56,6 +57,7 @@ BDEPEND="${RDEPEND}
SITEFILE="50${PN}-gentoo.el"
EPYTEST_PLUGINS=( pkgcore )
distutils_enable_tests pytest
export USE_SYSTEM_TREE_SITTER_BASH=1