About | Links | Scripts
Sharing linux/windows scripts and tips

Downgrade Gentoo from testing to stable

August 05, 2018 — Jesse Harris

At some point in my main Gentoo boxes life I added the ~amd64 keyword into my make.conf. I don't remeber why I did this, but I can't think of a reason I need my entire install to be bleeding edge.

I did some googling around on the best approach to achieve this and from what I read on forums, having a bunch of testing packages downgrade to stable is not such a good idea.

One reason might be that per app config files are usually only designed to be backward compatible, not forward compatible.

At any rate, the idea is to gather a list of currently installed testing packages and add them to package.keywords for their current version.

With this method, eventually those packages will become stable.

The method I used is basically from the sabayon wiki with a few tweaks.

  1. First, edit make.conf ACCEPT_KEYWORDS to:

  2. Now use equery, sed and grep to construct a new packge.keywords

     equery -C -N list -F '=$cpv $mask2' '*' | \
         grep \~ | sed 's/\[~amd64 keyword\]/~amd64/' > \

Basically I added '-C' to remove colours and grep

  1. Examine testpackages for sanity, and then test with a world upgrade.

     emerge --ask --update --newuse --deep --with-bdeps=y @world
     These are the packages that would be merged, in order:
     Calculating dependencies... done!
     Nothing to merge; quitting.


18 months since making this change I thought I'd see how many of the original testing packages are still on my system. This little shell snippit uses equery to check if a package listed in the testpackages portage file made earlier is still installed on the system, and if not, update the file with a # in front.

    for i in $(awk '/=/ {print $1}' testpackages)
      if ! equery l "$i" > /dev/null;
        sudo sed -ie "s/\(${i/\//\\/}\)/#\1/" \

After running this grep -c '^#' testpackages shows 368 packages no longer needed in here and conversely 118 are still required.

Tags: gentoo, portage