Bisecting with live ebuilds
Suppose one hits a regression in ZFS. In this example, between ZFS 2.1.4 (last known good version) and ZFS 2.1.6 (being the latest version where a bug is hit).
git bisect is enormously helpful for debugging issues. Luckily, zfs*-9999 ebuilds can be used to do this easily.
First, clone ZFS at the
git clone https://github.com/openzfs/zfs -b zfs-2.1.5-staging
Start the bisect:
git bisect start
git bisect bad zfs-2.1.5
git bisect good zfs-2.1.4
Create a simple script to allow easily building each commit:
export EGIT_OVERRIDE_COMMIT_OPENZFS_ZFS=$(git rev-parse HEAD) export EGIT_OVERRIDE_BRANCH_OPENZFS_ZFS=zfs-2.1.5-staging export ACCEPT_KEYWORDS="**" emerge -v1 zfs zfs-kmod echo "If this version is good (need to reboot), run 'git bisect good'." echo "If this version is bad (need to reboot), run 'git bisect bad'."
Run /tmp/test-zfs.sh repeatedly.
After each run of emerge by the script, test out ZFS by rebooting. If it worked, type git bisect good. If the bug remained, type git bisect bad. Continue until the first bad commit is identified.
Using git bisect run
git bisect has a 'run' subcommand which allows running a command or script to determine if a commit is good or bad.
For example, if sys-libs/glibc is failing in its last-minute sanity-check in
pkg_preinst, it's sufficient to use the following script with the glibc git repository:
#!/bin/bash export EGIT_OVERRIDE_COMMIT_GLIBC=$(git rev-parse HEAD) export EGIT_OVERRIDE_BRANCH_GLIBC=release/2.35/master export ACCEPT_KEYWORDS="**" #USE="vanilla" ... emerge -v1 sys-libs/glibc || exit 1