THESE ARE MY PERSONAL NOTES ON MY FIRST EBUILD.
THIS IS BY NO MEANS A USEFUL GUIDE OR ANYTHING SIMILAR TO ANYONE.
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.
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):
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.
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"
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)
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 ebuildseems 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.
… correct, the result of a “git clone”.
Just for fun, test “make”:
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:
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
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 …