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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
The FreeBSD Documentation Project
$FreeBSD$
-->
<chapter xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
xml:id="testing">
<title>Testing the Port</title>
<sect1 xml:id="make-describe">
<title>Running <command>make describe</command></title>
<para>Several of the &os; port maintenance tools, such as
&man.portupgrade.1;, rely on a database called
<filename>/usr/ports/INDEX</filename> which keeps track of such
items as port dependencies. <filename>INDEX</filename> is
created by the top-level <filename>ports/Makefile</filename> via
<command>make index</command>, which descends into each port
subdirectory and executes <command>make describe</command>
there. Thus, if <command>make describe</command> fails in any
port, no one can generate <filename>INDEX</filename>, and many
people will quickly become unhappy.</para>
<note>
<para>It is important to be able to generate this file no matter
what options are present in <filename>make.conf</filename>, so
please avoid doing things such as using
<literal>.error</literal> statements when (for instance) a
dependency is not satisfied. (See
<xref linkend="dads-dot-error"/>.)</para>
</note>
<para>If <command>make describe</command> produces a string rather
than an error message, everything is probably safe. See
<filename>bsd.port.mk</filename> for the meaning of the string
produced.</para>
<para>Also note that running a recent version of
<command>portlint</command> (as specified in the next section)
will cause <command>make describe</command> to be run
automatically.</para>
</sect1>
<sect1 xml:id="testing-portlint">
<title>Portlint</title>
<para>Do check the port with <link
linkend="porting-portlint"><command>portlint</command></link>
before submitting or committing it. <command>portlint</command>
warns about many common errors, both functional and
stylistic. For a new (or repocopied) port,
<command>portlint -A</command> is the most thorough; for an
existing port, <command>portlint -C</command> is
sufficient.</para>
<para>Since <command>portlint</command> uses heuristics to try to
figure out errors, it can produce false positive warnings. In
addition, occasionally something that is flagged as a problem
really cannot be done in any other way due to limitations in the
ports framework. When in doubt, the best thing to do is ask on
&a.ports;.</para>
</sect1>
<sect1 xml:id="testing-porttools">
<title>Port Tools</title>
<para>The <package role="port">ports-mgmt/porttools</package>
program is part of the Ports Collection.</para>
<para><command>port</command> is the front-end script, which can
help simplify the testing job. Whenever a new port or an update
to an existing one needs testing, use
<command>port test</command> to test the port, including the
<link
linkend="testing-portlint"><command>portlint</command></link>
checking. This command also detects and lists any files that
are not listed in <filename>pkg-plist</filename>. For
example:</para>
<screen>&prompt.root; <userinput>port test /usr/ports/net/csup</userinput></screen>
</sect1>
<sect1 xml:id="porting-prefix">
<title><varname>PREFIX</varname> and
<varname>DESTDIR</varname></title>
<para><varname>PREFIX</varname> determines where the port will be
installed. It defaults to <filename>/usr/local</filename>, but
can be set by the user to a custom path like
<filename>/opt</filename>. The port must respect the value of
this variable.</para>
<para><varname>DESTDIR</varname>, if set by the user, determines
the complete alternative environment, usually a jail or an
installed system mounted somewhere other than
<filename>/</filename>. A port will actually install into
<filename>DESTDIR/PREFIX</filename>, and register with the
package database in <filename>DESTDIR/var/db/pkg</filename>. As
<varname>DESTDIR</varname> is handled automatically by the ports
infrastructure with &man.chroot.8;. There is no need for
modifications or any extra care to write
<varname>DESTDIR</varname>-compliant ports.</para>
<para>The value of <varname>PREFIX</varname> will be set to
<varname>LOCALBASE</varname> (defaulting to
<filename>/usr/local</filename>). If
<varname>USE_LINUX_PREFIX</varname> is set,
<varname>PREFIX</varname> will be <varname>LINUXBASE</varname>
(defaulting to <filename>/compat/linux</filename>).</para>
<para>Avoiding hard-coded <filename>/usr/local</filename> paths in
the source makes the port much more flexible and able to cater
to the needs of other sites. Often, this can be accomplished by
replacing occurrences of <filename>/usr/local</filename>
in the port's various <filename>Makefile</filename>s with
<literal>${PREFIX}</literal>. This variable is
automatically passed down to every stage of the build and
install processes.</para>
<para>Make sure the application is not installing things in
<filename>/usr/local</filename> instead of
<varname>PREFIX</varname>. A quick test for such hard-coded
paths is:</para>
<screen>&prompt.user; <userinput>make clean; make package PREFIX=/var/tmp/`make -V PORTNAME`</userinput></screen>
<para>If anything is installed outside of
<varname>PREFIX</varname>, the package creation process will
complain that it cannot find the files.</para>
<para>In addition, it is worth checking the same with the stage
directory support (see <xref linkend="staging"/>):</para>
<screen>&prompt.user; <userinput>make stage && make check-plist && make stage-qa && make package</userinput></screen>
<itemizedlist>
<listitem>
<para><buildtarget>check-plist</buildtarget> checks for files
missing from the plist, and files in the plist that are not
installed by the port.</para>
</listitem>
<listitem>
<para><buildtarget>stage-qa</buildtarget> checks for common
problems like bad shebang, symlinks pointing outside the
stage directory, setuid files, and non-stripped
libraries...</para>
</listitem>
</itemizedlist>
<para>These tests will not find hard-coded paths inside the port's
files, nor will it verify that <varname>LOCALBASE</varname> is
being used to correctly refer to files from other ports. The
temporarily-installed port in
<filename>/var/tmp/`make -V PORTNAME`</filename> must be
tested for proper operation to make sure there are no problems
with paths.</para>
<para><varname>PREFIX</varname> must not be set explicitly in a
port's <filename>Makefile</filename>. Users installing the port
may have set <varname>PREFIX</varname> to a custom location, and
the port must respect that setting.</para>
<para>Refer to programs and files from other ports with the
variables mentioned above, not explicit pathnames. For
instance, if the port requires a macro <literal>PAGER</literal>
to have the full pathname of <command>less</command>, do not use
a literal path of <filename>/usr/local/bin/less</filename>.
Instead, use <literal>${LOCALBASE}</literal>:</para>
<programlisting>-DPAGER=\"${LOCALBASE}/bin/less\"</programlisting>
<para>The path with <varname>LOCALBASE</varname> is more likely to
still work if the system administrator has moved the whole
<filename>/usr/local</filename> tree somewhere else.</para>
<tip>
<para>All these tests are done automatically when running
<command>poudriere testport</command> or <command>poudriere
bulk -t</command>. It is highly recommended that every
ports contributor install and test their ports with it. See
<xref linkend="testing-poudriere"/> for more
information.</para>
</tip>
</sect1>
<sect1 xml:id="testing-poudriere">
<title><application>Poudriere</application></title>
<para>For a ports contributor,
<application>Poudriere</application> is one of the most
important and helpful testing and build tools. Its main
features include:</para>
<itemizedlist>
<listitem>
<para>Bulk building of the entire ports tree, specific subsets
of the ports tree, or a single port including its
dependencies</para>
</listitem>
<listitem>
<para>Automatic packaging of build results</para>
</listitem>
<listitem>
<para>Generation of build log files per port</para>
</listitem>
<listitem>
<para>Providing a signed &man.pkg.8; repository</para>
</listitem>
<listitem>
<para>Testing of port builds before submitting a patch to the
&os; bug tracker or committing to the ports tree</para>
</listitem>
<listitem>
<para>Testing for successful ports builds using different
options</para>
</listitem>
</itemizedlist>
<para>Because <application>Poudriere</application> performs its
building in a clean &man.jail.8; environment and uses
&man.zfs.8; features, it has several advantages over traditional
testing on the host system:</para>
<itemizedlist>
<listitem>
<para>No pollution of the host environment: No leftover files,
no accidental removals, no changes of existing configuration
files.</para>
</listitem>
<listitem>
<para>Verify <filename>pkg-plist</filename> for missing or
superfluous entries</para>
</listitem>
<listitem>
<para>Ports committers sometimes ask for a
<application>Poudriere</application> log alongside a patch
submission to assess whether the patch is ready for
integration into the ports tree</para>
</listitem>
</itemizedlist>
<para>It is also quite straightforward to set up and use, has no
dependencies, and will run on any supported &os; release. This
section shows how to install, configure, and run
<application>Poudriere</application> as part of the normal
workflow of a ports contributor.</para>
<para>The examples in this section show a default file layout, as
standard in &os;. Substitute any local changes accordingly.
The ports tree, represented by <varname>${PORTSDIR}</varname>,
is located in <filename>/usr/ports</filename>. Both
<varname>${LOCALBASE}</varname> and <varname>${PREFIX}</varname>
are <filename>/usr/local</filename> by default.</para>
<sect2 xml:id="testing-poudriere-installing">
<title>Installing <application>Poudriere</application></title>
<para><application>Poudriere</application> is available in the
ports tree in <package
role="port">ports-mgmt/poudriere</package>. It can be
installed using &man.pkg.8; or from ports:</para>
<screen>&prompt.root; <userinput>pkg install poudriere</userinput></screen>
<para>or</para>
<screen>&prompt.root; <userinput>make -C /usr/ports/ports-mgmt/poudriere install clean</userinput></screen>
<para>There is also a work-in-progress version of
<application>Poudriere</application> which will eventually
become the next release. It is available in <package
role="port">ports-mgmt/poudriere-devel</package>. This
development version is used for the official &os; package
builds, so it is well tested. It often has newer interesting
features. A ports committer will want to use the development
version because it is what is used in production, and has all
the new features that will make sure everything is exactly
right. A contributor will not necessarily need those as the
most important fixes are backported to released version. The
main reason for the use of the development version to build
the official package is because it is faster, in a way that
will shorten a full build from 18 hours to 17 hours when using
a high end 32 <acronym>CPU</acronym> server with 128GB of
<acronym>RAM</acronym>. Those optimizations will not matter a
lot when building ports on a desktop machine.</para>
</sect2>
<sect2 xml:id="testing-poudriere-setup">
<title>Setting Up <application>Poudriere</application></title>
<para>The port installs a default configuration file,
<filename>/usr/local/etc/poudriere.conf</filename>. Each
parameter is documented in the configuration file and in
&man.poudriere.8;. Here is a minimal example config
file:</para>
<programlisting>ZPOOL=tank
ZROOTFS=/poudriere
BASEFS=/poudriere
DISTFILES_CACHE=/usr/ports/distfiles
RESOLV_CONF=/etc/resolv.conf
FREEBSD_HOST=ftp://ftp.freebsd.org
SVN_HOST=svn.FreeBSD.org</programlisting>
<variablelist>
<varlistentry>
<term><varname>ZPOOL</varname></term>
<listitem>
<para>The name of the <acronym>ZFS</acronym> storage pool
which <application>Poudriere</application> shall use.
Must be listed in the output of <command>zpool
status</command>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>ZROOTFS</varname></term>
<listitem>
<para>The root of
<application>Poudriere</application>-managed file
systems. This entry will cause
<application>Poudriere</application> to create
&man.zfs.8; file systems under
<literal>tank/poudriere</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>BASEFS</varname></term>
<listitem>
<para>The root mount point for
<application>Poudriere</application> file systems. This
entry will cause <application>Poudriere</application> to
mount <literal>tank/poudriere</literal> to
<literal>/poudriere</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>DISTFILES_CACHE</varname></term>
<listitem>
<para>Defines where distfiles are stored. In this
example, <application>Poudriere</application> and the
host share the distfiles storage directory. This avoids
downloading tarballs which are already present on the
system.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>RESOLV_CONF</varname></term>
<listitem>
<para>Use the host <filename>/etc/resolv.conf</filename>
inside jails for <acronym>DNS</acronym>. This is needed
so jails can resolve the <acronym>URL</acronym>s of
distfiles when downloading. It is not needed when using
a proxy. Refer to the default configuration file for
proxy configuration.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>FREEBSD_HOST</varname></term>
<listitem>
<para>The <acronym>FTP</acronym>/<acronym>HTTP</acronym>
server to use when the jails are installed from &os;
releases and updated with &man.freebsd-update.8;.
Choose a server location which is close, for example if
the machine is located in Australia, use
<literal>ftp.au.freebsd.org</literal>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>SVN_HOST</varname></term>
<listitem>
<para>The server from where jails are installed and
updated when using
<application>Subversion</application>. Also used for
ports tree when not using &man.portsnap.8;. Again,
choose a nearby location. A list of official
<application>Subversion</application> mirrors can be
found in the <link
xlink:href="&url.books.handbook;/svn.html#svn-mirrors">&os;
Handbook <application>Subversion</application>
section</link>.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
<sect2 xml:id="testing-poudriere-create-jails">
<title>Creating <application>Poudriere</application>
Jails</title>
<para>Create the base jails which
<application>Poudriere</application> will use for
building:</para>
<screen>&prompt.root; <userinput>poudriere jail -c -j 111Ramd64 -v 11.1-RELEASE -a amd64</userinput></screen>
<para>Fetch a <literal>11.1-RELEASE</literal> for
<literal>amd64</literal> from the <acronym>FTP</acronym>
server given by <varname>FREEBSD_HOST</varname> in
<filename>poudriere.conf</filename>, create the zfs file
system <literal>tank/poudriere/jails/111Ramd64</literal>, mount
it on <filename>/poudriere/jails/111Ramd64</filename> and
extract the <literal>11.1-RELEASE</literal> tarballs into this
file system.</para>
<screen>&prompt.root; <userinput>poudriere jail -c -j 11i386 -v stable/11 -a i386 -m svn+https</userinput></screen>
<para>Create <literal>tank/poudriere/jails/11i386</literal>,
mount it on <filename>/poudriere/jails/11i386</filename>, then
check out the tip of the <application>Subversion</application>
branch of <literal>&os;-11-STABLE</literal> from
<literal>SVN_HOST</literal> in
<filename>poudriere.conf</filename> into
<filename>/poudriere/jails/11i386/usr/src</filename>, then
complete a <buildtarget>buildworld</buildtarget> and install
it into <filename>/poudriere/jails/11i386</filename>.</para>
<tip>
<para>If a specific <application>Subversion</application>
revision is needed, append it to the version string. For
example:</para>
<screen>&prompt.root; <userinput>poudriere jail -c -j 11i386 -v stable/11@123456 -a i386 -m svn+https</userinput></screen>
</tip>
<note>
<para>While it is possible to build a newer version of &os; on
an older version, most of the time it will not run. For
example, if a <literal>stable/11</literal> jail is needed,
the host will have to run <literal>stable/11</literal> too.
Running <literal>11.0-RELEASE</literal> is not
enough.</para>
</note>
<note>
<para>To create a <application>Poudriere</application> jail
for <literal>12.0-CURRENT</literal>:</para>
<screen>&prompt.root; <userinput>poudriere jail -c -j 12amd64 -v head -a amd64 -m svn+https</userinput></screen>
<para>In order to run a <literal>12.0-CURRENT</literal>
<application>Poudriere</application> jail you must be
running <literal>12.0-CURRENT</literal>. In general, newer
kernels can build and run older jails. For instance, a
<literal>12.0-CURRENT</literal> kernel can build and run a
<literal>11.1-STABLE</literal>
<application>Poudriere</application> jails if the
<literal>COMPAT_FREEBSD11</literal> kernel option was
compiled in (on by default in
<literal>12.0-CURRENT</literal>
<filename>GENERIC</filename> kernel config).</para>
</note>
<caution>
<para>The default <literal>svn</literal> protocol works but is
not very secure. Using <literal>svn+https</literal> along
with verifying the remote server's <acronym>SSL</acronym>
fingerprint is advised. It will ensure that the files used
for building the jail are from a trusted source.</para>
</caution>
<para>A list of jails currently known to
<application>Poudriere</application> can be shown with
<command>poudriere jail -l</command>:</para>
<screen>&prompt.root; <userinput>poudriere jail -l</userinput>
JAILNAME VERSION ARCH METHOD
111Ramd64 11.1-RELEASE amd64 ftp
11i386 11.0-STABLE i386 svn+https</screen>
</sect2>
<sect2 xml:id="testing-poudriere-maintaining-jails">
<title>Keeping <application>Poudriere</application> Jails
Updated</title>
<para>Managing updates is very straightforward. The
command:</para>
<screen>&prompt.root; <userinput>poudriere jail -u -j <replaceable>JAILNAME</replaceable></userinput></screen>
<para>updates the specified jail to the latest version
available. For &os; releases, update to the latest patchlevel
with &man.freebsd-update.8;. For &os; versions built from
source, update to the latest
<application>Subversion</application> revision in the
branch.</para>
<tip>
<para>For jails employing a
<literal>svn+<replaceable>*</replaceable></literal> method,
it is helpful to add <command>-J
<replaceable>NumberOfParallelBuildJobs</replaceable></command>
to speed up the build by increasing the number of parallel
compile jobs used. For example, if the building machine has
6 <acronym>CPU</acronym>s, use:</para>
<screen>&prompt.root; <userinput>poudriere jail -u -J 6 -j <replaceable>JAILNAME</replaceable></userinput></screen>
</tip>
</sect2>
<sect2 xml:id="testing-poudriere-ports-tree">
<title>Setting Up Ports Trees for Use with
<application>Poudriere</application></title>
<para>There are multiple ways to use ports trees in
<application>Poudriere</application>. The most
straightforward way is to have
<application>Poudriere</application> create a default ports
tree for itself:</para>
<screen>&prompt.root; <userinput>poudriere ports -c</userinput></screen>
<para>This command creates
<literal>tank/poudriere/ports/default</literal>, mount it on
<filename>/poudriere/ports/default</filename>, and populate it
using &man.portsnap.8;. Afterward it is included in the list
of known ports trees:</para>
<screen>&prompt.root; <userinput>poudriere ports -l</userinput>
PORTSTREE METHOD PATH
default portsnap /poudriere/ports/default</screen>
<note>
<para>Note that the <quote>default</quote> ports tree is
special. Each of the build commands explained later will
implicitly use this ports tree unless specifically specified
otherwise. To use another tree, add <command>-p
<replaceable>treename</replaceable></command> to the
commands.</para>
</note>
<para>While useful for regular bulk builds, having this default
ports tree with the &man.portsnap.8; method may not be the
best way to deal with local modifications for a ports
contributor. As with the creation of jails, it is possible to
use a different method for creating the ports tree. To add an
additional ports tree for testing local modifications and
ports development, checking out the tree via
<application>Subversion</application> is possible:</para>
<screen>&prompt.root; <userinput>poudriere ports -c -m svn+https -p subversive</userinput></screen>
<note>
<para>The <acronym>http</acronym> and <acronym>https</acronym>
methods need <package role="port">devel/subversion</package>
built with the <literal>SERF</literal> option enabled. It
is enabled by default.</para>
</note>
<para>Creates <literal>tank/poudriere/ports/subversive</literal>
and mounts it on
<filename>/poudriere/ports/subversive</filename>. It is then
populated using <application>Subversion</application>.
Finally, it is added to the list of known ports trees:</para>
<screen>&prompt.root; <userinput>poudriere ports -l</userinput>
PORTSTREE METHOD PATH
default portsnap /poudriere/ports/default
subversive svn+https /poudriere/ports/subversive</screen>
<tip>
<para>The <literal>svn</literal> method allows extra
qualifiers to tell <application>Subversion</application>
exactly how to fetch data. This is explained in
&man.poudriere.8;. For instance, <command>poudriere ports
-c -m svn+ssh -p subversive</command> uses
<application>SSH</application> for the checkout.</para>
</tip>
</sect2>
<sect2 xml:id="testing-poudriere-ports-tree-manual">
<title>Using Manually Managed Ports Trees with Poudriere</title>
<para>Depending on the workflow, it can be extremely helpful to
use ports trees which are maintained manually. For instance,
if there is a local copy of the ports tree in
<filename>/work/ports</filename>, point
<application>Poudriere</application> to the location:</para>
<screen>&prompt.root; <userinput>poudriere ports -c -F -f none -M /work/ports -p development</userinput></screen>
<para>This will be listed in the table of known trees:</para>
<screen>&prompt.root; <userinput>poudriere ports -l</userinput>
PORTSTREE METHOD PATH
development - /work/ports</screen>
<note>
<para>The dash in the <literal>METHOD</literal> column means
that <application>Poudriere</application> will not update or
change this ports tree, ever. It is completely up to the
user to maintain this tree, including all local
modifications that may be used for testing new ports and
submitting patches.</para>
</note>
</sect2>
<sect2 xml:id="testing-poudriere-ports-tree-updating">
<title>Keeping Poudriere Ports Trees Updated</title>
<para>As straightforward as with jails described earlier:</para>
<screen>&prompt.root; <userinput>poudriere ports -u -p <replaceable>PORTSTREE</replaceable></userinput></screen>
<para>Will update the given
<replaceable>PORTSTREE</replaceable>, one tree given by the
output of <command>poudriere -l</command>, to the latest
revision available on the official servers.</para>
<note>
<para>Ports trees without a method, see <xref
linkend="testing-poudriere-ports-tree-manual"/>, cannot be
updated like this. They must be updated manually by the
porter.</para>
</note>
</sect2>
<sect2 xml:id="testing-poudriere-testing-ports">
<title>Testing Ports</title>
<para>After jails and ports trees have been set up, the result
of a contributor's modifications to the ports tree can be
tested.</para>
<para>For example, local modifications to the <package
role="port">www/firefox</package> port located in
<filename>/work/ports/www/firefox</filename> can be tested in
the previously created 11.1-RELEASE jail:</para>
<screen>&prompt.root; <userinput>poudriere testport -j 111Ramd64 -p development -o www/firefox</userinput></screen>
<para>This will build all dependencies of
<application>Firefox</application>. If a dependency has been
built previously and is still up-to-date, the pre-built
package is installed. If a dependency has no up-to-date
package, one will be built with default options in a jail.
Then <application>Firefox</application> itself is
built.</para>
<para>The complete build of every port is logged to
<filename>/poudriere/data/logs/bulk/111Ri386-development/<replaceable>build-time</replaceable>/logs</filename>.</para>
<para>The directory name <literal>111Ri386-development</literal>
is derived from the arguments to <literal>-j</literal> and
<literal>-p</literal>, respectively. For convenience, a
symbolic link
<filename>/poudriere/data/logs/bulk/111Ri386-development/latest</filename>
is also maintained. The link points to the latest
<replaceable>build-time</replaceable> directory. Also in this
directory is an <filename>index.html</filename> for observing
the build process with a web browser.</para>
<para>By default, <application>Poudriere</application> cleans up
the jails and leaves log files in the directories mentioned
above. To ease investigation, jails can be kept running after
the build by adding <option>-i</option> to
<command>testport</command>:</para>
<screen>&prompt.root; <userinput>poudriere testport -j 111Ramd64 -p development -i -o www/firefox</userinput></screen>
<para>After the build completes, and regardless of whether it
was successful, a shell is provided within the jail. The
shell is used to investigate further.
<application>Poudriere</application> can be told to leave the
jail running after the build finishes with
<option>-I</option>. <application>Poudriere</application>
will show the command to run when the jail is no longer
needed. It is then possible to &man.jexec.8; into it:</para>
<screen>&prompt.root; <userinput>poudriere testport -j 111Ramd64 -p development -I -o www/firefox</userinput>
[...]
====>> Installing local Pkg repository to /usr/local/etc/pkg/repos
====>> Leaving jail 111Ramd64-development-n running, mounted at /poudriere/data/.m/111Ramd64-development/ref for interactive run testing
====>> To enter jail: jexec 111Ramd64-development-n env -i TERM=$TERM /usr/bin/login -fp root
====>> To stop jail: poudriere jail -k -j 111Ramd64 -p development
&prompt.root; <userinput>jexec 111Ramd64-development-n env -i TERM=$TERM /usr/bin/login -fp root</userinput>
&prompt.root; <userinput><replaceable>[do some stuff in the jail]</replaceable></userinput>
&prompt.root; <userinput>exit</userinput>
&prompt.root; <userinput>poudriere jail -k -j 111Ramd64 -p development</userinput>
====>> Umounting file systems</screen>
<para>An integral part of the &os; ports build infrastructure is
the ability to tweak ports to personal preferences with
options. These can be tested with
<application>Poudriere</application> as well. Adding the
<option>-c</option>:</para>
<screen>&prompt.root; <userinput>poudriere testport -c -o www/firefox</userinput></screen>
<para>Presents the port configuration dialog before the port is
built. The ports given after <option>-o</option> in the
format
<literal><replaceable>category</replaceable>/<replaceable>portname</replaceable></literal>
will use the specified options, all dependencies will use the
default options. Testing dependent ports with non-default
options can be accomplished using sets, see <xref
linkend="testing-poudriere-sets"/>.</para>
<tip>
<para>When testing ports where <filename>pkg-plist</filename>
is altered during build depending on the selected options,
it is recommended to perform a test run with all options
selected <emphasis>and</emphasis> one with all options
deselected.</para>
</tip>
</sect2>
<sect2 xml:id="testing-poudriere-sets">
<title>Using Sets</title>
<para>For all actions involving builds, a so-called
<emphasis>set</emphasis> can be specified using <literal>-z
<replaceable>setname</replaceable></literal>. A set refers
to a fully independent build. This allows, for instance,
usage of <command>testport</command> with non-standard options
for the dependent ports.</para>
<para>To use sets, <application>Poudriere</application> expects
an existing directory structure similar to
<varname>PORT_DBDIR</varname>, defaults to
<filename>/var/db/ports</filename> in its configuration
directory. This directory is then &man.nullfs.5;-mounted into the
jails where the ports and their dependencies are built.
Usually a suitable starting point can be obtained by
recursively copying the existing <varname>PORT_DBDIR</varname>
to
<filename>/usr/local/etc/poudriere.d/<replaceable>jailname</replaceable>-<replaceable>portname</replaceable>-<replaceable>setname</replaceable>-options</filename>.
This is described in detail in &man.poudriere.8;. For
instance, testing <package role="port">www/firefox</package>
in a specific set named <literal>devset</literal>, add the
<literal>-z devset</literal> parameter to the testport
command:</para>
<screen>&prompt.root; <userinput>poudriere testport -j 111Ramd64 -p development -z devset -o www/firefox</userinput></screen>
<para>This will look for the existence of these directories in
this order:</para>
<itemizedlist>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-development-devset-options</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-devset-options</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-development-options</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/devset-options</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/development-options</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-options</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/options</filename></para>
</listitem>
</itemizedlist>
<para>From this list, <application>Poudriere</application>
&man.nullfs.5;-mounts the <emphasis>first existing</emphasis>
directory tree into the <filename>/var/db/ports</filename>
directory of the build jails. Hence, all custom options are
used for all the ports during this run of
<command>testport</command>.</para>
<para>After the directory structure for a set is provided, the
options for a particular port can be altered. For
example:</para>
<screen>&prompt.root; <userinput>poudriere options -c www/firefox -z devset</userinput></screen>
<para>The configuration dialog for <package
role="port">www/firefox</package> is shown, and options can
be edited. The selected options are saved to the
<literal>devset</literal> set.</para>
<note>
<para><application>Poudriere</application> is very flexible in
the option configuration. They can be set for particular
jails, ports trees, and for multiple ports by one command.
Refer to &man.poudriere.8; for details.</para>
</note>
</sect2>
<sect2 xml:id="testing-poudriere-make-conf">
<title>Providing a Custom <filename>make.conf</filename>
File</title>
<para>Similar to using sets,
<application>Poudriere</application> will also use a custom
<filename>make.conf</filename> if it is provided. No special
command line argument is necessary. Instead,
<application>Poudriere</application> looks for existing files
matching a name scheme derived from the command line. For
instance:</para>
<screen>&prompt.root; <userinput>poudriere testport -j 111Ramd64 -p development -z devset -o www/firefox</userinput></screen>
<para>causes <application>Poudriere</application> to check for
the existence of these files in this order:</para>
<itemizedlist>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/make.conf</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/devset-make.conf</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/development-make.conf</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-make.conf</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-development-make.conf</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-devset-make.conf</filename></para>
</listitem>
<listitem>
<para><filename>/usr/local/etc/poudriere.d/111Ramd64-development-devset-make.conf</filename></para>
</listitem>
</itemizedlist>
<para>Unlike with sets, all of the found files will be appended,
<emphasis>in that order</emphasis>, into one
<filename>make.conf</filename> inside the build jails. It is
hence possible to have general make variables, intended to
affect all builds in
<filename>/usr/local/etc/poudriere.d/make.conf</filename>.
Special variables, intended to affect only certain jails or
sets can be set in specialised <filename>make.conf</filename>
files, such as
<filename>/usr/local/etc/poudriere.d/111Ramd64-development-devset-make.conf</filename>.</para>
<example xml:id="testing-poudriere-sets-perl">
<title>Using <filename>make.conf</filename> to Change Default
<application>Perl</application></title>
<para>To build a set with a non default
<application>Perl</application> version, for example,
<literal>5.20</literal>, using a set named
<literal>perl5-20</literal>, create a
<filename>perl5-20-make.conf</filename> with this
line:</para>
<programlisting>DEFAULT_VERSIONS+= perl=5.20</programlisting>
<note>
<para>Note the use of <literal>+=</literal> so that if the
variable is already set in the default
<filename>make.conf</filename> its content will not be
overwritten.</para>
</note>
</example>
</sect2>
<sect2 xml:id="testing-poudriere-pruning-distfiles">
<title>Pruning no Longer Needed Distfiles</title>
<para><application>Poudriere</application> comes with a built-in
mechanism to remove outdated distfiles that are no longer used
by any port of a given tree. The command</para>
<screen>&prompt.root; <userinput>poudriere distclean -p <replaceable>portstree</replaceable></userinput></screen>
<para>will scan the distfiles folder,
<varname>DISTFILES_CACHE</varname> in
<filename>poudriere.conf</filename>, versus the ports tree
given by the <literal>-p
<replaceable>portstree</replaceable></literal> argument and
prompt for removal of those distfiles. To skip the prompt and
remove all unused files unconditionally, the
<literal>-y</literal> argument can be added:</para>
<screen>&prompt.root; <userinput>poudriere distclean -p <replaceable>portstree</replaceable> -y</userinput></screen>
</sect2>
<!--
Tricks
TODO
- ZFS clones for ports tree modifications during builds
-->
</sect1>
<sect1 xml:id="testing-tinderbox">
<title>Tinderbox</title>
<para>As an avid ports contributor, take
a look at <application>Tinderbox</application>. It is a
powerful system for building and testing ports. Install
<application>Tinderbox</application> using
<package role="port">ports-mgmt/tinderbox</package> port. Be
sure to read supplied documentation since the configuration is
not trivial.</para>
<para>Visit the
<link xlink:href="http://tinderbox.marcuscom.com/">Tinderbox
website</link> for more details.</para>
</sect1>
</chapter>
|