Writing ebuilds for Gentoo – my experiences

Being new to the Gentoo world, I had to quickly write a few ebuilds. This process is reasonably well documented in Ebuild howto and wiki, however, some issues are not very clear.

Here’s what wasn’t obvious to me:

  1. Installing packages using ebuild and a full path to your ebuild doesn’t work (from the man-page: The implementation of emerge /path/to/ebuild is broken and so this syntax shouldn’t be used).
  2. In this case, to install your package you should probably create PORTDIR_OVERLAY in /etc/make.conf (e.g., PORTDIR_OVERLAY="/usr/local/portage", see this wiki page).
  3. Your package has to be in one of the predefined categories. If you come up with something new, Portage will happily ignore it.
  4. Before emerging, you should recompute the digest of your package using emerge /path/to/ebuild digest command.
  5. It seems that from within the package, it is difficult to distinguish whether the package is being installed for the first time vs. updated and updated vs. removed. For this, I wrote a hack, which I documented in my blog.

2 Responses to “Writing ebuilds for Gentoo – my experiences”

  1. Jeff Shanab Says:

    I am getting started writing ebuilds and came accross the same issues, I want to add a catagory for cad :-)

    I am having a bit of a problem with it not being able to find my configure file, I think because it is in a subdirectory. Do you have any advice about that?

    when the tar expands it puts things in /var/tmp/portage/opencascade-5.2/work inside work is the subdirectory ros that has the configure file and a src direcory that contais the source

  2. tadekp Says:

    Well, looking at the source /usr/lib/portage/bin/ebuild.sh it looks that you can predefine a variable ECONF_SOURCE and, indeed, some of the packages do this. Hope this helps!

Leave a Reply