User:Maffblaster/Drafts/Advanced ebuild testing guide

This guide provides instructions for users to create their own chroot test environments. This is helpful for those who would like to test their ebuilds in a basic, pollution free environment.

Introduction
Chroots have been around for a long time. Apparently the first "chroot" system call was introduced in Version 7 Unix in 1979. They are essential to the Gentoo installation process (those who have followed the Gentoo Handbook have worked in a chroot environment). Originating with the development of Gentoo the term "stage tarball" was created to help the Gentoo Release Engineering team define what tasks still needed completing in a chroot environment. Read up on the four levels of stage tarballs in the stage tarball article.

Official Gentoo Stage3 tarballs
The officially generated stage3 tarballs from the Release Engineering project are perfect specimens to use for creating new chroots, they can be generally obtained from the following links:

Custom stage3 tarballs
Have a currently running system that would be nice to use a test environment? Use the command to compress it into a stage3 or stage4 tarball, just make sure to label it appropriately:

Snapshotable filesystems (btrfs, zfs)
When using a filesystem that has the capability to create snapshots, it is possible to quickly generate chroot test environments.

Btrfs
To make a 'chroot' snapshot of the currently running system with btrfs, issue:

Then simply run the mount commands for the appropriate virtual filesystems.

Zfs
If you want to take a snapshot of a single dataset in zfs you would do the following:

If you want to take a snapshot of every dataset under a particular dataset, you can do:

ZFS snapshots are read-only. If you want to create a writeable dataset, use the "clone" command on a snapshot. Example:

If you have a "tank/gentoo/chroot" dataset that you want to make clones from, you would first take a snapshot to save a read only copy, and then we would make how many clones from that as you desire:

zfs snapshot tank/gentoo/chroot@testingBase zfs clone tank/gentoo@chroot@testingBase tank/gentoo/container1 zfs clone tank/gentoo@chroot@testingBase tank/gentoo/container2 zfs clone tank/gentoo@chroot@testingBase tank/gentoo/container3

If after a while you decide that you want to delete chroot, all of it's snapshots, and all of its dependent clones, you can actually do that in one command:

LXC
https://github.com/globalcitizen/lxc-gentoo

https://github.com/specing/lxc-gentoo