Updating Portage Tree on Gentoo 2017 Image

As the portage tree on the Gentoo 2017 image hasn't been updated in a while running emerge --sync fails due to the portage package being out of date. To update it, it is required to download old snapshots and use them to slowly upgrade portage to a more recent version.

You may be able to find different combinations of snapshots but the following snapshot downloads worked for me:-

wget http://dev.gentoo.org/~swift/snapshots/portage-20170920.tar.bz2
wget http://dev.gentoo.org/~swift/snapshots/portage-20180120.tar.bz2
wget http://dev.gentoo.org/~swift/snapshots/portage-20180520.tar.bz2
wget http://dev.gentoo.org/~swift/snapshots/portage-20180720.tar.bz2

These contain the portage snapshot from the dates in the filenames. We will need to extract these to the /usr/portage directory sequentially and then update the portage package using that snapshot.

First start by backing up the existing /usr/portage directory:-

mv /usr/portage/ /usr/portage.latest

and then extract the oldest portage snapshot to /usr/portage

tar xjpf portage-20170920.tar.bz2 -C /usr

We will then need to update the portage package

emerge -auv portage

then complete the steps for each of the other snapshots

mv /usr/portage /usr/portage.20170920.old
tar xjpf portage-20180120.tar.bz2 -C /usr
emerge -auv portage
mv /usr/portage /usr/portage.20180120.old
tar xjpf portage-20180520.tar.bz2 -C /usr
emerge -auv portage
mv /usr/portage /usr/portage.20180520.old
tar xjpf portage-20180720.tar.bz2 -C /usr
emerge -avu portage
mv /usr/portage /usr/portage.20180721.old

This will leave your system in a position to restore the latest snapshot and emerge the latest portage package

mv /usr/portage.latest /usr/portage
emerge -auv portage

To tidy up, update the etc files that have been updated.


and confirm your portage tree is up to date

emerge --sync

Your should then be able to update your system

emerge -av system

Note if you are running Gentoo on a memory constrained system it would be a good idea to create a swap file and mount it automatically on boot. Otherwise compiling gcc will probably fail.

dd if=/dev/zero of=/mnt/2G.swap bs=1G seek=2 count=0
mkswap /mnt/2G.swap    

Configure /etc/fstab so that it mounts automatically on boot

sudo nano /etc/fstab

add the following line

/mnt/2G.swap    none    swap    sw,loop   0 0

and then confirm that it is able to find the fstab entry and mount the swap file

swapon -a