diff options
author | Louis Sautier <sautier.louis@gmail.com> | 2018-06-20 15:44:51 +0200 |
---|---|---|
committer | Brian Dolbec <dolsen@gentoo.org> | 2018-07-14 08:44:08 -0700 |
commit | f4faf6d7950150a3068f92a3f3615b884db897d6 (patch) | |
tree | 569ebe0fae5da6116bc77dc79ed442449492a7c3 /repoman | |
parent | repoman: Warn on = dependencies without * or revision (diff) | |
download | portage-f4faf6d7950150a3068f92a3f3615b884db897d6.tar.gz portage-f4faf6d7950150a3068f92a3f3615b884db897d6.tar.bz2 portage-f4faf6d7950150a3068f92a3f3615b884db897d6.zip |
repoman: add a check for unsorted KEYWORDS
Diffstat (limited to 'repoman')
-rw-r--r-- | repoman/cnf/qa_data/qa_data.yaml | 1 | ||||
-rw-r--r-- | repoman/cnf/repository/qa_data.yaml | 1 | ||||
-rw-r--r-- | repoman/man/repoman.1 | 3 | ||||
-rw-r--r-- | repoman/pym/repoman/modules/scan/keywords/keywords.py | 21 |
4 files changed, 26 insertions, 0 deletions
diff --git a/repoman/cnf/qa_data/qa_data.yaml b/repoman/cnf/qa_data/qa_data.yaml index 49ffdaf74..6aad56b8c 100644 --- a/repoman/cnf/qa_data/qa_data.yaml +++ b/repoman/cnf/qa_data/qa_data.yaml @@ -83,6 +83,7 @@ qahelp: missing: "Ebuilds that have a missing or empty KEYWORDS variable" stable: "Ebuilds that have been added directly with stable KEYWORDS" stupid: "Ebuilds that use KEYWORDS=-* instead of package.mask" + unsorted: "Ebuilds that contain KEYWORDS which are not sorted alphabetically." LICENSE: deprecated: "This ebuild is listing a deprecated license." invalid: "This ebuild is listing a license that doesnt exist in portages license/ dir." diff --git a/repoman/cnf/repository/qa_data.yaml b/repoman/cnf/repository/qa_data.yaml index 2e9e16b1d..c96ce46a9 100644 --- a/repoman/cnf/repository/qa_data.yaml +++ b/repoman/cnf/repository/qa_data.yaml @@ -67,6 +67,7 @@ qawarnings: - KEYWORDS.dropped - KEYWORDS.stupid - KEYWORDS.missing + - KEYWORDS.unsorted - LICENSE.deprecated - LICENSE.virtual - metadata.warning diff --git a/repoman/man/repoman.1 b/repoman/man/repoman.1 index 01f37dd99..dea17c3b4 100644 --- a/repoman/man/repoman.1 +++ b/repoman/man/repoman.1 @@ -228,6 +228,9 @@ Ebuilds that have been added directly with stable KEYWORDS .B KEYWORDS.stupid Ebuilds that use KEYWORDS=-* instead of package.mask .TP +.B KEYWORDS.unsorted +Ebuilds that contain KEYWORDS which are not sorted alphabetically. +.TP .B LICENSE.deprecated This ebuild is listing a deprecated license. .TP diff --git a/repoman/pym/repoman/modules/scan/keywords/keywords.py b/repoman/pym/repoman/modules/scan/keywords/keywords.py index 1e9623906..556f352ad 100644 --- a/repoman/pym/repoman/modules/scan/keywords/keywords.py +++ b/repoman/pym/repoman/modules/scan/keywords/keywords.py @@ -55,6 +55,8 @@ class KeywordChecks(ScanBase): self._checkForMaskLikeKeywords(xpkg, y_ebuild, ebuild.keywords) + self._checkForUnsortedKeywords(ebuild, xpkg, y_ebuild) + self.slot_keywords[pkg.slot].update(ebuild.archs) return False @@ -133,6 +135,25 @@ class KeywordChecks(ScanBase): self.qatracker.add_error("KEYWORDS.stupid", "%s/%s.ebuild" % (xpkg, y_ebuild)) + def _checkForUnsortedKeywords(self, ebuild, xpkg, y_ebuild): + '''Ebuilds that contain KEYWORDS + which are not sorted alphabetically.''' + def sort_keywords(kw): + # Split keywords containing hyphens. The part after + # the hyphen should be treated as the primary key. + # This is consistent with ekeyword. + parts = list(reversed(kw.lstrip("~-").split("-", 1))) + # Hack to make sure that keywords + # without hyphens are sorted first + if len(parts) == 1: + parts.insert(0, "") + return parts + sorted_keywords = sorted(ebuild.keywords, key=sort_keywords) + if sorted_keywords != ebuild.keywords: + self.qatracker.add_error("KEYWORDS.unsorted", + "%s/%s.ebuild contains unsorted keywords" % + (xpkg, y_ebuild)) + @property def runInPkgs(self): '''Package level scans''' |