--- a/Portage.pm 2013-09-11 08:34:10.792161194 +0200 +++ b/Portage.pm 2013-09-11 09:00:45.737142232 +0200 @@ -46,11 +46,13 @@ our $used_make_conf = ""; # --- private members --- -my %_environment = (); -my $_EPREFIX = ""; -my @_profiles = (); -my %_use_eh_safe = (); ## USE_EXPAND_HIDDEN safe hash. See _read_make_defaults() -my %_use_order = (); +my %_environment = (); +my $_EPREFIX = ""; +my $_PORTDIR = ""; +my $_PORTDIR_OVERLAY = ""; +my @_profiles = (); +my %_use_eh_safe = (); ## USE_EXPAND_HIDDEN safe hash. See _read_make_defaults() +my %_use_order = (); # $_use_temp - hashref that represents the current state of # all known flags. This is for data gathering, the public @@ -87,7 +89,7 @@ # --- private methods --- sub _add_flag; sub _add_temp; -sub _determine_eprefix; +sub _determine_eprefix_portdir; sub _determine_make_conf; sub _determine_profiles; sub _final_cleaning; @@ -112,7 +114,7 @@ # --- Package initialization --- INIT { $_environment{$_} = {} for qw{USE USE_EXPAND USE_EXPAND_HIDDEN}; - _determine_eprefix; + _determine_eprefix_portdir; _determine_make_conf; _determine_profiles; _read_make_globals; @@ -223,14 +225,29 @@ } -# Determine the value for EPREFIX and save it -# in $_EPREFIX. This is done using 'portageq'. +# Determine the values for EPREFIX, PORTDIR +# and PORTDIR_OVERLAY. These are saved in +# $_EPREFIX, $_PORTDIR and $_PORTDIR_OVERLAY. +# This is done using 'portageq'. # Other output from portageq is printed on # STDERR. # No parameters accepted. -sub _determine_eprefix { +sub _determine_eprefix_portdir { my $tmp = "/tmp/ufed_$$.tmp"; - $_EPREFIX = qx{portageq envvar EPREFIX 2>$tmp}; + my @res = map { + my $x = $_; + chomp $x; + $x =~ s/'//g; + $x + } qx{portageq envvar -v EPREFIX PORTDIR PORTDIR_OVERLAY 2>$tmp}; + + while (my $res = shift @res) { + if ($res =~ /^(.*)=(.*)$/) { + "EPREFIX" eq $1 and $_EPREFIX = $2; + "PORTDIR" eq $1 and $_PORTDIR = $2; + "PORTDIR_OVERLAY" eq $1 and $_PORTDIR_OVERLAY = $2; + } + } die "Couldn't determine EPREFIX from Portage" if $? != 0; if ( -s $tmp ) { @@ -241,7 +258,6 @@ } -e $tmp and unlink $tmp; - chomp($_EPREFIX); return; } @@ -631,13 +647,11 @@ } # Add PORTDIR and overlays to @_profiles - defined ($_environment{PORTDIR}) - and push @_profiles, "$_environment{PORTDIR}/profiles" + length ($_PORTDIR) + and push @_profiles, "${_PORTDIR}/profiles" or die("Unable to determine PORTDIR!\nSomething is seriously broken here!\n"); - defined ($_environment{PORTDIR_OVERLAY}) - and push @_profiles, - map { my $x=$_; $x =~ s/^\s*(\S+)\s*$/$1\/profiles/mg ; $x } - split('\n', $_environment{PORTDIR_OVERLAY}); + length ($_PORTDIR_OVERLAY) + and push @_profiles, split(' ', $_PORTDIR_OVERLAY); -e "${_EPREFIX}/etc/portage/profile" and push @_profiles, "${_EPREFIX}/etc/portage/profile"; return;