Part 5 Basic Ebuild

WARNING:
THESE ARE MY PERSONAL NOTES ON MY FIRST EBUILD.
THIS IS BY NO MEANS A USEFUL GUIDE OR ANYTHING SIMILAR TO ANYONE.
RTFM

I’ll try to write an ebuild from scratch and document the progress here.

Ebuild from scratch: Part 5 : Basic Ebuild for MultiMarkdown

Now let’s start writing the ebuild.

Folder Structure

In Part 1 : Preparations a local overlay was created.
Now create folders for our new ebuild in there:
mkdir -p /usr/local/portage/dev-lang/peg-multimarkdown
Note: I chose package name “dev-lang/peg-multimarkdown” here.

Create ebuild File

Change to the new folder and start editing a new ebuild file (I use vim):
cd /usr/local/portage/dev-lang/peg-multimarkdown
vim peg-multimarkdown-9999.ebuild

I don’t know if this versioning is correct, but there seem to be no releases in the git-repository. This will use the master branch of the repo and we’ll have to unmask it.

Ebuild Header

Vim (or some plugin) is friendly and starts up with a template.
This is the first version of the file:

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=0

# project is hosted on github.com, so git-2 is needed (git is deprecated)
inherit git-2

DESCRIPTION="MMD is a superset of the Markdown syntax (more syntax features & output formats)"
HOMEPAGE="http://http://fletcherpenney.net/multimarkdown"

EGIT_REPO_URI="git://github.com/fletcher/peg-multimarkdown.git"
SRC_URI=""

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64"

Notes:
EAPI: I start with EAPI=0. Seems to be the lowest level, let’s see how far I get with it.
inherit git-2 : This is a git-based ebuild. This inlcudes the git-2.eclass, which will also be processed.
EGIT_REPO_URI : Necessary for git-2, the url that would be used in a “git clone” (see MultiMarkdown Linux Installation)

Ebuild Manifest

The Manifest file holds some sort of hashes for all the file in the ebuild (like md5sum).
It must be recreated after any change with:
ebuild peg-multimarkdown-9999.ebuild manifest

Stepping through the emerge process

Here’s the quote again:

  • Gentoo Development Guide : Ebuild Functions:

    When installing packages from source, the function call order is pkg_setup, src_unpack, src_prepare, src_compile, src_test (optional, FEATURES=”test”), src_install, pkg_preinst, pkg_postinst.

    man ebuild seems to show the functions in correct order, let’s try “unpack”:

    ebuild peg-multimarkdown-9999.ebuild unpack
    … actually performs “git clone”. We inherited the git-2.eclass, its function git-2_src_unpack does this.
    Anyway, the output shows:
    Source unpacked in /var/tmp/portage/dev-lang/peg-multimarkdown-9999/work
    so let’s go there.
    cd /var/tmp/portage/dev-lang/peg-multimarkdown-9999/work
    ls -al
    cd peg-multimarkdown-9999
    ls -al

    … correct, the result of a “git clone”.

    Just for fun, test “make”:
    make
    ls -al

    Interesting … created were:

    • multimarkdown : an executable binary!
    • *.o files : compiled versions of the *.c files.
    • peg folder : no idea what this is

    Let’s clean up, then go one step further in the ebuild – directly to the src_compile()-function:
    cd /usr/local/portage/
    ebuild peg-multimarkdown-9999.ebuild clean
    ebuild peg-multimarkdown-9999.ebuild compile

    Trailing to the output of the git-clone follows the same output as previously with make!
    Let’s check:
    ls -al /var/tmp/portage/dev-lang/peg-multimarkdown-9999/work/peg-multimarkdown-9999/
    ==> The same files were created.

    We’re not done yet, but it’s time for next part …


Home: Ebuild From Scratch
Previous chapter: Part 4 Emerge Process
Next chapter: Part 7 Testing & Fixing Installation

Advertisements

One comment

  1. José Fournier · · Reply

    Hi,

    Thank you for this very intersting tuto.
    It seems that before running :
    [qote]
    ebuild peg-multimarkdown-9999.ebuild clean
    ebuild peg-multimarkdown-9999.ebuild compile
    [/quote]
    user should

     cd /usr/local/portage/dev-lang/peg-multimarkdown-9999/ 

    instead of

     cd /usr/local/portage/

    Moreover I got a compile error I do not meet with the previous direct make.

    [quote]
    localhost peg-multimarkdown # ls -a
    . .. Manifest peg-multimarkdown-9999.ebuild
    localhost peg-multimarkdown # ebuild peg-multimarkdown-9999.ebuild clean
    localhost peg-multimarkdown # ebuild peg-multimarkdown-9999.ebuild compile
    * checking ebuild checksums ;-) … [ ok ]
    >>> Unpacking source…
    GIT update –>
    repository: git://github.com/fletcher/peg-multimarkdown.git
    at the commit: 0d9c20e50874e4410ac33784a27e43c778d91995
    branch: master
    storage directory: “/usr/portage/distfiles/egit-src/peg-multimarkdown.git”
    checkout type: bare repository
    Cloning into ‘/var/tmp/portage/dev-lang/peg-multimarkdown-9999/work/peg-multimarkdown-9999’…
    done.
    Branch branch-master set up to track remote branch master from origin.
    Switched to a new branch ‘branch-master’
    >>> Unpacked to /var/tmp/portage/dev-lang/peg-multimarkdown-9999/work/peg-multimarkdown-9999
    >>> Source unpacked in /var/tmp/portage/dev-lang/peg-multimarkdown-9999/work
    >>> Compiling source in /var/tmp/portage/dev-lang/peg-multimarkdown-9999/work/peg-multimarkdown-9999 …
    make -j5
    CC=gcc make -C peg-0.1.9
    cc -c -O2 -pipe -ansi -o markdown_output.o markdown_output.c
    cc -c -O2 -pipe -ansi -o markdown_lib.o markdown_lib.c
    cc -c -O2 -pipe -ansi -o GLibFacade.o GLibFacade.c
    cc -c -O2 -pipe -ansi -o utility_functions.o utility_functions.c
    make[1]: Entering directory `/var/tmp/portage/dev-lang/peg-multimarkdown-9999/work/peg-multimarkdown-9999/peg-0.1.9′
    gcc -g -Wall -O3 -DNDEBUG -c -o peg.o peg.c
    In file included from utility_functions.c:4:0:
    utility_functions.h:5:18: fatal error: glib.h: No such file or directory
    compilation terminated.
    make: *** [utility_functions.o] Error 1
    make: *** Waiting for unfinished jobs….
    gcc -g -Wall -O3 -DNDEBUG -c -o tree.o tree.c
    In file included from markdown_output.c:27:0:
    odf.h:6:18: fatal error: glib.h: No such file or directory
    compilation terminated.
    make: *** [markdown_output.o] Error 1
    gcc -g -Wall -O3 -DNDEBUG -c -o compile.o compile.c
    In file included from peg.c:48:0:
    peg.peg-c: In function ‘yy_Sequence’:
    peg.peg-c:791:3: warning: label ‘l77’ defined but not used [-Wunused-label]
    In file included from peg.c:48:0:
    peg.c: At top level:
    peg.peg-c:226:16: warning: ‘yyPush’ defined but not used [-Wunused-function]
    peg.peg-c:227:16: warning: ‘yyPop’ defined but not used [-Wunused-function]
    peg.peg-c:228:16: warning: ‘yySet’ defined but not used [-Wunused-function]
    gcc -g -Wall -O3 -DNDEBUG -c -o leg.o leg.c
    leg.c:253:15: warning: ‘yyAccept’ defined but not used [-Wunused-function]
    leg.c:268:16: warning: ‘yyPush’ defined but not used [-Wunused-function]
    leg.c:269:16: warning: ‘yyPop’ defined but not used [-Wunused-function]
    leg.c:270:16: warning: ‘yySet’ defined but not used [-Wunused-function]
    gcc -g -Wall -O3 -DNDEBUG -o peg-new peg.o tree.o compile.o
    mv peg-new peg
    gcc -g -Wall -O3 -DNDEBUG -o leg-new leg.o tree.o compile.o
    mv leg-new leg
    make[1]: Leaving directory `/var/tmp/portage/dev-lang/peg-multimarkdown-9999/work/peg-multimarkdown-9999/peg-0.1.9′
    emake failed
    * ERROR: dev-lang/peg-multimarkdown-9999::x-portage failed (compile phase):
    * emake failed
    *
    * Call stack:
    * ebuild.sh, line 93: Called src_compile
    * environment, line 2727: Called __eapi0_src_compile
    * phase-helpers.sh, line 655: Called __eapi2_src_compile
    * phase-helpers.sh, line 695: Called die
    * The specific snippet of code:
    * emake || die “emake failed”
    *
    * If you need support, post the output of `emerge –info ‘=dev-lang/peg-multimarkdown-9999::x-portage’`,
    * the complete build log and the output of `emerge -pqv ‘=dev-lang/peg-multimarkdown-9999::x-portage’`.
    * The complete build log is located at ‘/var/tmp/portage/dev-lang/peg-multimarkdown-9999/temp/build.log’.
    * The ebuild environment file is located at ‘/var/tmp/portage/dev-lang/peg-multimarkdown-9999/temp/environment’.
    * Working directory: ‘/var/tmp/portage/dev-lang/peg-multimarkdown-9999/work/peg-mul
    [/quote]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: