diff --git a/src/pkgcheck/checks/metadata_xml.py b/src/pkgcheck/checks/metadata_xml.py index 12d171124..5d85b74e8 100644 --- a/src/pkgcheck/checks/metadata_xml.py +++ b/src/pkgcheck/checks/metadata_xml.py @@ -702,6 +702,14 @@ def feed(self, pkgset): urls = set(filter(self.__filter_url, all_urls)) urls = sorted(urls.union(pkg.homepage), key=len) + if "git-r3" in pkg.inherited and hasattr(pkg, "environment"): + egit_repo_uri = re.compile(r"^declare -- EGIT_REPO_URI=\"(.*)\"$") + for env_line in pkg.environment.data.splitlines(): + result = re.search(egit_repo_uri, env_line) + if result: + urls.append(result.group(1).removesuffix(".git")) + break + for remote_type, regex in self.remotes_map: if remote_type in remotes: continue diff --git a/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json b/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json index 9d74b4e94..782292d8c 100644 --- a/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json +++ b/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/expected.json @@ -1,4 +1,5 @@ {"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "gitlab", "value": "pkgcore/pkgcheck/extra/MissingRemoteId", "uri": "https://gitlab.com/pkgcore/pkgcheck/extra/MissingRemoteId/-/archive/1/MissingRemoteId-1.tar.bz2"} +{"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "kde-invent", "value": "pkgcore/pkgcheck", "uri": "https://invent.kde.org/pkgcore/pkgcheck"} {"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "heptapod", "value": "pkgcore/pkgcore", "uri": "https://foss.heptapod.net/pkgcore/pkgcore/-/archive/4/MissingRemoteId-4.tar.bz2"} {"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "pypi", "value": "MissingRemoteId", "uri": "https://files.pythonhosted.org/packages/source/M/MissingRemoteId/MissingRemoteId-1.tar.gz"} {"__class__": "MissingRemoteId", "category": "MissingRemoteIdCheck", "package": "MissingRemoteId", "remote_type": "sourceforge", "value": "pkgcheck", "uri": "https://downloads.sourceforge.net/pkgcheck/MissingRemoteId-2.tar.gz"} diff --git a/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/fix.patch b/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/fix.patch index 035f9ad4b..905e536a5 100644 --- a/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/fix.patch +++ b/testdata/data/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/fix.patch @@ -1,6 +1,6 @@ --- eapis-testing/MissingRemoteIdCheck/MissingRemoteId/metadata.xml +++ fixed/MissingRemoteIdCheck/MissingRemoteId/metadata.xml -@@ -3,6 +3,10 @@ +@@ -3,6 +3,11 @@ pkgcore/pkgcheck @@ -8,6 +8,7 @@ + pkgcore/pkgcheck + MissingRemoteId + pkgcheck ++ pkgcore/pkgcheck enable tests diff --git a/testdata/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-5.ebuild b/testdata/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-5.ebuild new file mode 100644 index 000000000..f1741c994 --- /dev/null +++ b/testdata/repos/eapis-testing/MissingRemoteIdCheck/MissingRemoteId/MissingRemoteId-5.ebuild @@ -0,0 +1,9 @@ +EAPI=7 + +inherit git-r3 + +DESCRIPTION="Check EGIT_REPO_URI" +HOMEPAGE="https://pkgcore.github.io/pkgcheck/" +EGIT_REPO_URI="https://invent.kde.org/pkgcore/pkgcheck.git" +LICENSE="BSD" +SLOT="0" diff --git a/testdata/repos/eapis-testing/eclass/git-r3.eclass b/testdata/repos/eapis-testing/eclass/git-r3.eclass new file mode 100644 index 000000000..6d539f254 --- /dev/null +++ b/testdata/repos/eapis-testing/eclass/git-r3.eclass @@ -0,0 +1,40 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: git-r3.eclass +# @MAINTAINER: +# Michał Górny +# @SUPPORTED_EAPIS: 7 8 +# @BLURB: Eclass for fetching and unpacking git repositories. +# @DESCRIPTION: +# Third generation eclass for easing maintenance of live ebuilds using +# git as remote repository. + +case ${EAPI} in + 7|8) ;; + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; +esac + +if [[ ! ${_GIT_R3_ECLASS} ]]; then +_GIT_R3_ECLASS=1 + +# @ECLASS_VARIABLE: EGIT_REPO_URI +# @REQUIRED +# @DESCRIPTION: +# URIs to the repository, e.g. https://foo. If multiple URIs are +# provided, the eclass will consider the remaining URIs as fallbacks +# to try if the first URI does not work. For supported URI syntaxes, +# read the manpage for git-clone(1). +# +# URIs should be using https:// whenever possible. http:// and git:// +# URIs are completely insecure and their use (even if only as +# a fallback) renders the ebuild completely vulnerable to MITM attacks. +# +# Can be a whitespace-separated list or an array. +# +# Example: +# @CODE +# EGIT_REPO_URI="https://a/b.git https://c/d.git" +# @CODE + +fi