Earlier, two GCC on my system were pulled for rebuilding. That got me thinking, do I really need two versions of GCC? Most of packages should be fine with current stable GCC in Portage tree. And those whom were built using little older version 4.3.4, would not require GCC anymore since they were emerged. Also I had app-text/docbook-xml-dtd and dev-libs/boost, both had at least four slots emerged.

I decided to see if I really need that many slots, I came up with this short Bash script:

INSTFORMAT='{last}{else} <slot>{}' FORMAT='<category>/<name><installedversions:INSTFORMAT>\n' eix -I -2 | grep ' ' |
while read pkg slots; do
  [[ "$pkg" == "Found" ]] && continue

  for slot in ${slots}; do
    echo "equery d ${pkg}:${slot}"
  done

  echo -n "emerge -pv --depclean"
  for slot in ${slots}; do
    echo -n " ${pkg}:${slot}"
  done
  echo
  echo
done | tee slots.lst

Just copy-and-pasting into your shell. It requires eix for listing packages. I cant find any command to list packages have two installed slots, so I made my own using eix. Note that the last slot of the package is not listed because it should be your current version, you dont need to unemerge that, do you?

It gives you outputs like:

equery d app-text/docbook-xml-dtd:4.1.2
equery d app-text/docbook-xml-dtd:4.2
equery d app-text/docbook-xml-dtd:4.3
equery d app-text/docbook-xml-dtd:4.4
emerge -pv --depclean app-text/docbook-xml-dtd:4.1.2 app-text/docbook-xml-dtd:4.2 app-text/docbook-xml-dtd:4.3 app-text/docbook-xml-dtd:4.4

Basically you only need the last one command, those equery are for references if you like to use them. emerge with -v should give you enough information why one is not pulled for unemerging. If that command doesnt list any package as unemerge, then skip, those slots are all required. Some might be pulled, some might not, or all not.

Remove -pv to do a real unemerging.

After you finish, you should run

  1. emerge -pvuDt world to make sure you dont unemerge something accidentally (if you have changed those commands), and definitely to run
  2. revdep-build. Some of you packages might be built against old slots and its dependencies can depend on newer slots/version. You would need to rebuild those.

I cleaned up 19 slots.