aboutsummaryrefslogtreecommitdiff
blob: 1658f490c158df79cc6e89cc62d0669973594272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
<?xml version="1.0"?>
<guide self="ebuild-writing/common-mistakes/">
<chapter>
<title>Common Mistakes</title>

<body>
<p>
This section contains information on the common mistakes developers make when
writing ebuilds.
</p>
</body>

<section>
<title>Common Ebuild Writing Mistakes</title>
<body>

<subsection>
<title>Invalid use of <c>static</c> use-flag</title>
<body>
The <c>static</c> 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 <c>static-libs</c> use-flag is used for this.
</body>
</subsection>

<subsection>
<title>Invalid use of <c>ROOT</c></title>
<body>
<p>
The usage of <c>ROOT</c> is only designed to influence the way the package is
installed (ie. into <c>ROOT</c>) - building and compiling should not depend on
<c>ROOT</c>. As a consequence of this the usage of <c>ROOT</c> in <c>src_*</c>
functions is not allowed.
</p>

<p>
See also <uri link="::ebuild-writing/variables#ROOT"/>.
</p>
</body>
</subsection>

<subsection>
<title>Referencing the full path to documentation files that could be
compressed</title>
<body>
When printing out to the users where to find files like INSTALL, do not specify
the full path since <c>PORTAGE_COMPRESS</c> comes into play.  The file could be
compressed with gzip, bzip2, or some other random compression tool.  So,
instead of doing this:

<codesample lang="ebuild">
elog "They are listed in /usr/share/doc/${PF}/INSTALL.gz"
</codesample>

Do something like:

<codesample lang="ebuild">
elog "They are listed in the INSTALL file in /usr/share/doc/${PF}"
</codesample>
</body>
</subsection>

<subsection>
<title>Build log not verbose</title>
<body>
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 <b>build log must always be verbose.</b>
<p>
There are several ways to fix non-verbose build logs depending on the build system:
</p>
<p>
For <c>cmake</c> 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).
</p>

<p>
For <c>autotools</c> 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.
</p>

<p>
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.
</p>
<note>In case you encounter an affected package which uses a build system not
controllable by portage or eclasses you should file a bug (preferably with a patch)
and make it block the tracker bug #429308. Solutions above ebuild level are
preferred.</note>
</body>
</subsection>

<subsection>
<title>-Werror compiler flag not removed</title>
<body>
"-Werror" is a flag which turns all warnings into errors and thus will abort compiling if any warning is encountered.

<p><b>Rationale</b><p />
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.:
<ul>
  <li>
    new warnings on version bumps of GCC/GLIBC the developer was not aware of at the point of coding
  </li>
  <li>
    some autoconf checks will fail badly
  </li>
  <li>
    libraries adding deprecated API warnings although that API is still working/supported
  </li>
  <li>
    on less known architectures we may get different/more warnings than on common ones
  </li>
  <li>
    random breakage depending on what distro/architecture/library version/kernel/userland the developer was testing "-Werror" on
  </li>
</ul>
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.
</p>

<p><b>How to fix</b><p />
To fix the affected build system you should try the following methods:
<ul>
  <li>
    remove the compiler flag from the build system, <e>e.g. Makefile.am or configure.ac</e> or even provide a switch (for autotools based build systems that could be "--disable-werror", which is good for sending a patch upstream)
  </li>
  <li>
    use <e>append-flags -Wno-error</e> (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
  </li>
</ul>
Always check that it's really gone in the build log.
</p>

<p><b>Specific -Werror=... flags</b><p />
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.
</p>

<p><b>Exceptions</b><p />
Removing "-Werror" from configure.ac can cause breakage in very rare
cases where the configure phase relies on the exit code. See
<uri link="https://sourceforge.net/tracker/?func=detail&amp;aid=2959749&amp;group_id=204462&amp;atid=989708">
app-emulation/open-vm-tools bug</uri>. But even then we remove it from
the resulting Makefile.
</p>
</body>
</subsection>

<subsection>
<title>Missing/Invalid/Broken Header</title>
<body>

<p>
When you submit your ebuilds, the header must be <e>exactly</e> the same as
the one in
<uri link="https://gitweb.gentoo.org/repo/gentoo.git/tree/skel.ebuild">
skel.ebuild</uri>.
</p>

<p>
The first two lines <e>must</e> look like this:
</p>

<pre caption="Valid Header">
# Copyright 1999-2019 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
</pre>

<note>
The header previously included a third line with a CVS <c>&#36;Id&#36;</c>
or <c>&#36;Header&#36;</c> keyword. That line was abolished after conversion
to Git by <uri link="https://bugs.gentoo.org/611234">decision of the Gentoo
Council on 28 February 2017</uri> and <e>must not</e> be added any more.
</note>

</body>
</subsection>
<subsection>
<title>Redefined P, PV, PN, PF</title>
<body>

<p>
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.
</p>

<p>
By the way, if you find a package that re-defines it, don't copy it. Submit a
bug about that ebuild.
</p>

</body>
</subsection>
<subsection>
<title>Including version numbers in SRC_URI and S</title>
<body>

<p>
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:
</p>

<pre caption="Example versioning redefinition">
MY_P=${P/pyopenal/PyOpenAL}
SRC_URI="http://download.gna.org/pyopenal/${MY_P}.tar.gz"
S=${WORKDIR}/${MY_P}
</pre>

</body>
</subsection>
<subsection>
<title>DEPEND has syntactical errors</title>
<body>

<p>
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.
</p>

<ul>
  <li>
    <e>Always include the CATEGORY.</e><br />
    For example, use <c>&gt;=x11-libs/gtk+-2</c> and not <c>&gt;=gtk+-2</c>.
  </li>
  <li>
    <e>Do not put an asterisk (*) for &gt;= dependencies.</e><br />
    For example, it should be <c>&gt;=x11-libs/gtk+-2</c> rather than
    <c>&gt;=x11-libs/gtk+-2*</c>.
  </li>
  <li><e>GTK specific. Always use =x11-libs/gtk+-1.2* for GTK+1 apps.</e></li>
  <li>
    <e>Never depend on a meta package.</e><br />
    So don't depend on gnome-base/gnome, always depend on the specific
    libraries like libgnome.
  </li>
  <li>
    <e>One dependency per line.</e><br />
    Don't put multiple dependency on the same line. It makes it ugly to read
    and hard to follow.
  </li>
</ul>

</body>
</subsection>
<subsection>
<title>DEPEND is incomplete</title>
<body>

<p>
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.
</p>

<ul>
  <li>
    <e>Look in configure.in or configure.ac</e><br />
    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.
  </li>
  <li>
    <e>Look at included .spec files</e><br />
    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
  </li>
  <li>
    <e>Look at the application/library website</e><br />
    Check the application website for possible dependencies that they suggest
    are needed.
  </li>
  <li>
    <e>Read the README and INSTALL for the package</e><br />
    They usually also contain useful information about building and installing
    packages.
  </li>
  <li>
    <e>Remember non-binary dependencies such as pkg-config, doc generation
    programs, etc.</e><br />
    Usually the build process requires some dependencies such as intltool,
    libtool, pkg-config, doxygen, scrollkeeper, gtk-doc, etc. Make sure those
    are clearly stated.
  </li>
</ul>

</body>
</subsection>
<subsection>
<title>LICENSE Invalid</title>
<body>

<p>
Another common mistake users make when submitting ebuilds is supplying an
invalid license. For example, <c>GPL</c> is not a valid license. You need to
specify <c>GPL-1</c> or <c>GPL-2</c>. Same with <c>LGPL</c>. Make sure the
license you use in the <c>LICENSE</c> field is something that exists in
<path>/usr/portage/licenses</path>. As a tip, check the <path>COPYING</path>
in a source tarball for the license. If a package does not specify it
uses <c>GPL-1</c> or <c>GPL-2</c>, it is very likely it uses <c>GPL-2</c>.
</p>

<p>
If the license for the package you submit is unique and not in
<path>/usr/portage/licenses/</path>, then you must submit the new license in a
separate file.
</p>

</body>
</subsection>
<subsection>
<title>Untested ARCHs in KEYWORDS</title>
<body>

<p>
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
<c>~</c>.
</p>

</body>
</subsection>
<subsection>
<title>SLOT missing</title>
<body>

<p>
Make sure you have the SLOT variable in the ebuild. If you don't plan to use it,
don't remove it. Put in:
</p>

<pre caption="Default SLOT variable">
SLOT="0"
</pre>

</body>
</subsection>
<subsection>
<title>DESCRIPTION and HOMEPAGE wrong</title>
<body>

<p>
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. Set HOMEPAGE to
<uri link="::ebuild-maintenance#Homepage unavailable">No_homepage wiki page</uri>,
if there is none.
</p>

</body>
</subsection>
<subsection>
<title>Wrongfully used spaces instead of TABS</title>
<body>

<p>
It is no fun reformatting lines of ebuilds because the submitter did not follow
the guidelines to use TABS rather than spaces. So <e>please</e> use tabs!
</p>

</body>
</subsection>
<subsection>
<title>Trailing whitespace</title>
<body>

<p>
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.
</p>

</body>
</subsection>
<subsection>
<title>Adding redundant S=${WORKDIR}/${P}</title>
<body>

<p>
If <c>S=${WORKDIR}/${P}</c>, then you should not add it to your ebuild. This is
implied already, you should only add it if it is something other than
<c>${WORKDIR}/${P}</c>.
</p>

</body>
</subsection>
<subsection>
<title>Documentation missing</title>
<body>

<p>
If your package has documentation, make sure you install it using <c>dodoc</c>
or in <path>/usr/share/doc/${PF}</path>. Remember to check for errors when
running <c>dodoc</c>/<c>doins</c>.
</p>

<p>
If the package documentation is large or requires additional
dependencies to build, you should make it optional with the <c>doc</c>
USE flag.  If the documentation is small and does not require
additional dependencies (e.g. <c>README</c> files), install it
unconditionally.
</p>

</body>
</subsection>

<subsection>
<title>Masking unsupported/broken USE flags</title>
<body>
<p>
Exceptionally, a package may have an unsupported/broken USE flag
(this can happen with <e>vanilla</e> or <e>custom-cflags</e>).
Then the USE flag must be masked for that ebuild
(usually in <e>profiles/base/package.use.mask</e>),
at least when the ebuild hits the stable branch.
</p>
</body>
</subsection>

</body>
</section>


<section>
<title>Common Ebuild Submission Mistakes</title>
<subsection>
<title>Introduction</title>
<body>

<p>
Please submit ebuilds properly by following the <uri
link="::ebuild-maintenance#adding-a-new-ebuild">Adding new Ebuild</uri> tutorial.
</p>

</body>
</subsection>
<subsection>
<title>Tarball'ing an ebuild</title>
<body>

<p>
Please do not attach ebuilds or patches as tarballs. It avoids extra
operations when reviewing.
</p>

</body>
</subsection>
<subsection>
<title>Inlining Ebuilds</title>
<body>

<p>
Don't cut and paste an ebuild into bugzilla's comment field.
</p>

</body>
</subsection>
<subsection>
<title>No description on what the package is</title>
<body>

<p>
Please let us know what the package is, and fill in the URL with the home page
of the application, if any exists.
</p>

</body>
</subsection>
<subsection>
<title>Package updates without explaining what has changed</title>
<body>

<p>
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.
</p>

<p>
It is wise to submit a diff for a package update rather than the whole ebuild.
The best way to generate it would be:
</p>

<pre caption="Creating a diff">
$ <i>diff -u some-package-0.1.0.ebuild some-package-0.2.0.ebuild &gt; ~/some-package-0.2.0.diff</i>
</pre>

</body>
</subsection>
<subsection>
<title>Submitting unchanged ebuilds for version bumps</title>
<body>

<p>
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.
</p>

</body>
</subsection>
</section>

</chapter>

</guide>