Lines 4-13
Link Here
|
4 |
# Distributed under the terms of the GNU General Public License v2 |
4 |
# Distributed under the terms of the GNU General Public License v2 |
5 |
# $Header: /var/cvsroot/gentoo-src/ufed/Portage.pm,v 1.3 2005/11/13 00:28:17 truedfx Exp $ |
5 |
# $Header: /var/cvsroot/gentoo-src/ufed/Portage.pm,v 1.3 2005/11/13 00:28:17 truedfx Exp $ |
6 |
|
6 |
|
|
|
7 |
use strict; |
8 |
use warnings; |
9 |
|
7 |
my %environment; |
10 |
my %environment; |
8 |
$environment{$_}={} for qw(USE); # INCREMENTALS, except we only need USE |
11 |
$environment{$_}={} for qw(USE); # INCREMENTALS, except we only need USE |
9 |
|
12 |
|
10 |
our %packages; |
13 |
our %packages; |
|
|
14 |
our @portagedirs; |
11 |
our @profiles; |
15 |
our @profiles; |
12 |
our %use_masked_flags; |
16 |
our %use_masked_flags; |
13 |
our %use_defaults_flags; |
17 |
our %use_defaults_flags; |
Lines 16-23
Link Here
|
16 |
our %make_conf_flags; |
20 |
our %make_conf_flags; |
17 |
our %archs; |
21 |
our %archs; |
18 |
our %all_flags; |
22 |
our %all_flags; |
|
|
23 |
our $make_conf_path; |
19 |
|
24 |
|
20 |
sub have_package($); |
25 |
sub have_package($); |
|
|
26 |
sub follow_link($); |
21 |
sub merge(\%%); |
27 |
sub merge(\%%); |
22 |
sub merge_env(\%); |
28 |
sub merge_env(\%); |
23 |
sub noncomments($); |
29 |
sub noncomments($); |
Lines 42-47
Link Here
|
42 |
read_archs; |
48 |
read_archs; |
43 |
|
49 |
|
44 |
my $lastorder; |
50 |
my $lastorder; |
|
|
51 |
|
45 |
for(reverse split /:/, $environment{USE_ORDER} || "env:pkg:conf:auto:defaults") { |
52 |
for(reverse split /:/, $environment{USE_ORDER} || "env:pkg:conf:auto:defaults") { |
46 |
if($_ eq 'defaults') { |
53 |
if($_ eq 'defaults') { |
47 |
merge %default_flags, %make_defaults_flags; |
54 |
merge %default_flags, %make_defaults_flags; |
Lines 60-70
Link Here
|
60 |
die "Sorry, USE_ORDER without make.conf overriding global USE flags are not currently supported by ufed.\n"; |
67 |
die "Sorry, USE_ORDER without make.conf overriding global USE flags are not currently supported by ufed.\n"; |
61 |
} |
68 |
} |
62 |
|
69 |
|
|
|
70 |
sub follow_link($) { |
71 |
my ($xPath) = @_; |
72 |
$xPath = (map {my $x=$_;$x=~ s,/[^/]*$,/,;$x} ($xPath))[0].readlink($xPath) |
73 |
while ( defined($xPath) && (-l $xPath)); |
74 |
return (defined($xPath) ? norm_path('', $xPath) : $xPath); |
75 |
} |
76 |
|
63 |
sub have_package($) { |
77 |
sub have_package($) { |
64 |
my ($cp) = @_; |
78 |
my ($cp) = @_; |
65 |
return $packages{$cp}; |
79 |
return $packages{$cp}; |
66 |
} |
80 |
} |
67 |
|
81 |
|
|
|
82 |
|
68 |
sub merge(\%%) { |
83 |
sub merge(\%%) { |
69 |
my ($env, %env) = @_; |
84 |
my ($env, %env) = @_; |
70 |
%{$env} = () if(exists $env{'*'}); |
85 |
%{$env} = () if(exists $env{'*'}); |
Lines 136-144
Link Here
|
136 |
} |
151 |
} |
137 |
|
152 |
|
138 |
sub read_make_conf() { |
153 |
sub read_make_conf() { |
139 |
my %env = read_sh "/etc/make.conf"; |
154 |
my $mcFile = "/etc/make.conf"; |
140 |
merge %make_conf_flags, %{$env{USE}} if exists $env{USE}; |
155 |
my $mcPath = follow_link $mcFile; |
141 |
@portagedirs = $environment{PORTDIR}; |
156 |
my %env = (); |
|
|
157 |
|
158 |
# 1. There is no known valid path, yet |
159 |
$make_conf_path = ""; |
160 |
|
161 |
# 2. Read the old path if it is not a symlink to the new path |
162 |
if ( defined($mcPath) && ( -e $mcPath ) && ("/etc/portage/make.conf" ne $mcPath) ) { |
163 |
%env = read_sh $mcPath; |
164 |
merge %make_conf_flags, %{$env{USE}} if exists $env{USE}; |
165 |
%env = (); |
166 |
## Store this path as being valid for now |
167 |
$make_conf_path = $mcPath; |
168 |
} |
169 |
|
170 |
# 3. Now switch to the new location - it must not be a symlink to the old either |
171 |
$mcFile = "/etc/portage/make.conf"; |
172 |
$mcPath = follow_link $mcFile; |
173 |
if ( defined($mcPath) && (-e $mcPath ) && ("/etc/make.conf" ne $mcPath) ) { |
174 |
%env = read_sh $mcPath; |
175 |
merge %make_conf_flags, %{$env{USE}} if exists $env{USE}; |
176 |
|
177 |
# Overwrite the old path, as the new location is the overriding one. |
178 |
$make_conf_path = $mcPath; |
179 |
} |
180 |
|
181 |
die ("Path to make.conf could not be determined!") unless (length($make_conf_path)); |
182 |
|
183 |
@portagedirs = $environment{PORTDIR} || ( "/usr/portage" ); ## PORTDIR is not necassarily set by make.conf |
142 |
push @portagedirs, split ' ', $environment{PORTDIR_OVERLAY} if defined $environment{PORTDIR_OVERLAY}; |
184 |
push @portagedirs, split ' ', $environment{PORTDIR_OVERLAY} if defined $environment{PORTDIR_OVERLAY}; |
143 |
} |
185 |
} |
144 |
|
186 |
|
Lines 204-212
Link Here
|
204 |
} |
246 |
} |
205 |
|
247 |
|
206 |
sub read_profiles() { |
248 |
sub read_profiles() { |
207 |
$_ = readlink '/etc/make.profile'; |
249 |
my $mpFileOld = follow_link(-l "/etc/make.profile" ? "/etc/make.profile" : undef); |
208 |
die "/etc/make.profile is not a symlink\n" if not defined $_; |
250 |
my $mpFileNew = follow_link(-l "/etc/portage/make.profile" ? "/etc/portage/make.profile" : undef); |
209 |
@profiles = norm_path '/etc', $_; |
251 |
|
|
|
252 |
die "make.profile can not be found!\n" unless (defined($mpFileOld) || defined($mpFileNew)); |
253 |
|
254 |
@profiles = defined($mpFileNew) ? $mpFileNew : $mpFileOld; |
210 |
for (my $i = -1; $i >= -@profiles; $i--) { |
255 |
for (my $i = -1; $i >= -@profiles; $i--) { |
211 |
for(noncomments "$profiles[$i]/parent") { |
256 |
for(noncomments "$profiles[$i]/parent") { |
212 |
splice @profiles, $i, 0, norm_path $profiles[$i], $_; |
257 |
splice @profiles, $i, 0, norm_path $profiles[$i], $_; |
Lines 224-236
Link Here
|
224 |
my $DQVAL = qr{"((?:[^\\"]|\\.)*)"}s; # doublequoted value |
269 |
my $DQVAL = qr{"((?:[^\\"]|\\.)*)"}s; # doublequoted value |
225 |
|
270 |
|
226 |
my ($fname) = @_; |
271 |
my ($fname) = @_; |
|
|
272 |
|
273 |
# If the file is empty, return quietly |
274 |
return unless (-s $fname); |
275 |
|
227 |
my %env; |
276 |
my %env; |
228 |
if(open my $file, '<', $fname) { |
277 |
if(open my $file, '<', $fname) { |
229 |
{ local $/; $_ = <$file> } |
278 |
{ local $/; $_ = <$file> } |
230 |
eval { |
279 |
eval { |
231 |
for(;;) { |
280 |
for(;;) { |
232 |
/\G$BLANK/gc; |
281 |
/\G$BLANK/gc; |
233 |
last if pos == length; |
282 |
last if (pos || -1) == length; |
234 |
/\G$IDENT/gc or die; |
283 |
/\G$IDENT/gc or die; |
235 |
my $name = $1; |
284 |
my $name = $1; |
236 |
/\G$BLANK/gc; |
285 |
/\G$BLANK/gc; |