--- Portage.pm +++ Portage.pm @@ -27,6 +27,7 @@ sub read_make_defaults(); sub read_make_globals(); sub read_packages(); +sub read_parents_pushing($$); sub read_profiles(); sub read_sh($); sub read_use_defaults(); @@ -203,16 +204,20 @@ closedir $pkgdir; } +sub read_parents_pushing($$) { + my ($dirname, $count) = @_; + die "Too many parents in profile.\n" unless $count; + for(noncomments "$dirname/parent") { + read_parents_pushing norm_path($dirname, $_), $count - 1; + } + push @profiles, $dirname; +} + sub read_profiles() { $_ = readlink '/etc/make.profile'; die "/etc/make.profile is not a symlink\n" if not defined $_; - @profiles = norm_path '/etc', $_; - PARENT: { - for(noncomments "$profiles[0]/parent") { - unshift @profiles, norm_path $profiles[0], $_; - redo PARENT; - } - } + @profiles = (); + read_parents_pushing norm_path('/etc', $_), 1000; push @profiles, '/etc/portage/profile'; }