Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13670 - main/trunk/pym/portage
Date: Mon, 22 Jun 2009 21:31:47
Message-Id: E1MIr7B-0000VI-EP@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-06-22 21:31:44 +0000 (Mon, 22 Jun 2009)
3 New Revision: 13670
4
5 Modified:
6 main/trunk/pym/portage/__init__.py
7 main/trunk/pym/portage/const.py
8 Log:
9 Change ACCEPT_LICENSE evaluation so that things like ACCEPT_LICENSE="* -@EULA"
10 will work as expected. The ACCEPT_LICENSE variable is now treated as a lazily
11 evaluated incremental, so that * can be used to match all licenses without
12 every having to explicitly expand it to all licenses. It should now behave
13 as approved by the council in response to the "RFC: ACCEPT_LICENSE default
14 value (GLEP 23)" discussion:
15
16 http://archives.gentoo.org/gentoo-dev/msg_d5c1e7285399ebc27a74bdd02cb4d037.xml
17
18
19 Modified: main/trunk/pym/portage/__init__.py
20 ===================================================================
21 --- main/trunk/pym/portage/__init__.py 2009-06-22 20:02:48 UTC (rev 13669)
22 +++ main/trunk/pym/portage/__init__.py 2009-06-22 21:31:44 UTC (rev 13670)
23 @@ -1201,6 +1201,7 @@
24 self.modifiedkeys = []
25 self.uvlist = []
26 self._accept_chost_re = None
27 + self._accept_license = None
28
29 self.virtuals = {}
30 self.virts_p = {}
31 @@ -1818,18 +1819,6 @@
32 self["PORTAGE_PYM_PATH"] = PORTAGE_PYM_PATH
33 self.backup_changes("PORTAGE_PYM_PATH")
34
35 - # Expand license groups
36 - # This has to do be done for each config layer before regenerate()
37 - # in order for incremental negation to work properly.
38 - if local_config:
39 - for c in self.configdict.itervalues():
40 - v = c.get("ACCEPT_LICENSE")
41 - if not v:
42 - continue
43 - v = " ".join(self.expandLicenseTokens(v.split()))
44 - c["ACCEPT_LICENSE"] = v
45 - del c, v
46 -
47 for var in ("PORTAGE_INST_UID", "PORTAGE_INST_GID"):
48 try:
49 self[var] = str(int(self.get(var, "0")))
50 @@ -1843,20 +1832,6 @@
51 # initialize self.features
52 self.regenerate()
53
54 - if local_config:
55 - self._accept_license = \
56 - set(self.get("ACCEPT_LICENSE", "").split())
57 - # In order to enforce explicit acceptance for restrictive
58 - # licenses that require it, "*" will not be allowed in the
59 - # user config. Don't enforce this until license groups are
60 - # fully implemented in the tree.
61 - #self._accept_license.discard("*")
62 - if not self._accept_license:
63 - self._accept_license = set(["*"])
64 - else:
65 - # repoman will accept any license
66 - self._accept_license = set(["*"])
67 -
68 if not portage.process.sandbox_capable and \
69 ("sandbox" in self.features or "usersandbox" in self.features):
70 if self.profile_path is not None and \
71 @@ -2113,10 +2088,19 @@
72 except exception.InvalidDependString:
73 licenses = set()
74 licenses.discard('||')
75 - # Do not expand * here, since that would make it appear to the
76 - # check_license() function as if the user has accepted licenses
77 - # which have not really been explicitly accepted.
78 - licenses.intersection_update(settings._accept_license)
79 + if settings._accept_license:
80 + acceptable_licenses = set()
81 + for x in settings._accept_license:
82 + if x == '*':
83 + acceptable_licenses.update(licenses)
84 + elif x == '-*':
85 + acceptable_licenses.clear()
86 + elif x[:1] == '-':
87 + acceptable_licenses.discard(x[1:])
88 + else:
89 + acceptable_licenses.add(x)
90 +
91 + licenses = acceptable_licenses
92 return ' '.join(sorted(licenses))
93
94 def _restrict(self, use, settings):
95 @@ -2676,16 +2660,31 @@
96 @rtype: List
97 @return: A list of licenses that have not been accepted.
98 """
99 - if "*" in self._accept_license:
100 + if not self._accept_license:
101 return []
102 - acceptable_licenses = self._accept_license
103 + accept_license = self._accept_license
104 cpdict = self._plicensedict.get(dep_getkey(cpv), None)
105 if cpdict:
106 - acceptable_licenses = self._accept_license.copy()
107 + accept_license = list(self._accept_license)
108 cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
109 for atom in match_to_list(cpv_slot, cpdict.keys()):
110 - acceptable_licenses.update(cpdict[atom])
111 + accept_license.extend(cpdict[atom])
112
113 + licenses = set(flatten(dep.use_reduce(dep.paren_reduce(
114 + metadata["LICENSE"]), matchall=1)))
115 + licenses.discard('||')
116 +
117 + acceptable_licenses = set()
118 + for x in accept_license:
119 + if x == '*':
120 + acceptable_licenses.update(licenses)
121 + elif x == '-*':
122 + acceptable_licenses.clear()
123 + elif x[:1] == '-':
124 + acceptable_licenses.discard(x[1:])
125 + else:
126 + acceptable_licenses.add(x)
127 +
128 license_str = metadata["LICENSE"]
129 if "?" in license_str:
130 use = metadata["USE"].split()
131 @@ -2854,11 +2853,27 @@
132 # an incremental!
133 myincrementals.remove("USE")
134
135 +
136 + mydbs = self.configlist[:-1]
137 + mydbs.append(self.backupenv)
138 +
139 + # ACCEPT_LICENSE is a lazily evaluated incremental, so that * can be
140 + # used to match all licenses without every having to explicitly expand
141 + # it to all licenses.
142 + if self._accept_license is None:
143 + if self.local_config:
144 + mysplit = []
145 + for curdb in mydbs:
146 + mysplit.extend(curdb.get('ACCEPT_LICENSE', '').split())
147 + if mysplit:
148 + self.configlist[-1]['ACCEPT_LICENSE'] = ' '.join(mysplit)
149 + self._accept_license = tuple(self.expandLicenseTokens(mysplit))
150 + else:
151 + # repoman will accept any license
152 + self._accept_license = ()
153 +
154 for mykey in myincrementals:
155
156 - mydbs=self.configlist[:-1]
157 - mydbs.append(self.backupenv)
158 -
159 myflags=[]
160 for curdb in mydbs:
161 if mykey not in curdb:
162
163 Modified: main/trunk/pym/portage/const.py
164 ===================================================================
165 --- main/trunk/pym/portage/const.py 2009-06-22 20:02:48 UTC (rev 13669)
166 +++ main/trunk/pym/portage/const.py 2009-06-22 21:31:44 UTC (rev 13670)
167 @@ -52,7 +52,7 @@
168 REPO_NAME_LOC = "profiles" + "/" + REPO_NAME_FILE
169
170 INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES",
171 - "ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
172 + "ACCEPT_KEYWORDS",
173 "CONFIG_PROTECT_MASK", "CONFIG_PROTECT",
174 "PRELINK_PATH", "PRELINK_PATH_MASK", "PROFILE_ONLY_VARIABLES"]
175 EBUILD_PHASES = ["setup", "unpack", "prepare", "configure",