pkgcore / pkgcheck

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

Detect unused/stray USE flags #427

Open thesamesam opened 2 years ago

thesamesam commented 2 years ago

It's possible to have USE flags in IUSE which are declared in metadata.xml (or global USE flags) which don't actually do anything (no references in dependencies, or in the ebuilds).

Example: see https://gitweb.gentoo.org/repo/gentoo.git/commit/net-misc/iputils?id=0b738488bed8d9735db35ade5a01834b3e07ebcf.

From 0b738488bed8d9735db35ade5a01834b3e07ebcf Mon Sep 17 00:00:00 2001
From: Mike Gilbert <floppym@gentoo.org>
Date: Wed, 11 May 2022 14:29:07 -0400
Subject: net-misc/iputils: drop non-functional USE flags

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
---
 net-misc/iputils/iputils-20210722-r1.ebuild | 2 +-
 net-misc/iputils/iputils-20211215.ebuild    | 2 +-
 net-misc/iputils/iputils-99999999.ebuild    | 2 +-
 net-misc/iputils/metadata.xml               | 2 --
 4 files changed, 3 insertions(+), 5 deletions(-)

(limited to 'net-misc/iputils')

diff --git a/net-misc/iputils/iputils-20210722-r1.ebuild b/net-misc/iputils/iputils-20210722-r1.ebuild
index 2ae5257319b..a97324cae33 100644
--- a/net-misc/iputils/iputils-20210722-r1.ebuild
+++ b/net-misc/iputils/iputils-20210722-r1.ebuild
@@ -28,7 +28,7 @@ HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"

 LICENSE="BSD GPL-2+ rdisc"
 SLOT="0"
-IUSE="+arping caps clockdiff doc gcrypt idn nettle nls rarpd rdisc ssl static test tftpd tracepath traceroute6"
+IUSE="+arping caps clockdiff doc idn nls rarpd rdisc static test tftpd tracepath traceroute6"
 RESTRICT="!test? ( test )"

 BDEPEND="
diff --git a/net-misc/iputils/iputils-20211215.ebuild b/net-misc/iputils/iputils-20211215.ebuild
index dfcc596a154..74d10298e9c 100644
--- a/net-misc/iputils/iputils-20211215.ebuild
+++ b/net-misc/iputils/iputils-20211215.ebuild
@@ -29,7 +29,7 @@ HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"

 LICENSE="BSD GPL-2+ rdisc"
 SLOT="0"
-IUSE="+arping caps clockdiff doc gcrypt idn nettle nls rarpd rdisc ssl static test tracepath"
+IUSE="+arping caps clockdiff doc idn nls rarpd rdisc static test tracepath"
 RESTRICT="!test? ( test )"

 LIB_DEPEND="
diff --git a/net-misc/iputils/iputils-99999999.ebuild b/net-misc/iputils/iputils-99999999.ebuild
index cef1837240e..e94679e4343 100644
--- a/net-misc/iputils/iputils-99999999.ebuild
+++ b/net-misc/iputils/iputils-99999999.ebuild
@@ -29,7 +29,7 @@ HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"

 LICENSE="BSD GPL-2+ rdisc"
 SLOT="0"
-IUSE="+arping caps clockdiff doc gcrypt idn nettle nls ssl static test tracepath"
+IUSE="+arping caps clockdiff doc idn nls static test tracepath"
 RESTRICT="!test? ( test )"

 LIB_DEPEND="
diff --git a/net-misc/iputils/metadata.xml b/net-misc/iputils/metadata.xml
index b6ebdf9c592..cd78568cc22 100644
--- a/net-misc/iputils/metadata.xml
+++ b/net-misc/iputils/metadata.xml
@@ -8,8 +8,6 @@
   <use>
     <flag name="arping">Build and install arping -- tool for sending ARP requests to peers (see also <pkg>net-analyzer/arping</pkg>)</flag>
     <flag name="clockdiff">Build and install clockdiff -- tool for comparing clocks via ICMP packets</flag>
-    <flag name="gcrypt">Use <pkg>dev-libs/libgcrypt</pkg> for md5 support</flag>
-    <flag name="nettle">Use <pkg>dev-libs/nettle</pkg> for md5 support</flag>
     <flag name="rarpd">Build and install rarpd -- server for handling RARP (reverse ARP) requests; generally only used by old systems</flag>
     <flag name="rdisc">Build and install rdisc -- server for the client side of the ICMP router discover protocol</flag>
     <flag name="tftpd">Build and install tftpd -- server for the Trivial File Transfer Protocol (see also <pkg>net-ftp/tftp-hpa</pkg>)</flag>
-- 
cgit v1.2.3-18-g5258
thesamesam commented 2 years ago

This is related to https://github.com/pkgcore/pkgcheck/issues/414 but it's a bit different.

The other bug might hit some cases of this bug.

arthurzam commented 2 years ago

OK, so as preparation, the list of places where a USE flag can be used:

Special cases that I exclude:

ferringb commented 7 months ago

I'd suggest disabling the check if any variable reference is found for those invocations- IE, use $VAR. It's a stretch, but consider an eclass that is renaming a use flag- I would use an intermediate var to hold what the flag is for the 'before' and 'after', and this check wouldn't like that.