pkgcore / pkgcheck

pkgcore-based QA utility for ebuild repos
https://pkgcore.github.io/pkgcheck
BSD 3-Clause "New" or "Revised" License
34 stars 29 forks source link

[New Check]: Detect invalid use of `has_version --host-root` with EAPI 7 #630

Closed thesamesam closed 9 months ago

thesamesam commented 9 months ago

Is there an existing such new check request for this?

Explain

EAPI 7 bans has_version --host-root in favour of using the relevant dependency class (like -b).

Examples

https://bugs.gentoo.org/915019

https://github.com/gentoo/gentoo/blob/ddbbca3c064b767d9dab6b63a6046537f8ebc01e/dev-java/openjfx/openjfx-11.0.11_p1-r1.ebuild#L131 has:

    if has_version --host-root dev-java/openjdk:${SLOT}; then
        export JAVA_HOME=${EPREFIX}/usr/$(get_libdir)/openjdk-${SLOT}
        export JDK_HOME="${JAVA_HOME}"
        export ANT_RESPECT_JAVA_HOME=true
       [...]
   fi

Output message

BadHasVersionArgument

Documentation

has_version used with illegal argument

Result level

error

meklu commented 9 months ago

https://github.com/gentoo/gentoo/blob/ddbbca3c064b767d9dab6b63a6046537f8ebc01e/dev-java/openjfx/openjfx-11.0.11_p1-r1.ebuild#L131 has:

  if has_version --host-root dev-java/openjdk:${SLOT}; then
      export JAVA_HOME=${EPREFIX}/usr/$(get_libdir)/openjdk-${SLOT}
      export JDK_HOME="${JAVA_HOME}"
      export ANT_RESPECT_JAVA_HOME=true
       [...]
   fi

Just a couple of lines later https://github.com/gentoo/gentoo/blob/ddbbca3c064b767d9dab6b63a6046537f8ebc01e/dev-java/openjfx/openjfx-11.0.11_p1-r1.ebuild#L138 has the following:

            JDK_HOME=$(best_version --host-root dev-java/openjdk-bin:${SLOT})
            [[ -n ${JDK_HOME} ]] || die "Build VM not found!"

Judging by the trace in the bugzilla bug these {has,best}_version functions share code, so you should probably be looking for best_version --host-root as well. The query function reference being silent about the old option seems to reinforce this notion (https://devmanual.gentoo.org/function-reference/query-functions/).

ulm commented 9 months ago

--host-root was replaced by -b, -d and -r in EAPI 7 (not 8) already.

arthurzam commented 9 months ago

When on commit https://github.com/gentoo/gentoo/commit/ddbbca3c064b767d9dab6b63a6046537f8ebc01e , I get those results:

dev-java/openjfx
  BadHasVersionArgument: version 11.0.9_p0: 'best_version --host-root' is invalid in EAPI>=7, on line: 138
  BadHasVersionArgument: version 11.0.9_p0: 'has_version --host-root' is invalid in EAPI>=7, on lines: 131, 186
  BadHasVersionArgument: version 11.0.9_p0-r1: 'best_version --host-root' is invalid in EAPI>=7, on line: 138
  BadHasVersionArgument: version 11.0.9_p0-r1: 'has_version --host-root' is invalid in EAPI>=7, on lines: 131, 186
  BadHasVersionArgument: version 11.0.11_p1: 'best_version --host-root' is invalid in EAPI>=7, on line: 138
  BadHasVersionArgument: version 11.0.11_p1: 'has_version --host-root' is invalid in EAPI>=7, on lines: 131, 186
  BadHasVersionArgument: version 11.0.11_p1-r1: 'best_version --host-root' is invalid in EAPI>=7, on line: 138
  BadHasVersionArgument: version 11.0.11_p1-r1: 'has_version --host-root' is invalid in EAPI>=7, on lines: 131, 186

net-misc/zerotier
  BadHasVersionArgument: version 1.6.4: 'has_version --host-root' is invalid in EAPI>=7, on lines: 38, 43

When on master, I only get this single find:

net-misc/zerotier
  BadHasVersionArgument: version 1.6.4: 'has_version --host-root' is invalid in EAPI>=7, on lines: 38, 43
arthurzam commented 9 months ago

Looking at it more, it should be part of BannedEapiCommand result, something like:

net-misc/zerotier
  BannedEapiCommand: version 1.6.4: 'has_version --host-root' banned in EAPI 7, used on line 38: 'has_version --host-root "sys-devel/clang:${LLVM_SLOT}"'
  BannedEapiCommand: version 1.6.4: 'has_version --host-root' banned in EAPI 7, used on line 43: 'has_version --host-root "=sys-devel/lld-${LLVM_SLOT}*"'