Common Mistakes
This section contains information on the common mistakes developers make when writing ebuilds.
Common Ebuild Writing Mistakes
Invalid use of static
use-flag
The static
use-flag should only be used to make a binary use static
linking instead of dynamic linking. It should not be used to make a library
install static libraries. Instead, the static-libs
use-flag is used for this.
Invalid use of ROOT
The usage of ROOT
is only designed to influence the way the package is
installed (ie. into ROOT
) — building and compiling should not depend
on ROOT
. As a consequence of this the usage of ROOT
in
src_*
functions is not allowed.
See also ROOT.
Referencing the full path to documentation files that could be compressed
When printing out to the users where to find files like INSTALL, do not specify
the full path since PORTAGE_COMPRESS
comes into play. The file could be
compressed with gzip, bzip2, or some other random compression tool. So,
instead of doing this:
elog "They are listed in /usr/share/doc/${PF}/INSTALL.gz"
Do something like:
elog "They are listed in the INSTALL file in /usr/share/doc/${PF}"
Build log not verbose
When writing ebuilds, you should always check the build log, because the build system might ignore CC/CXX/LD/CFLAGS/LDFLAGS and such or add undesired flags by default. In order to analyze this and have complete information, in case someone reports a bug for your package, the build log must always be verbose.
There are several ways to fix non-verbose build logs depending on the build system:
For cmake
based build systems it should be sufficient that the ebuild calls
cmake-utils_src_compile which picks up the cmake-utils.eclass variable 'CMAKE_VERBOSE=1'
by default. If you call emake directly for whatever reason, you can do 'emake VERBOSE=1'
(note that cmake-utils_src_compile takes arguments as well which are passed to make).
For autotools
based build systems you can pass '--disable-silent-rules' to econf,
or use EAPI 5 where that argument is passed automatically. 'emake V=1' should also work.
For custom Makefiles you often have to write a patch. Try to get upstream to include an option like 'V=1' to enable full verbosity.
-Werror compiler flag not removed
"-Werror" is a flag which turns all warnings into errors and thus will abort compiling if any warning is encountered.
Rationale
This flag is not recommended for releases and should always be disabled when encountered in build-logs, because there are numerous cases where this breaks without purpose, e.g.:
- new warnings on version bumps of GCC/GLIBC the developer was not aware of at the point of coding
- some autoconf checks will fail badly
- libraries adding deprecated API warnings although that API is still working/supported
- on less known architectures we may get different/more warnings than on common ones
- random breakage depending on what distro/architecture/library version/kernel/userland the developer was testing "-Werror" on
Turning off "-Werror" we will still see the warnings, but there is no reason that they cause compile failure. Also note that portage already emits QA notices about gcc warnings that can cause runtime breakage.
How to fix
To fix the affected build system you should try the following methods:
- remove the compiler flag from the build system, e.g. Makefile.am or configure.ac or even provide a switch (for autotools based build systems that could be "--disable-werror", which is good for sending a patch upstream)
- use append-flags -Wno-error (needs flag-o-matic.eclass); for this to work the environment flags have to be respected and placed after build system flags; this method is not preferred as it will disable all "-Werror=specific-warning" flags as well, see next section
Always check that it's really gone in the build log.
Specific -Werror=... flags
GCC can turn any specific warning into an error. A specific -Werror flag would be "-Werror=implicit-function-declaration" for example and will only affect warnings about implicit function declarations. It's mostly safe to leave these untouched, cause they are pinned to this issue and should not cause random build time breakage. Also, we can expect that upstream did this on purpose to avoid known runtime errors and not just for testing their builds. However you should check the specified warnings yourself or ask other developers if unsure.
Exceptions
Removing "-Werror" from configure.ac can cause breakage in very rare cases where the configure phase relies on the exit code. See app-emulation/open-vm-tools bug. But even then we remove it from the resulting Makefile.
Missing/Invalid/Broken Header
When you submit your ebuilds, the header must be exactly the same as the one in skel.ebuild.
The first two lines must look like this:
# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2
$Id$
or $Header$
keyword. That line was abolished after conversion
to Git by decision of the Gentoo
Council on 28 February 2017 and must not be added any more.
Redefined P, PV, PN, PF
You should never redefine those variables. Always use MY_P, MY_PN, MY_PV, P0, etc. See other ebuilds that do it in portage for more information. Most ebuilds use bash "Parameter Expansion". Please read the man page for bash to understand how "Parameter Expansion" works.
By the way, if you find a package that re-defines it, don't copy it. Submit a bug about that ebuild.
Including version numbers in SRC_URI and S
You should try not to include version numbers in the SRC_URI and S. Always try to use ${PV} or ${P}. It makes maintaining the ebuild much easier. If a version number is not consistent with the tarball/source, then use MY_P. An example dev-python/pyopenal fetches a tarball called PyOpenAL, so we redefine it like:
MY_P=${P/pyopenal/PyOpenAL} SRC_URI="http://download.gna.org/pyopenal/${MY_P}.tar.gz" S=${WORKDIR}/${MY_P}
DEPEND has syntactical errors
There are many things that go wrong with user submitted DEPEND and RDEPEND fields. Here are some important points to follow when you write the dependency part.
-
Always include the CATEGORY.
For example, use
>=x11-libs/gtk+-2
and not>=gtk+-2
. -
Do not put an asterisk (*) for >= dependencies.
For example, it should be
>=x11-libs/gtk+-2
rather than>=x11-libs/gtk+-2*
. - GTK specific. Always use =x11-libs/gtk+-1.2* for GTK+1 apps.
- Never depend on a meta package. So don't depend on gnome-base/gnome, always depend on the specific libraries like libgnome.
- One dependency per line. Don't put multiple dependency on the same line. It makes it ugly to read and hard to follow.
DEPEND is incomplete
This is another very common error. The ebuild submitter submits an ebuild that "just works" without checking if the dependencies are correct. Here are some tips on how to find the correct dependencies.
- Look in configure.in or configure.ac. Look for checks for packages in here. Things to look out for are pkg-config checks or AM_* functions that check for a specific version.
- Look at included .spec files. A good indication of dependencies is to look at the included .spec files for relevant deps. However, do not trust them to be the definitive complete list of dependencies.
- Look at the application/library website. Check the application website for possible dependencies that they suggest are needed.
- Read the README and INSTALL for the package. They usually also contain useful information about building and installing packages.
- Remember non-binary dependencies such as pkg-config, doc generation programs, etc. Usually the build process requires some dependencies such as intltool, libtool, pkg-config, doxygen, scrollkeeper, gtk-doc, etc. Make sure those are clearly stated.
LICENSE Invalid
Another common mistake users make when submitting ebuilds is supplying an
invalid license. For example, GPL
is not a valid license. You need to
specify GPL-1
or GPL-2
. Same with LGPL
. Make sure the
license you use in the LICENSE
field is something that exists in
the licenses
directory. As a tip, check the COPYING
in a source tarball for the license. If a package does not specify it
uses GPL-1
or GPL-2
, it is very likely it uses GPL-2
.
If the license for the package you submit is unique and not in
licenses/
, then you must submit the new license in a
separate file.
Untested ARCHs in KEYWORDS
Please do not add other ARCHs into KEYWORDS unless the ebuild has been tested on
that ARCH. Also all new ebuilds should be ~x86 or whatever architecture it is.
Make sure when you bump a version, the stable KEYWORDS are all marked as
~
.
SLOT missing
Make sure you have the SLOT variable in the ebuild. If you don't plan to use it, don't remove it. Put in:
SLOT="0"
DESCRIPTION and HOMEPAGE wrong
Please check if the HOMEPAGE
variable is right and leads users to the
right page if they want to find out more about the package. And make sure
the DESCRIPTION
is not overly long. Good descriptions will describe
the main function of the package in a sentence. If no homepage for the package
is available, set the HOMEPAGE
variable to
https://wiki.gentoo.org/wiki/No_homepage
.
Wrongfully used spaces instead of TABS
It is no fun reformatting lines of ebuilds because the submitter did not follow the guidelines to use TABS rather than spaces. So please use tabs!
Trailing whitespace
I'm often guilty of this. Remember to run repoman over your ebuilds so it can tell you if there is trailing whitespace at the end of lines or on empty lines.
Adding redundant S=${WORKDIR}/${P}
If S=${WORKDIR}/${P}
, then you should not add it to your ebuild. This is
implied already, you should only add it if it is something other than
${WORKDIR}/${P}
.
Documentation missing
If your package has documentation, make sure you install it using dodoc
or in /usr/share/doc/${PF}
. Remember to check for errors when
running dodoc
/doins
.
If the package documentation is large or requires additional
dependencies to build, you should make it optional with the doc
USE flag. If the documentation is small and does not require
additional dependencies (e.g. README
files), install it
unconditionally.
Masking unsupported/broken USE flags
Exceptionally, a package may have an unsupported/broken USE flag (this can happen with vanilla or custom-cflags). Then the USE flag must be masked for that ebuild (usually in profiles/base/package.use.mask), at least when the ebuild hits the stable branch.
Common Ebuild Submission Mistakes
Introduction
Please submit ebuilds properly by following the Adding a New Ebuild tutorial.
Tarball'ing an ebuild
Please do not attach ebuilds or patches as tarballs. It avoids extra operations when reviewing.
Inlining Ebuilds
Don't cut and paste an ebuild into bugzilla's comment field.
No description on what the package is
Please let us know what the package is, and fill in the URL with the home page of the application, if any exists.
Package updates without explaining what has changed
If you submit a package update, then make sure you explain what changes you made to the ebuild. For example if a package introduces a new features/option and you use a USE flag, list it in your bug. Don't make us hunt for it.
It is wise to submit a diff for a package update rather than the whole ebuild. The best way to generate it would be:
$ diff -u some-package-0.1.0.ebuild some-package-0.2.0.ebuild > ~/some-package-0.2.0.diff
Submitting unchanged ebuilds for version bumps
If you are submitting a new version for a package in portage, make sure the existing ebuild works and make sure changes are incorporated in the new ebuild (such as added documentation.) If there are no required changes to the ebuild from the previous version, then don't attach the ebuild. Just say so in the bug report that you copied the ebuild over and verified that the package works and installs properly.