Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/checks/ebuilds/variables/, pym/repoman/
Date: Mon, 21 Sep 2015 23:51:36
Message-Id: 1442878964.f1407272871994cd83a18398b566566a61d4f9d0.dolsen@gentoo
1 commit: f1407272871994cd83a18398b566566a61d4f9d0
2 Author: Tom Wijsman <tomwij <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 6 15:09:43 2014 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Mon Sep 21 23:42:44 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=f1407272
7
8 repoman/main.py: Split LICENSE checks to checks/ebuild/variables/
9
10 pym/repoman/checks/ebuilds/variables/license.py | 47 +++++++++++++++++++++++++
11 pym/repoman/main.py | 21 +++--------
12 2 files changed, 52 insertions(+), 16 deletions(-)
13
14 diff --git a/pym/repoman/checks/ebuilds/variables/license.py b/pym/repoman/checks/ebuilds/variables/license.py
15 new file mode 100644
16 index 0000000..bdc859c
17 --- /dev/null
18 +++ b/pym/repoman/checks/ebuilds/variables/license.py
19 @@ -0,0 +1,47 @@
20 +
21 +'''description.py
22 +Perform checks on the LICENSE variable.
23 +'''
24 +
25 +# import our initialized portage instance
26 +from repoman._portage import portage
27 +
28 +
29 +class LicenseChecks(object):
30 + '''Perform checks on the LICENSE variable.'''
31 +
32 + def __init__(self, qatracker, liclist, liclist_deprecated):
33 + '''
34 + @param qatracker: QATracker instance
35 + @param liclist: List of licenses.
36 + @param liclist: List of deprecated licenses.
37 + '''
38 + self.qatracker = qatracker
39 + self.liclist = liclist
40 + self.liclist_deprecated = liclist_deprecated
41 +
42 + def check(
43 + self, pkg, package, ebuild, y_ebuild):
44 + '''
45 + @param pkg: Package in which we check (object).
46 + @param package: Package in which we check (string).
47 + @param ebuild: Ebuild which we check (object).
48 + @param y_ebuild: Ebuild which we check (string).
49 + '''
50 +
51 + # Parse the LICENSE variable, remove USE conditions and flatten it.
52 + licenses = portage.dep.use_reduce(
53 + pkg._metadata["LICENSE"], matchall=1, flat=True)
54 +
55 + # Check each entry to ensure that it exists in ${PORTDIR}/licenses/.
56 + for lic in licenses:
57 + # Need to check for "||" manually as no portage
58 + # function will remove it without removing values.
59 + if lic not in self.liclist and lic != "||":
60 + self.qatracker.add_error(
61 + "LICENSE.invalid",
62 + package + "/" + y_ebuild + ".ebuild: %s" % lic)
63 + elif lic in self.liclist_deprecated:
64 + self.qatracker.add_error(
65 + "LICENSE.deprecated",
66 + "%s: %s" % (ebuild.relative_path, lic))
67
68 diff --git a/pym/repoman/main.py b/pym/repoman/main.py
69 index 7b36852..08d79eb 100755
70 --- a/pym/repoman/main.py
71 +++ b/pym/repoman/main.py
72 @@ -63,6 +63,7 @@ from repoman.checks.ebuilds.pkgmetadata import PkgMetadata
73 from repoman.checks.ebuilds.use_flags import USEFlagChecks
74 from repoman.checks.ebuilds.variables.description import DescriptionChecks
75 from repoman.checks.ebuilds.variables.eapi import EAPIChecks
76 +from repoman.checks.ebuilds.variables.license import LicenseChecks
77 from repoman.ebuild import Ebuild
78 from repoman.errors import err
79 from repoman.modules.commit import repochecks
80 @@ -299,6 +300,7 @@ liveeclasscheck = LiveEclassChecks(qatracker)
81 rubyeclasscheck = RubyEclassChecks(qatracker)
82 eapicheck = EAPIChecks(qatracker, repo_settings)
83 descriptioncheck = DescriptionChecks(qatracker)
84 +licensecheck = LicenseChecks(qatracker, liclist, liclist_deprecated)
85 ######################
86
87 for xpkg in effective_scanlist:
88 @@ -617,22 +619,9 @@ for xpkg in effective_scanlist:
89
90 # license checks
91 if not badlicsyntax:
92 - # Parse the LICENSE variable, remove USE conditions and
93 - # flatten it.
94 - licenses = portage.dep.use_reduce(myaux["LICENSE"], matchall=1, flat=True)
95 - # Check each entry to ensure that it exists in PORTDIR's
96 - # license directory.
97 - for lic in licenses:
98 - # Need to check for "||" manually as no portage
99 - # function will remove it without removing values.
100 - if lic not in liclist and lic != "||":
101 - qatracker.add_error(
102 - "LICENSE.invalid",
103 - xpkg + "/" + y_ebuild + ".ebuild: %s" % lic)
104 - elif lic in liclist_deprecated:
105 - qatracker.add_error(
106 - "LICENSE.deprecated",
107 - "%s: %s" % (ebuild.relative_path, lic))
108 + #################
109 + licensecheck.check(pkg, xpkg, ebuild, y_ebuild)
110 + #################
111
112 # restrict checks
113 myrestrict = None