Staging Gentoo upgrades using binpkg and chroot
I've been experimenting with a set of scripts intended to build binpkgs for a system on the system itself, without touching production applications, in preparation for the "real" upgrade. The system in question is running root-on-ZFS, which allows me to use a copy-on-write copy of the real root as the chroot target, but this isn't a prerequisite for the idea in general.
There are some non-trivial interactions between PID namespaces (
unshare --pid) and Portage. When I attempted to use a separate PID namespace, I received mysterious
Bad file descriptor errors from find at the very end of any Portage install inside the chroot.
- Create a ZFS snapshot of /, make a clone from it, mount it somewhere
/var/cache/distfilesinto the chroot
FEATURES="buildpkg"in the chroot's make.conf
- Inside the chroot, perform whatever Portage operations you want (e.g.
emerge --sync && emerge --update --deep --with-bdeps=y @world)
- If you've synced the Portage tree inside the chroot, you might want to copy it to the real system
- Close down the chroot -- you've got your binary packages. You can also delete the ZFS clone and snapshot.
- Repeat the Portage operations on the host, with
So far, I have automated the creation/destruction of the snapshot+clone and proper mounting/unmounting of proc, dev, sys into the chroot.