From f4dfce46a41fc0ed283d4625b7283ca3c1c231a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 22 Nov 2024 16:58:22 +0100 Subject: [PATCH 1/2] eclass: Update for RUST_DEPEND MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- src/pkgcheck/checks/eclass.py | 6 +++--- .../EclassManualDepsCheck/RustMissingDeps/fix.patch | 2 +- .../dev-lang/rust-bin/rust-bin-1.81.0.ebuild | 4 ++++ .../dev-lang/rust-bin/rust-bin-1.82.0.ebuild | 4 ++++ .../repos/standalone/dev-lang/rust/rust-1.81.0.ebuild | 4 ++++ .../repos/standalone/dev-lang/rust/rust-1.82.0.ebuild | 4 ++++ testdata/repos/standalone/eclass/cargo.eclass | 2 ++ testdata/repos/standalone/eclass/rust.eclass | 10 ++++++++++ testdata/repos/standalone/virtual/rust/rust-0.ebuild | 2 -- 9 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.81.0.ebuild create mode 100644 testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.82.0.ebuild create mode 100644 testdata/repos/standalone/dev-lang/rust/rust-1.81.0.ebuild create mode 100644 testdata/repos/standalone/dev-lang/rust/rust-1.82.0.ebuild create mode 100644 testdata/repos/standalone/eclass/rust.eclass delete mode 100644 testdata/repos/standalone/virtual/rust/rust-0.ebuild diff --git a/src/pkgcheck/checks/eclass.py b/src/pkgcheck/checks/eclass.py index 52bcea6ee..f806e50e5 100644 --- a/src/pkgcheck/checks/eclass.py +++ b/src/pkgcheck/checks/eclass.py @@ -516,9 +516,9 @@ class RubyMissingDeps(results.VersionResult, results.Warning): class RustMissingDeps(results.VersionResult, results.Warning): - """Package sets ``CARGO_OPTIONAL`` but does not depend on ``virtual/rust``.""" + """Package sets ``CARGO_OPTIONAL`` but does not use ``${RUST_DEPEND}``.""" - desc = "sets CARGO_OPTIONAL but does not depend on virtual/rust" + desc = "sets CARGO_OPTIONAL but does not use ${RUST_DEPEND}" class TmpfilesMissingDeps(results.VersionResult, results.Warning): @@ -542,7 +542,7 @@ class EclassManualDepsCheck(Check): dependencies = ( # eclass, variable, one of deps, class - ("cargo", "CARGO_OPTIONAL", {"virtual/rust"}, RustMissingDeps), + ("cargo", "CARGO_OPTIONAL", {"dev-lang/rust", "dev-lang/rust-bin"}, RustMissingDeps), ("go-module", "GO_OPTIONAL", {"dev-lang/go"}, GoMissingDeps), ( "ruby-ng", diff --git a/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch b/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch index 08394782e..5d75114ec 100644 --- a/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch +++ b/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch @@ -6,4 +6,4 @@ diff -Naur standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-1.eb LICENSE="BSD" SLOT="0" + -+BDEPEND="virtual/rust" ++BDEPEND="${RUST_DEPEND}" diff --git a/testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.81.0.ebuild b/testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.81.0.ebuild new file mode 100644 index 000000000..2c6d46284 --- /dev/null +++ b/testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.81.0.ebuild @@ -0,0 +1,4 @@ +DESCRIPTION="Stub ebuild" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="${PV}" diff --git a/testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.82.0.ebuild b/testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.82.0.ebuild new file mode 100644 index 000000000..2c6d46284 --- /dev/null +++ b/testdata/repos/standalone/dev-lang/rust-bin/rust-bin-1.82.0.ebuild @@ -0,0 +1,4 @@ +DESCRIPTION="Stub ebuild" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="${PV}" diff --git a/testdata/repos/standalone/dev-lang/rust/rust-1.81.0.ebuild b/testdata/repos/standalone/dev-lang/rust/rust-1.81.0.ebuild new file mode 100644 index 000000000..2c6d46284 --- /dev/null +++ b/testdata/repos/standalone/dev-lang/rust/rust-1.81.0.ebuild @@ -0,0 +1,4 @@ +DESCRIPTION="Stub ebuild" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="${PV}" diff --git a/testdata/repos/standalone/dev-lang/rust/rust-1.82.0.ebuild b/testdata/repos/standalone/dev-lang/rust/rust-1.82.0.ebuild new file mode 100644 index 000000000..2c6d46284 --- /dev/null +++ b/testdata/repos/standalone/dev-lang/rust/rust-1.82.0.ebuild @@ -0,0 +1,4 @@ +DESCRIPTION="Stub ebuild" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="${PV}" diff --git a/testdata/repos/standalone/eclass/cargo.eclass b/testdata/repos/standalone/eclass/cargo.eclass index 217dc8e8d..04deb1f4e 100644 --- a/testdata/repos/standalone/eclass/cargo.eclass +++ b/testdata/repos/standalone/eclass/cargo.eclass @@ -1,5 +1,7 @@ # cargo eclass +inherit rust + CARGO_CRATE_URIS=${CRATES} cargo_crate_uris() { :; } diff --git a/testdata/repos/standalone/eclass/rust.eclass b/testdata/repos/standalone/eclass/rust.eclass new file mode 100644 index 000000000..b85f9bde8 --- /dev/null +++ b/testdata/repos/standalone/eclass/rust.eclass @@ -0,0 +1,10 @@ +# rust eclass + +RUST_DEPEND=" + || ( + dev-lang/rust-bin:1.82.0 + dev-lang/rust:1.82.0 + dev-lang/rust-bin:1.81.0 + dev-lang/rust:1.81.0 + ) +" diff --git a/testdata/repos/standalone/virtual/rust/rust-0.ebuild b/testdata/repos/standalone/virtual/rust/rust-0.ebuild deleted file mode 100644 index 9c2ce2e95..000000000 --- a/testdata/repos/standalone/virtual/rust/rust-0.ebuild +++ /dev/null @@ -1,2 +0,0 @@ -DESCRIPTION="Stub ebuild" -SLOT="0" From 117712e793a8052ba185d510e1cbd20f314a383e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 22 Nov 2024 17:24:41 +0100 Subject: [PATCH 2/2] eclass: Support rust.eclass and RUST_OPTIONAL as well MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: https://github.com/pkgcore/pkgcheck/issues/714 Signed-off-by: Michał Górny --- src/pkgcheck/checks/eclass.py | 5 +++-- .../RustMissingDeps/expected.json | 2 ++ .../RustMissingDeps/fix.patch | 18 ++++++++++++++++++ .../RustMissingDeps/RustMissingDeps-2.ebuild | 6 ++++++ .../RustMissingDeps/RustMissingDeps-3.ebuild | 10 ++++++++++ .../RustMissingDeps/RustMissingDeps-4.ebuild | 10 ++++++++++ testdata/repos/standalone/eclass/cargo.eclass | 4 ++++ 7 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-2.ebuild create mode 100644 testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild create mode 100644 testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild diff --git a/src/pkgcheck/checks/eclass.py b/src/pkgcheck/checks/eclass.py index f806e50e5..5a6b6430e 100644 --- a/src/pkgcheck/checks/eclass.py +++ b/src/pkgcheck/checks/eclass.py @@ -516,9 +516,9 @@ class RubyMissingDeps(results.VersionResult, results.Warning): class RustMissingDeps(results.VersionResult, results.Warning): - """Package sets ``CARGO_OPTIONAL`` but does not use ``${RUST_DEPEND}``.""" + """Package sets ``RUST_OPTIONAL`` but does not use ``${RUST_DEPEND}``.""" - desc = "sets CARGO_OPTIONAL but does not use ${RUST_DEPEND}" + desc = "sets RUST_OPTIONAL (or CARGO_OPTIONAL) but does not use ${RUST_DEPEND}" class TmpfilesMissingDeps(results.VersionResult, results.Warning): @@ -543,6 +543,7 @@ class EclassManualDepsCheck(Check): dependencies = ( # eclass, variable, one of deps, class ("cargo", "CARGO_OPTIONAL", {"dev-lang/rust", "dev-lang/rust-bin"}, RustMissingDeps), + ("rust", "RUST_OPTIONAL", {"dev-lang/rust", "dev-lang/rust-bin"}, RustMissingDeps), ("go-module", "GO_OPTIONAL", {"dev-lang/go"}, GoMissingDeps), ( "ruby-ng", diff --git a/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/expected.json b/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/expected.json index 43be8d931..762b9a20d 100644 --- a/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/expected.json +++ b/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/expected.json @@ -1 +1,3 @@ {"__class__": "RustMissingDeps", "category": "EclassManualDepsCheck", "package": "RustMissingDeps", "version": "1"} +{"__class__": "RustMissingDeps", "category": "EclassManualDepsCheck", "package": "RustMissingDeps", "version": "3"} +{"__class__": "RustMissingDeps", "category": "EclassManualDepsCheck", "package": "RustMissingDeps", "version": "4"} diff --git a/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch b/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch index 5d75114ec..3fc81ee04 100644 --- a/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch +++ b/testdata/data/repos/standalone/EclassManualDepsCheck/RustMissingDeps/fix.patch @@ -7,3 +7,21 @@ diff -Naur standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-1.eb SLOT="0" + +BDEPEND="${RUST_DEPEND}" +diff -Naur standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild fixed/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild +--- standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild ++++ fixed/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild +@@ -8,3 +8,5 @@ DESCRIPTION="Optional inherit without deps" + HOMEPAGE="https://github.com/pkgcore/pkgcheck" + LICENSE="BSD" + SLOT="0" ++ ++BDEPEND="${RUST_DEPEND}" +diff -Naur standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild fixed/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild +--- standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild ++++ fixed/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild +@@ -8,3 +8,5 @@ DESCRIPTION="Optional inherit without deps" + HOMEPAGE="https://github.com/pkgcore/pkgcheck" + LICENSE="BSD" + SLOT="0" ++ ++BDEPEND="${RUST_DEPEND}" diff --git a/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-2.ebuild b/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-2.ebuild new file mode 100644 index 000000000..6edadd9f0 --- /dev/null +++ b/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-2.ebuild @@ -0,0 +1,6 @@ +inherit rust + +DESCRIPTION="Normal non-optional inherit" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="0" diff --git a/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild b/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild new file mode 100644 index 000000000..11da192c3 --- /dev/null +++ b/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-3.ebuild @@ -0,0 +1,10 @@ +EAPI=7 + +RUST_OPTIONAL=1 + +inherit rust + +DESCRIPTION="Optional inherit without deps" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="0" diff --git a/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild b/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild new file mode 100644 index 000000000..a89f53a5d --- /dev/null +++ b/testdata/repos/standalone/EclassManualDepsCheck/RustMissingDeps/RustMissingDeps-4.ebuild @@ -0,0 +1,10 @@ +EAPI=7 + +RUST_OPTIONAL=1 + +inherit cargo + +DESCRIPTION="Optional inherit without deps" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +LICENSE="BSD" +SLOT="0" diff --git a/testdata/repos/standalone/eclass/cargo.eclass b/testdata/repos/standalone/eclass/cargo.eclass index 04deb1f4e..9a9eb924f 100644 --- a/testdata/repos/standalone/eclass/cargo.eclass +++ b/testdata/repos/standalone/eclass/cargo.eclass @@ -1,5 +1,9 @@ # cargo eclass +if [[ -n ${CARGO_OPTIONAL} ]]; then + RUST_OPTIONAL=1 +fi + inherit rust CARGO_CRATE_URIS=${CRATES}