1 |
commit: 197a876f4bd29f01732bc0657c9764c2e9d35fae |
2 |
Author: Sven Eden <yamakuzure <AT> gmx <DOT> net> |
3 |
AuthorDate: Tue Feb 25 18:00:58 2014 +0000 |
4 |
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de> |
5 |
CommitDate: Tue Feb 25 18:00:58 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=197a876f |
7 |
|
8 |
Portage.pm: Some comment cleanup and one minor bugfix. |
9 |
|
10 |
--- |
11 |
Portage.pm | 146 ++++++++++++++++++++++++++++++++----------------------------- |
12 |
1 file changed, 76 insertions(+), 70 deletions(-) |
13 |
|
14 |
diff --git a/Portage.pm b/Portage.pm |
15 |
index 5471e73..5d42860 100644 |
16 |
--- a/Portage.pm |
17 |
+++ b/Portage.pm |
18 |
@@ -1,6 +1,6 @@ |
19 |
package Portage; |
20 |
|
21 |
-# Copyright 1999-2013 Gentoo Foundation |
22 |
+# Copyright 1999-2014 Gentoo Foundation |
23 |
# Distributed under the terms of the GNU General Public License v2 |
24 |
# $Header: $ |
25 |
|
26 |
@@ -20,13 +20,20 @@ BEGIN { |
27 |
|
28 |
# Set this to 1 to get debugging output |
29 |
use constant { DEBUG => 0 }; |
30 |
+## Note: Although use constant is deprecated as of page 55 of PBP |
31 |
+# [ValuesAndExpressions::ProhibitConstantPragma] and should be replaced by |
32 |
+# ReadOnly, I do not see any gain in adding a dependency to dev-perl/Readonly |
33 |
+# just for one value that is used when debugging only. - sed |
34 |
+ |
35 |
|
36 |
# $use_flags - hashref that represents the combined and |
37 |
# consolidated data about all valid use flags |
38 |
# Layout of $use_flags->{flag_name}: |
39 |
# {count} = number of different description lines |
40 |
-# Note: +1 for the list of affected packages, and +1 for each descriptionless package with settings differing from global. |
41 |
-# {global} = hashref for the global paramters if the flag has a description in use.desc, otherwise undefined |
42 |
+# Note: +1 for the list of affected packages, and +1 for each descriptionless |
43 |
+# package with settings differing from global. |
44 |
+# {global} = hashref for the global paramters if the flag has a description in |
45 |
+# use.desc, otherwise undefined |
46 |
# ->{conf} = The flag is disabled (-1), enabled (1) or not set (0) in make.conf |
47 |
# ->{default} = The flag is disabled (-1), enabled (1) or not set (0) by default |
48 |
# ->{descr} = Global description |
49 |
@@ -34,16 +41,24 @@ use constant { DEBUG => 0 }; |
50 |
# ->{forced} = The flag is globally force enabled (and masked) (0,1) |
51 |
# ->{installed} = At least one affected package is installed (0,1) |
52 |
# ->{masked} = The flag is globally masked (0,1) |
53 |
-# Note: When a flag is forced, {masked} is set to one, but can be reset to 0 by any later use.mask file. |
54 |
+# Note: When a flag is forced, {masked} is set to one, but can be reset to |
55 |
+# 0 by any later use.mask file. |
56 |
# {"local"}->{package} = hashref for per package settings |
57 |
-# ->{descr} = Description from use.local.desc or empty if there is no individual description |
58 |
-# Note: Packages without description are only listed here if their settings differ from the global |
59 |
-# ->{forced} = The flag is explicitly unforced (-1), default (0) or explicitly force enabled (1) for this package |
60 |
+# ->{descr} = Description from use.local.desc or empty if there is no |
61 |
+# individual description. |
62 |
+# Note: Packages without description are only listed here if their settings |
63 |
+# differ from the global. |
64 |
+# ->{forced} = The flag is explicitly unforced (-1), default (0) or |
65 |
+# explicitly force enabled (1) for this package |
66 |
# ->{installed} = This package is installed |
67 |
-# ->{masked} = The flag is explicitly unmasked (-1), default (0) or masked (1) for this package |
68 |
-# ->{package} = The flag is explicitly disabled (-1), default (0) or enabled (1) for this package by (profiles)/package.use |
69 |
-# ->{pkguse} = The flag is explicitly disabled (-1), default (0) or enabled(1) for this package by /etc/portage/package.use |
70 |
-# Note: This is a combination of the ebuilds IUSE and the installation PKGUSE and only set for installed packages. |
71 |
+# ->{masked} = The flag is explicitly unmasked (-1), default (0) or |
72 |
+# masked (1) for this package |
73 |
+# ->{package} = The flag is explicitly disabled (-1), default (0) or |
74 |
+# enabled (1) for this package by (profiles)/package.use |
75 |
+# ->{pkguse} = The flag is explicitly disabled (-1), default (0) or |
76 |
+# enabled(1) for this package by /etc/portage/package.use |
77 |
+# Note: This is a combination of the ebuilds IUSE and the installation |
78 |
+# PKGUSE and only set for installed packages. |
79 |
our $use_flags; |
80 |
|
81 |
# $used_make_conf - path of the used make.conf |
82 |
@@ -64,23 +79,28 @@ my @_profiles = (); |
83 |
my %_use_eh_safe = (); ## USE_EXPAND_HIDDEN safe hash. See _read_make_defaults() |
84 |
my %_use_order = (); |
85 |
|
86 |
-# $_use_temp - hashref that represents the current state of |
87 |
-# all known flags. This is for data gathering, the public |
88 |
-# $use_flags is generated out of this by _gen_use_flags() |
89 |
+# $_use_temp - hashref that represents the current state of all known flags. |
90 |
+# This is for data gathering, the public $use_flags is generated out of this |
91 |
+# by _gen_use_flags(). |
92 |
# Layout of $_use_temp->{flag_name}: |
93 |
# {global} = conf hash for global settings |
94 |
# {"local"}-> {package} = conf hash for per package settings |
95 |
# global and per package settings: |
96 |
# ->{conf} Is either disabled, left alone or enabled by make.conf (-1, 0, 1) |
97 |
-# ->{default} Is either disabled, left alone or enabled by make.defaults (-1, 0, 1) (global) or installed packages IUSE (local) |
98 |
-# ->{descr} Description from use.desc ({global}) or use.local.desc {cat/pkg} (string) |
99 |
+# ->{default} Is either disabled, left alone or enabled by make.defaults |
100 |
+# (-1, 0, 1) (global) or installed packages IUSE (local) |
101 |
+# ->{descr} Description from use.desc ({global}) or use.local.desc {cat/pkg} |
102 |
# ->{forced} Is force enabled (implies {masked}=1) in any *use.force |
103 |
-# For packages this is only set to -1 (explicitly unforced) or +1 (explicitly forced). 0 means "left alone". |
104 |
-# ->{installed} Has one installed package ({global}) or is installed {cat/pkg} (0,1) |
105 |
+# For packages this is only set to -1 (explicitly unforced) or |
106 |
+# +1 (explicitly forced). 0 means "left alone". |
107 |
+# ->{installed} Has one installed package ({global}) or is installed {cat/pkg} |
108 |
# ->{masked} Is masked by any *use.mask (0,1) |
109 |
-# For packages this is only set to -1 (explicitly unmasked) or +1 (explicitly masked). 0 means "left alone". |
110 |
-# ->{package} Is either disabled, left alone or enabled by the profiles package.use files |
111 |
-# ->{pkguse} Is either disabled, left alone or enabled by the users package.use file |
112 |
+# For packages this is only set to -1 (explicitly unmasked) or +1 |
113 |
+# (explicitly masked). 0 means "left alone". |
114 |
+# ->{package} Is either disabled, left alone or enabled by the profiles |
115 |
+# package.use files |
116 |
+# ->{pkguse} Is either disabled, left alone or enabled by the users |
117 |
+# package.use file |
118 |
|
119 |
my $_use_temp = undef; |
120 |
my $_use_template = { |
121 |
@@ -391,9 +411,8 @@ sub _determine_profiles |
122 |
} |
123 |
|
124 |
|
125 |
-# This method does a final cleanup of $_use_temp |
126 |
-# Everything that is to be done _after_ all |
127 |
-# configs are parsed goes in here. |
128 |
+# This method does a final cleanup of $_use_temp. |
129 |
+# Everything that is to be done _after_ all configs are parsed goes in here. |
130 |
# No parameters accepted |
131 |
sub _final_cleaning |
132 |
{ |
133 |
@@ -423,14 +442,13 @@ sub _final_cleaning |
134 |
|
135 |
|
136 |
# This function fixes two aspects of the temporary flag hash: |
137 |
-# A) The {"default"} flag settings of packages might have to be |
138 |
-# overridden by the {"global"} ones. |
139 |
+# A) The {"default"} flag settings of packages might have to be overridden by |
140 |
+# the {"global"} ones. |
141 |
# (see USE_ORDER in man make.conf) |
142 |
-# B) All flags that are specific to explicit versioning have no |
143 |
-# descriptions yet. This must be enriched from the versionless |
144 |
-# package setting. |
145 |
-# C) Further flags that have no proper description get the |
146 |
-# string "(Unknown)" as a description |
147 |
+# B) All flags that are specific to explicit versioning have no descriptions |
148 |
+# yet. This must be enriched from the versionless package setting. |
149 |
+# C) Further flags that have no proper description get the string "(Unknown)" |
150 |
+# as a description |
151 |
sub _fix_flags |
152 |
{ |
153 |
for my $flag (keys %{$_use_temp}) { |
154 |
@@ -448,7 +466,7 @@ sub _fix_flags |
155 |
$gDefault = $globRef->{"default"}; |
156 |
} elsif ( $globRef->{conf} |
157 |
|| $globRef->{"default"} |
158 |
- || $globRef->{forcded} |
159 |
+ || $globRef->{forced} |
160 |
|| $globRef->{masked} ) { |
161 |
## The flag is definitely set somewhere |
162 |
$globRef->{descr} = $gDesc; |
163 |
@@ -486,9 +504,8 @@ sub _fix_flags |
164 |
} |
165 |
} ## End of looping packages |
166 |
|
167 |
- # Finally remove the global description if it is |
168 |
- # (Unknown) with at least one local representation |
169 |
- # present. |
170 |
+ # Finally remove the global description if it is (Unknown) with at |
171 |
+ # least one local representation present. |
172 |
if ($hasLocal && ("(Unknown)" eq $gDesc)) { |
173 |
$globRef->{descr} = ""; |
174 |
} |
175 |
@@ -498,8 +515,7 @@ sub _fix_flags |
176 |
} |
177 |
|
178 |
|
179 |
-# Once $_use_temp is ready, this method builds |
180 |
-# the final $use_flags hashref. |
181 |
+# Once $_use_temp is ready, this method builds the final $use_flags hashref. |
182 |
# No parameters accepted |
183 |
sub _gen_use_flags |
184 |
{ |
185 |
@@ -721,8 +737,8 @@ sub _norm_path { |
186 |
} |
187 |
|
188 |
|
189 |
-# reads all found arch.list and erase all found archs |
190 |
-# from $_use_temp. Archs are not setable. |
191 |
+# reads all found arch.list and erase all found archs from $_use_temp. Archs |
192 |
+# are not setable. |
193 |
# No parameters accepted |
194 |
sub _read_archs { |
195 |
for my $dir(@_profiles) { |
196 |
@@ -736,8 +752,7 @@ sub _read_archs { |
197 |
} |
198 |
|
199 |
|
200 |
-# reads all use.desc and use.local.desc and updates |
201 |
-# $_use_temp accordingly. |
202 |
+# reads all use.desc and use.local.desc and updates $_use_temp accordingly. |
203 |
# No parameters accepted |
204 |
sub _read_descriptions |
205 |
{ |
206 |
@@ -768,17 +783,13 @@ sub _read_descriptions |
207 |
} |
208 |
|
209 |
|
210 |
-# read make.conf and record the state of all set use |
211 |
-# flags. |
212 |
-# Additionally add all set portage directories (plus |
213 |
-# overlays) to @_profiles. |
214 |
-# The last added profile directory, if it exists, is |
215 |
-# /etc/portage/profile to allow recognition of user |
216 |
-# overrides. |
217 |
-# If either of the make.conf paths is a directory, all |
218 |
-# files are read in alphanumerical order. The file |
219 |
-# changes are written to will be the last file that |
220 |
-# contains a USE assignement. |
221 |
+# read make.conf and record the state of all set use flags. |
222 |
+# Additionally add all set portage directories (plus overlays) to @_profiles. |
223 |
+# The last added profile directory, if it exists, is /etc/portage/profile to |
224 |
+# allow recognition of user overrides. |
225 |
+# If either of the make.conf paths is a directory, all files are read in |
226 |
+# alphanumerical order. The file changes are written to will be the last file |
227 |
+# that contains a USE assignement. |
228 |
# No parameters accepted. |
229 |
sub _read_make_conf { |
230 |
my ($stOldPath, $stNewPath) = ( "${_EPREFIX}/etc/make.conf", |
231 |
@@ -876,9 +887,8 @@ sub _read_make_defaults { |
232 |
} |
233 |
|
234 |
|
235 |
-# read all found make.globals and merge their |
236 |
-# settings into %environment. This is done to |
237 |
-# get the final "PORTDIR" and "USE_ORDER" |
238 |
+# read all found make.globals and merge their settings into %environment. This |
239 |
+# is done to get the final "PORTDIR" and "USE_ORDER" |
240 |
# No parameters accepted |
241 |
sub _read_make_globals { |
242 |
for my $dir(@_profiles, "${_EPREFIX}/usr/share/portage/config") { |
243 |
@@ -888,8 +898,8 @@ sub _read_make_globals { |
244 |
} |
245 |
|
246 |
|
247 |
-# read all found package.use files and merge their values into |
248 |
-# env, adding flag parameters to $_use_tmp. |
249 |
+# read all found package.use files and merge their values into env, adding flag |
250 |
+# parameters to $_use_tmp. |
251 |
# No parameters accepted. |
252 |
sub _read_package_use |
253 |
{ |
254 |
@@ -917,10 +927,9 @@ sub _read_package_use |
255 |
} |
256 |
|
257 |
|
258 |
-# Analyze EPREFIX/var/db/pkg and analyze all installed |
259 |
-# packages. The contents of the file IUSE are used to |
260 |
-# enrich the information of the {default} part and to |
261 |
-# determine which packages are installed. |
262 |
+# Analyze EPREFIX/var/db/pkg and analyze all installed packages. The contents |
263 |
+# of the file IUSE are used to enrich the information of the {default} part and |
264 |
+# to determine which packages are installed. |
265 |
sub _read_packages { |
266 |
my $pkgdir = undef; |
267 |
opendir($pkgdir, "${_EPREFIX}/var/db/pkg") |
268 |
@@ -972,9 +981,8 @@ sub _read_packages { |
269 |
|
270 |
|
271 |
# reads the given file and parses it for key=value pairs. |
272 |
-# "source" entries are added to the file and parsed as |
273 |
-# well. The results of the parsing are merged into |
274 |
-# %environment. |
275 |
+# "source" entries are added to the file and parsed as well. The results of the |
276 |
+# parsing are merged into %environment. |
277 |
# Parameter 1: The path of the file to parse. |
278 |
# In a non-scalar context the function returns the found values. |
279 |
sub _read_sh { |
280 |
@@ -1060,9 +1068,8 @@ sub _read_sh { |
281 |
} |
282 |
|
283 |
|
284 |
-# read all enforced flags from all found use.force |
285 |
-# and package.use.force files. Save the found |
286 |
-# masks in %use_flags. |
287 |
+# read all enforced flags from all found use.force and package.use.force files. |
288 |
+# Save the found masks in %use_flags. |
289 |
# No parameters accepted. |
290 |
sub _read_use_force { |
291 |
for my $dir(@_profiles) { |
292 |
@@ -1103,9 +1110,8 @@ sub _read_use_force { |
293 |
} |
294 |
|
295 |
|
296 |
-# read all masked flags from all found use.mask |
297 |
-# and package.use.mask files. Save the found |
298 |
-# masks in %use_flags. |
299 |
+# read all masked flags from all found use.mask and package.use.mask files. |
300 |
+# Save the found masks in %use_flags. |
301 |
# No parameters accepted. |
302 |
sub _read_use_mask { |
303 |
for my $dir(@_profiles) { |