From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1478291-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 6F891158010
	for <garchives@archives.gentoo.org>; Wed, 18 Jan 2023 05:19:16 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 8AE06E07D1;
	Wed, 18 Jan 2023 05:19:15 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 695DAE07D1
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Jan 2023 05:19:15 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 68425340D41
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Jan 2023 05:19:14 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 6269D828
	for <gentoo-commits@lists.gentoo.org>; Wed, 18 Jan 2023 05:19:11 +0000 (UTC)
From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" <arthurzam@gentoo.org>
Message-ID: <1673814676.9e43d725ce4c2049e53e9df444b47c388bf98573.arthurzam@gentoo>
Subject: [gentoo-commits] proj/pkgcore/pkgcheck:master commit in: src/pkgcheck/checks/, ...
X-VCS-Repository: proj/pkgcore/pkgcheck
X-VCS-Files: src/pkgcheck/checks/profiles.py testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch testdata/repos/profiledir/profiles/unknown_use/make.defaults
X-VCS-Directories: src/pkgcheck/checks/ testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/ testdata/repos/profiledir/profiles/unknown_use/
X-VCS-Committer: arthurzam
X-VCS-Committer-Name: Arthur Zamarin
X-VCS-Revision: 9e43d725ce4c2049e53e9df444b47c388bf98573
X-VCS-Branch: master
Date: Wed, 18 Jan 2023 05:19:11 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: ecdf79c1-0c14-4301-b25a-8577368b54f5
X-Archives-Hash: 2f57fee20ebe3c8e2edee0bc2a18da45

commit:     9e43d725ce4c2049e53e9df444b47c388bf98573
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 15 20:31:16 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 15 20:31:16 2023 +0000
URL:        https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=9e43d725

ProfilesCheck: check for unknown USE & IUSE_IMPLICIT in make.defaults

Related: https://github.com/pkgcore/pkgcheck/issues/524
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcheck/checks/profiles.py                                    | 7 +++++++
 .../repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json | 1 +
 .../repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch     | 4 +++-
 testdata/repos/profiledir/profiles/unknown_use/make.defaults       | 2 ++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/pkgcheck/checks/profiles.py b/src/pkgcheck/checks/profiles.py
index 00d7c069..6d113519 100644
--- a/src/pkgcheck/checks/profiles.py
+++ b/src/pkgcheck/checks/profiles.py
@@ -290,6 +290,13 @@ class ProfilesCheck(Check):
 
     @verify_files(("make.defaults", "make_defaults"))
     def _make_defaults(self, filename: str, node, vals: dict[str, str]):
+        if use_flags := {
+            use.removeprefix("-")
+            for use_group in ("USE", "IUSE_IMPLICIT")
+            for use in vals.get(use_group, "").split()
+        }:
+            if unknown := use_flags - self.available_iuse:
+                yield UnknownProfileUse(pjoin(node.name, filename), sorted(unknown))
         if defined := set(vals.get("USE_EXPAND", "").split()):
             if unknown := defined - self.use_expand_groups:
                 yield UnknownProfileUseExpand(pjoin(node.name, filename), sorted(unknown))

diff --git a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json
index 36f7f55c..b7b1c988 100644
--- a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json
+++ b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/expected.json
@@ -1,3 +1,4 @@
+{"__class__": "UnknownProfileUse", "path": "unknown_use/make.defaults", "flags": ["defaults_iuse_implicit", "defaults_use"]}
 {"__class__": "UnknownProfileUse", "path": "unknown_use/unknown_stable_use/use.force", "flags": ["-use_force"]}
 {"__class__": "UnknownProfileUse", "path": "unknown_use/unknown_stable_use/use.stable.force", "flags": ["use_stable_force"]}
 {"__class__": "UnknownProfileUse", "path": "unknown_use/unknown_stable_use_mask/use.mask", "flags": ["-use_mask"]}

diff --git a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch
index 1541f627..d4003eb4 100644
--- a/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch
+++ b/testdata/data/repos/profiledir/ProfilesCheck/UnknownProfileUse/fix.patch
@@ -1,9 +1,11 @@
 diff -Naur profiledir/profiles/use.desc fixed/profiles/use.desc
 --- profiledir/profiles/use.desc	2020-11-23 10:54:01.018477444 -0700
 +++ fixed/profiles/use.desc	2020-11-23 11:54:08.071178614 -0700
-@@ -1 +1,5 @@
+@@ -1 +1,7 @@
  used - used global flag
 +use_force - use.force
 +use_mask - use.mask
 +use_stable_force - use.stable.force
 +use_stable_mask - use.stable.mask
++defaults_use - make.defaults USE
++defaults_iuse_implicit - make.defaults IUSE_IMPLICIT

diff --git a/testdata/repos/profiledir/profiles/unknown_use/make.defaults b/testdata/repos/profiledir/profiles/unknown_use/make.defaults
new file mode 100644
index 00000000..4699667b
--- /dev/null
+++ b/testdata/repos/profiledir/profiles/unknown_use/make.defaults
@@ -0,0 +1,2 @@
+USE="defaults_use used"
+IUSE_IMPLICIT="defaults_iuse_implicit used"