User:SAL9000

From Gentoo Wiki
Jump to: navigation, search

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.

Warning
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.
  1. Create a ZFS snapshot of /, make a clone from it, mount it somewhere
  2. Mount /var/cache/binpkgs and /var/cache/distfiles into the chroot
  3. Enable FEATURES="buildpkg" in the chroot's make.conf
  4. Inside the chroot, perform whatever Portage operations you want (e.g. emerge --sync && emerge --update --deep --with-bdeps=y @world)
  5. If you've synced the Portage tree inside the chroot, you might want to copy it to the real system
  6. Close down the chroot -- you've got your binary packages. You can also delete the ZFS clone and snapshot.
  7. Repeat the Portage operations on the host, with --usepkg or --usepkgonly

So far, I have automated the creation/destruction of the snapshot+clone and proper mounting/unmounting of proc, dev, sys into the chroot.