An alternative to git bisect with Gentoo and the live ebuild

Git bisect is absolutely powerful, but sometimes is more comfortable use emerge instead of compile the software outside the package manager.

That was my case with media-libs/jasper which I’m picking as example for this ‘howto’

So basically, you are running Gentoo, you can install a live ebuild (9999) and you want to find which commit id fixes an issue. Let’s see step-by-step what to do.

1) Clone the repository to obtain the commit ids and put them in a file

ago@blackgate ~ $ cd /tmp
ago@blackgate /tmp $ git clone https://github.com/mdadams/jasper.git
ago@blackgate /tmp $ cd jasper/
ago@blackgate /tmp/jasper $ git --no-pager log --format=%H > /tmp/commitlist.txt

The file should contain the git commit ids, for example:

883f85876a463019a16b6d38dd9afc022d1f07cf
de4e3953fd3ef9d539c5187b7988e8750b3d67c9
f9ccc661fd1094c8d1c3df38b51295677d268dbf

2) Use a simple script which runs emerge and the command you need to test.

#!/bin/bash
for COMMIT_ID in $( cat /tmp/commitlist.txt )
do
      echo "Testing with the commit id: "${COMMIT_ID}""
      EGIT_COMMIT="${COMMIT_ID}" emerge -q media-libs/jasper
      imginfo -f /tmp/myjpg.jpg
      echo -ne "\n\n\n"
done

With the EGIT_COMMIT variable from the git-* eclass, we can emerge the live ebuild at a specific commit id.
imginfo is in my case the command I need and then I print some blank lines to better separate the output of the commands and understand what is happening.

Now you need to wait and just check what is the output of the specified command.

SOME IMPORTANT NOTES:
– This howto looks to be valid when the project you are building is small; running this script with e.g. libreoffice will take months.
– This howto looks to be valid when you know that the problem is near to the commit master and will take few emerge cycles to found the issue.
– If you know that the problem is fixed e.g. a year ago, you can manually edit the commitlist.txt file and delete some recent ids, to have a specified and minor range of commits.

That’s all.

This entry was posted in gentoo. Bookmark the permalink.

4 Responses to An alternative to git bisect with Gentoo and the live ebuild

  1. Felix says:

    It would also be possible to combine git bisect and emerge via git
    bisect run. A run script could be of the form:

    #!/bin/bash

    EGIT_COMMIT=”$(git revparse HEAD)” emerge -q media-libs/jasper

    check_for_new_bug
    if has_bug; then
    return 1
    else
    return 0
    fi

    It might also be nice to use “ebuild … install” so that the running
    system is not affected by the tests.

    Reply
  2. eliasp says:

    Shouldn’t “${PN}_LIVE_COMMIT=$(git rev-parse HEAD)” be used instead of EGIT_COMMIT?

    Reply
  3. reck says:

    Why the grep and sed? git log has plenty of format options, git log –format=%H will log just the sha1s of each commit.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *