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