HOWTO make your own Gentoo ebuild

From LinuxReviews
Jump to navigationJump to search

The Gentoo Linux distribution uses simple text-files to describe how software should be installed and configured. These files can be complex and do advanced things but they can also be really simple. Making a basic one is rather easy. This means that there's a lot of custom out-of-tree ebuilds you can (ab)use on Gentoo.

Where to place and how to name custom ebuilds

First, make a folder where you will store your own ebuilds. /usr/local/portage is a good choice.

Shell command(s):
mkdir -p /usr/local/portage

and set that folder to be an overlay for portage in /etc/make.conf:

File: /etc/make.conf
PORTDIR_OVERLAY=/usr/local/portage

The folder structure in your overlay folder should be the same as found in /usr/portage so if you wanted to make an ebuild for a theme you would put that in /usr/local/portage/x11-themes.

Use the output from emerge -s package or emerge -pv package or eix to find its category and name. These reflect actual folders in /usr/portage. The ebuild for sys-apps/portage is found in /usr/portage/sys-apps/portage.

In what folder you place your own ebuilds is up to you, but it needs to fit one of the portage package categories. An ebuild for a new IM program should be placed in /usr/local/portage/net-im/newprogram/

All patches ebuilds use should be placed in a folder files/ where the ebuild is placed.

The ebuild needs to have a Manifest, a digital signature, for the source files used. These can be made with the command ebuild:

Shell command(s):
ebuild myebuild-0.1.1.ebuild digest

Once the ebuild is is place and the digital signature is made it can be emerged as usual:

Shell command(s):
emerge myebuild

How to make your own ebuilds

Take a look at the sample skeleton ebuild file founds on all Gentoo systems.

Shell command(s):
less /usr/portage/skel.ebuild

With very little editing you can use this file to make your own ebuilds.

Using downloaded ebuilds

If you download a plain .ebuild file, then copy the file to an appropiate folder in your portage overlay tree and make a digest for it:

mkdir -p /usr/local/portage/app-text/txt2tags
cd /usr/local/portage/app-text/txt2tags
cp /home/you/txt2tags-1.7.ebuild .
ebuild txt2tags-1.7.ebuild digest

Builds from BreakMyGentoo and others come has archives with a Manifest and digest included. Simply extract these files to /usr/local/portage/ and emerge them as usual:

wget http://ebuilds.net/gdesklets-core-0.24.1-rc1.tar.gz
tar xfvz gdesklets-core-0.24.1-rc1.tar.gz -C /usr/local/portage/

Where to look for ebuilds

Updating ebuilds to new versions

If you want to make an ebuild for a new release for slurm, you could:

mkdir -p /usr/local/portage/net-analyzer/slurm
cd /usr/local/portage/net-analyzer/slurm
cp -r /usr/portage/net-analyzer/slurm ..

Then rename the latest ebuild in portage to your new version

Shell command(s):
mv slurm-0.2.3.ebuild slurm-0.3.2.ebuild

and use that as the basis for your new ebuild. You could also add -rN to your ebuild to indicate it is a modified version of some ebuild: slurm-0.3.2.ebuild.ebuild becomes slurm-0.3.2.ebuild-r1.ebuild.

Now download the source and make a digital signature:

Shell command(s):
ebuild slurm-0.3.2.ebuild digest

Now your new ebuild should be available when you do

Shell command(s):
emerge slurm