Tutorial 1 - Your First Ebuild


Creating a Working Ebuild


The first thing you need to know about an ebuild is the URI of the file you're going to be installing. Abeni tries to determine the package name and ebuild name from the SRC_URI.

Click the new file icon on the toolbar.


Type or paste this URI into the box and click the 'OK' button: http://osdn.dl.sourceforge.net/sourceforge/abeni/hello-0.1.tar.gz


You are now in the Main tab and can start working on your ebuild. You can see in the "Ebuild Info" section Abeni has determined the package's name is "hello" and the ebuild's name is "hello-0.1.ebuild" from the SRC_URI.


Click on the 'Category' button and select the category "app-misc".


In the 'Default Variables' section, notice that the SRC_URI has changed. Abeni translates all Source Forge URIs to the "mirror://" format. Gentoo's portage system keeps a list of all Source Forge's mirrors. Using the "mirror://" format allows the emerge command to try multiple mirrors if one fails.


Before you can use emerge or ebuild commands on your new ebuild you need to create a digest. Click the digest icon on the toolbar. This will download the source code and create a digest.


The hello package is a C program and uses the standard "./configure && make && make install".
We need two functions in our ebuild to get hello installed - "src_compile()" and "src_install()". Abeni has a few standard templates for these functions, which we'll use.


Click the new function icon on the toolbar or hit the F3 key. From the list of funtions presented choose:
src_compile - ./configure - make


Notice the new tab labelled "src_compile".

Now we add src_install: Click the new function icon on the toolbar or hit the F3 key. Choose: src_install - make install


Click the emerge icon on the toolbar and click the "OK" button to emerge. In the log window below you'll notice the normal emerge process output. When the ebuild is finished emerging, you'll see the bright red stop icon has faded.


Test the program using by typing "hello" in a console. It should simply output "Howdy world!".


Fine-tuning the Ebuild.


You now have a working ebuild, but it is not a syntactically correct ebuild because it is missing some required information.


Enter "A hello world program" in the DESCRIPTION field.


Look at the SRC_URI field:


"mirror://sourceforge/abeni/hello-0.1.tar.gz"


You should not use the version number in SRC_URI. Instead use the variable "P" which evaluates to the package name, a "-", and the version number. In this case, "P" is:
hello-0.1


So we change SRC_URI to: "mirror://sourceforge/abeni/{$P}.tar.gz"


Using this method makes maintenance simple. When hello version 0.2 is released, simply renaming the ebuild will download the correct version because the variable "P" is derived from the ebuild's name.


The only file installed with the current ebuild is the binary file hello in /usr/bin. We need to figure out what license the package uses and if there is any documenation to install.


Click the unpack icon on toolbar.


The file abeni-0.1.tar.gz is unpacked. Following the standard emerge unpacking message you'll see:


Unpacked these directory(s) into ${WORKDIR}:
hello-0.1


WORKDIR is /var/tmp/portage/hello-0.1/work in this case. To save you a bit of typing, click the xterm icon on toolbar. An xterm will be opened. In this xterm type 'cd work/hello-0.0.1'


Do an 'ls' command. You'll see:


AUTHORS INSTALL NEWS configure install-sh COPYING Makefile.am README configure.in missing ChangeLog Makefile.in aclocal.m4 hello.c mkinstalldirs


After reading COPYING, you'll know the program is licensed under the terms of the GNU Public License version 2, so type "GPL-2" in the LICENSE field, or click the LICENSE button and select GPL-2.


Now we need to get the documentation installed, so click on the src_install tab and add this line after "einstall || die"


dodoc README NEWS AUTHOR ChangeLog


You can view your finished ebuild by hitting the F7 key, which will display the ebuild in the editor you specified in the options menu.


Click on the emerge icon on the toolbar and click 'OK' to emerge this package.

Goto top of page


SourceForge.net Logo