upgrading a gentoo box that hasn’t been upgraded since 2007

I was given root today in a gentoo box that nobody had upgraded since 2007. As expected the “emerge –sync; emerge -uDavt world” showed a lot of blockages.

I tried to solve each one but I got stuck while trying to upgrade portage 2.1.3.9 to 2.1.6.11. In order to upgrade portage I had to upgrade sandbox, but sandbox couldn’t be ugraded correctly due to portage 2.1.3.9 being unable to handle .tar.lzma files.
The box had sandbox-1.2 installed and it was unable to upgrade to sandbox-1.6. The error was:

unpack sandbox-1.6.tar.lzma: file format not recognized. Ignoring.

Upgrading lzma-utils, tar and a few other packages did not work. In the end I edited the sandbox-1.6-r2.ebuild and changed the src_unpack function from:
src_unpack() {
unpack ${A}
cd "${S}"
epatch "${FILESDIR}"/${P}-disable-qa-static.patch
epatch "${FILESDIR}"/${P}-disable-pthread.patch
epatch "${FILESDIR}"/0001-libsandbox-handle-more-at-functions.patch
}

To:
src_unpack() {
unpack ${A}
cd /var/tmp/portage/sys-apps/sandbox-1.6-r2/
tar --lzma -xvf sandbox-1.6.tar.lzma
mv sandbox-1.6/ work/
cd "${S}"
epatch "${FILESDIR}"/${P}-disable-qa-static.patch
epatch "${FILESDIR}"/${P}-disable-pthread.patch
epatch "${FILESDIR}"/0001-libsandbox-handle-more-at-functions.patch
}

Then:
cd /usr/portage/sys-apps/sandbox/; ebuild sandbox-1.6-r2.ebuild manifest

After this edit, sandbox emerged properly, so portage emerged properly too. Everything else worked as expected…