I was trying to figure out what packages are part of system set. So I went to check /etc/make.profile and followed any parent profiles for the list of packages in packages file of profiles which make.profile inherits. Soon, I realized that it’s easier to use a script, a Bash function actually.

lsprofile() {
  local d l PWD
  cd "${1:-/etc/make.profile}"
  d="$(pwd -P)"
  l=${2:-0}
  echo -e "\e[$((l+1))G$l ${d#/usr/portage/profiles/}"
  [[ ! -f "$d/parent" ]] && return 0

  while read p; do
    lsprofile "$d/$p" $((l+1))
  done < "$d/parent"
}

You can run it without argument or give it one profile file. Here is the result on the profile I used:

% lsprofile
0 default/linux/amd64/10.0/no-multilib
 1 default/linux/amd64/10.0
  2 default/linux/amd64
   3 base
   3 default/linux
   3 arch/amd64
    4 arch/base
    4 features/multilib
  2 releases/10.0
   3 releases
 1 arch/amd64/no-multilib
  2 arch/amd64
   3 arch/base
   3 features/multilib
 1 features/64bit-native

The first one is the profile of my system. Bigger number means longer distance ancient. You might also want to consult the manpage of Portage and emerge, also Cascading/Stackable Profiles2. I then wrote another command to list packages in packages file in those profiles:

lsprofile /etc/make.profile | while read dummy pkg; do grep '^[^#]' "/usr/portage/profiles/$pkg/packages" 2>/dev/null ; done | sorT

I think there must be a easy way to list. I did find eix --system --only-names would list, but there are some differences, those1 seem to have been removed from portage tree. emerge -pv system is another way to list.

[1]They all are category virtual package.
[2]http://www.gentoo.org/proj/en/releng/docs/cascading-profiles.xml is gone.