xref: /openbsd-src/share/man/man7/ports.7 (revision 46035553bfdd96e63c94e32da0210227ec2e3cf1)
1.\"
2.\" Copyright (c) 1997 David E. O'Brien
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $OpenBSD: ports.7,v 1.128 2020/04/28 13:11:32 espie Exp $
27.\" $FreeBSD: ports.7,v 1.7 1998/06/23 04:38:50 hoek Exp $
28.\"
29.Dd $Mdocdate: April 28 2020 $
30.Dt PORTS 7
31.Os
32.Sh NAME
33.Nm ports
34.Nd contributed applications
35.Sh DESCRIPTION
36The
37.Ox
38Ports Collection
39is the infrastructure used to create binary packages for third party
40applications.
41.Pp
42For normal usage refer to
43.Xr packages 7 ,
44as most ports produce binary packages which are available from
45the official HTTP mirrors.
46.Pp
47Each port contains any patches necessary to make the original
48application source code compile and run on
49.Ox .
50Compiling an application is as simple as typing
51.Ic make
52in the port directory!
53The
54.Pa Makefile
55automatically fetches the
56application source code, either from a local disk or via HTTP, unpacks it
57on the local system, applies the patches, and compiles it.
58If all goes well, simply type
59.Ic doas make install
60to install the application.
61.Pp
62For more information about using ports, see
63.Lk https://www.openbsd.org/faq/ports/ports.html "Working with Ports" .
64For information about creating new ports, see
65.Lk https://www.openbsd.org/faq/ports/ "The OpenBSD Porter's Handbook" .
66.Pp
67For a detailed description of the build process, see
68.Xr bsd.port.mk 5 .
69.Sh PORTS MASTER MAKEFILE
70The ports master Makefile, normally located in
71.Pa /usr/ports/Makefile
72(but see
73.Ev PORTSDIR
74below)
75offers a few useful targets.
76.Bl -tag -width configure
77.It Cm print-index
78display the contents of the index in a user-friendly way,
79.It Cm search
80invoked with a key, e.g.,
81.Ic make search key=foo ,
82retrieve information relevant to a given port (obsolescent).
83.El
84.Pp
85Starting in
86.Ox 4.0 ,
87there is a port,
88.Pa databases/sqlports
89that builds an sqlite database containing most information relevant to
90every port in the ports tree.
91This database can be searched using any tool able to manipulate such
92databases, for instance sqlitebrowser, or a script language with an
93sqlite interface, e.g., perl, python, ocaml, lua, php.
94.Pp
95All static index generating information has now been superseded by the
96.Pa sqlports ,
97.Pa portslist
98or
99.Pa pkglocatedb
100packages, which contain
101similar information to the old INDEX file, but are more frequently updated.
102.Sh SELECTING A SET OF PORTS
103One can define
104.Ev SUBDIRLIST
105to point to a file that contains a list of
106.Ev FULLPKGPATHs ,
107one per line, to build stuff only in some directories.
108.Pp
109If
110.Pa portslist
111is up to date, it is possible to select subsets by setting the following
112variables on the command line:
113.Bl -tag -width category
114.It Va key
115package name matching the given key,
116.It Va category
117port belonging to category,
118.It Va maintainer
119port maintained by a given person.
120.El
121.Pp
122For instance, to invoke
123.Cm clean
124on all ports in the x11 category, one can say:
125.Bd -literal -offset indent
126$ make category=x11 clean
127.Ed
128.Pp
129The index search is done by a perl script, so all regular expressions from
130.Xr perlre 1
131apply.
132.Sh TARGETS
133Individual ports are controlled through a few documented targets.
134Some of these targets work recursively through subdirectories, so that
135someone can, for example, install all of the net
136ports.
137.Pp
138The variable
139.Ev SKIPDIR
140can hold a set of package directories to avoid during recursion.
141These are always specified relative to the root of the ports tree,
142and can contain a flavor or subpackage part
143.Po
144see
145.Xr packages-specs 7
146.Pc .
147.Ev SKIPDIR
148is handled by a
149.Ic case
150statement, and so can contain simple wildcards
151.Po
152see
153.Xr sh 1
154.Dq File name patterns
155.Pc ,
156e.g., SKIPDIR='editors/openoffice*'.
157.Pp
158The variable
159.Ev STARTDIR
160can hold the path to a starting directory.
161The recursion will skip all directories up to that package path.
162This can be used to resume a full build at some specific point without having
163to go through thousands of directories first.
164.Pp
165The variable
166.Ev STARTAFTER
167can hold the path to a starting directory.
168The recursion will skip all directories up to and including that package path.
169This can be used to resume a full build after some specific point without having
170to go through thousands of directories first.
171.Pp
172In case of failure in a subdirectory, the shell fragment held in
173.Ev REPORT_PROBLEM
174is executed.
175Default behavior is to call exit, but this can be overridden on the command
176line, e.g., to avoid stopping after each problem.
177.Bd -literal -offset indent
178$ make REPORT_PROBLEM=true
179.Ed
180.Pp
181If
182.Ev REPORT_PROBLEM_LOGFILE
183is non empty, then
184.Ev REPORT_PROBLEM
185will default to:
186.Bd -literal -offset indent
187echo $$subdir ($@) >>$${REPORT_PROBLEM_LOGFILE}
188.Ed
189.Pp
190That is, any failure will append the faulty directory name together
191with the target that failed to
192.Pa ${REPORT_PROBLEM_LOGFILE}
193and proceed.
194.Pp
195Some targets that do this are
196.Cm all , build , checksum , clean ,
197.Cm configure , extract , fake ,
198.Cm fetch , install , distclean ,
199.Cm deinstall , reinstall , package , prepare ,
200.Cm link-categories , unlink-categories ,
201.Cm describe , show , regress ,
202.Cm lib-depends-check , homepage-links , manpages-check ,
203.Cm license-check , all-dir-depends , build-dir-depends ,
204.Cm run-dir-depends
205and
206.Cm readmes .
207.Pp
208Target names starting with
209.Sq _
210are private to the ports infrastructure,
211should not be invoked directly, and are liable to change without notice.
212.Pp
213In the following list, each target will run the preceding targets
214in order automatically.
215That is,
216.Cm build
217will be run
218.Pq if necessary
219by
220.Cm install ,
221and so on all the way to
222.Cm fetch .
223In typical use, one will only run
224.Cm install
225explicitly (as normal user, with
226.Ev SUDO
227defined in
228.Pa /etc/mk.conf ) ,
229or
230.Cm build
231(as user), then
232.Cm install
233(as root).
234.Bl -tag -width configure
235.It Cm fetch
236Fetch all of the files needed to build this port from the site(s)
237listed in
238.Ev MASTER_SITES .
239See
240.Ev FETCH_CMD .
241Use
242.Xr dpb 1
243with option
244.Fl F
245to quickly fetch distfiles for a subtree.
246.It Cm checksum
247Verify that the fetched distfile matches the one the port was tested against.
248Defining
249.Ev NO_CHECKSUM
250to
251.Dv Yes
252will skip this step.
253Sometimes, distfiles change without warning.
254The main
255.Ox
256mirror should still hold a copy of old distfiles, indexed by checksum.
257Using
258.Bd -literal -offset indent
259$ make checksum REFETCH=true
260.Ed
261.Pp
262will try to get a set of distfiles that match the recorded checksum.
263.It Cm prepare
264Install
265any build dependencies of the current port.
266Defining
267.Ev NO_DEPENDS
268to
269.Dv Yes
270will skip this step.
271.It Cm extract
272Expand the distfile into a work directory.
273.It Cm patch
274Apply any patches that are necessary for the port.
275.It Cm gen
276Recreate configure machinery if needed, mainly used by GNU based software
277that wants autogen/autoconf/automake.
278.It Cm configure
279Configure the port.
280Some ports will ask questions during this stage.
281See
282.Ev INTERACTIVE
283and
284.Ev BATCH .
285.It Cm build
286Build the port.
287This is the same as calling the
288.Cm all
289target.
290.It Cm fake
291Pretend to install the port under a subdirectory of the work directory.
292.It Cm generate-readmes
293Create READMEs and rc scripts under the fake subdirectory.
294.It Cm package
295Create a binary package from the fake installation.
296The package is a .tgz file that can be used to
297install the port with
298.Xr pkg_add 1 .
299.It Cm install
300Install the resulting package.
301.El
302.Pp
303The following targets are not run during the normal install process
304.Po
305exception
306.Cm clean
307is run for dependencies with the default settings of
308.Ev BULK Ns = Ns Dv Auto
309.Pc .
310.Bl -tag -width fetch-list
311.It Cm print-build-depends , print-run-depends
312Print an ordered list of all the compile and run dependencies.
313.It Cm clean
314Remove the expanded source code.
315This does not recurse to dependencies unless
316.Ev CLEANDEPENDS
317is defined to
318.Dv Yes .
319.It Cm distclean
320Remove the port's distfile(s).
321This does not recurse to dependencies.
322.It Cm regress
323Runs the ports regression tests.
324Usually needs a completed build.
325.It Cm reinstall
326Use this to restore a port after using
327.Xr pkg_delete 1 .
328.It Cm update
329Alternative target to
330.Cm install .
331Does not install new packages, but updates existing ones.
332.It Cm link-categories
333Populate the ports tree with symbolic links for each category the port
334belongs to.
335.It Cm unlink-categories
336Remove the symbolic links created by
337.Cm link-categories .
338.It Cm homepage-links
339creates an html list of links for each port
340.Ev HOMEPAGE .
341.El
342.Sh LOCK INFRASTRUCTURE
343The ports tree can be used concurrently for building several ports at the
344same time, thanks to a locking mechanism.
345By default, locks are stored under
346.Pa /tmp/portslocks .
347Defining
348.Ev LOCKDIR
349will point them elsewhere, or disable the mechanism if set to an empty value.
350.Pp
351All locks will be stored in
352.Pa ${LOCKDIR} .
353.Ev LOCK_CMD
354should be used to acquire a lock, and
355.Ev UNLOCK_CMD
356should be used to release it.
357.Pp
358Locks are named
359.Pa ${LOCKDIR}/${FULLPKGNAME}.lock ,
360or
361.Pa ${LOCKDIR}/${DISTFILE}.lock
362for distfiles fetching.
363.Pp
364The default values of
365.Ev LOCK_CMD
366and
367.Ev UNLOCK_CMD
368are appropriate for most uses.
369.Pp
370The locking protocol follows a big-lock model: each top-level target
371in a port directory will acquire the corresponding lock, complete its job,
372then release the lock, e.g., running
373.Bd -literal -offset indent
374$ make build
375.Ed
376.Pp
377will acquire the lock, run the port
378through
379.Cm fetch ,
380.Cm checksum ,
381.Cm extract ,
382.Cm patch ,
383.Cm configure ,
384.Cm build ,
385then release the lock.
386If dependencies are involved, they will invoke top-level targets in other
387directories, and thus acquire some other locks as well.
388.Pp
389The infrastructure contains some protection against acquiring the same lock
390twice, thus recursive locking is not needed for
391.Ev LOCK_CMD .
392.Pp
393Starting with
394.Ox 4.3 ,
395the infrastructure supports manual locking: the targets
396.Cm lock
397and
398.Cm unlock
399can be used to acquire and release individual locks.
400Both these targets output a shell command that must be used to update
401environment variables.
402Manual locking can be used to protect a directory against interference
403by an automated build job, while the user is looking at or modifying a
404given port.
405.Sh UPDATING PACKAGES
406Instead of deinstalling each package and rebuilding from scratch, the
407ports tree can be used to update installed packages.
408The
409.Cm update
410target will replace an installed package using
411.Xr pkg_add 1
412in replacement mode.
413If
414.Ev FORCE_UPDATE
415is set to
416.Dv Yes ,
417dependencies will also be updated first, and packages will always be updated,
418even if there is no difference between the old and the new packages.
419.Pp
420Updates use a mechanism similar to bulk cookies and deposit cookies in
421the
422.Ev UPDATE_COOKIES_DIR .
423See the next section for more details, since most of the fine points of
424bulk package building also apply to updates.
425.Pp
426There are bugs in the ports tree, most related to libtool, which make some
427updates prefer the already installed libraries instead of the newly built
428ones.
429This shows up as undefined references in libraries, in which case there
430is no choice but to proceed the old way: deinstall the offending package
431and everything built on top of it, build and install new packages.
432.Sh BULK PACKAGE BUILDING
433Building any significant number of packages from the ports tree should use
434.Xr dpb 1 ,
435a tool located inside the ports tree proper
436.Po
437normally as
438.Pa /usr/ports/infrastructure/bin/dpb
439.Pc .
440In particular, it can take advantage of machine clusters (same architecture
441and same installation), and of multi-core machines.
442.Pp
443For more detailed information, see
444.Xr bulk 8 .
445.Sh FLAVORS
446The
447.Ox
448ports tree comes with a mechanism called
449.Ic FLAVORS .
450Thanks to this mechanism, users can select specific options provided by
451a given port.
452.Pp
453If a port is
454.Qq flavored ,
455there should be a terse description of available flavors in the
456.Pa pkg/DESCR
457file.
458.Pp
459For example, the
460.Pa misc/screen
461port comes with a flavor called
462.Ic static .
463This changes the building process so a statically compiled version of
464the program will be built.
465To avoid confusion with other packages or flavors,
466the package name will be extended with a dash-separated list of
467the selected flavors.
468.Pp
469In this instance, the corresponding package will be called
470.Ic screen-4.0.2-static .
471.Pp
472To see the flavors of a port, use the
473.Cm show
474target:
475.Bd -literal -offset indent
476$ make show=FLAVORS
477.Ed
478.Pp
479To build a port with a specific flavor, just pass
480.Ev FLAVOR
481in the environment of the
482.Xr make 1
483command:
484.Bd -literal -offset indent
485$ env FLAVOR="static" make package
486.Ed
487.Pp
488and of course, use the same settings for the subsequent invocations of make:
489.Bd -literal -offset indent
490$ env FLAVOR="static" make install
491$ env FLAVOR="static" make clean
492.Ed
493.Pp
494More than one flavor may be specified:
495.Bd -literal -offset indent
496$ cd /usr/ports/mail/exim
497$ env FLAVOR="mysql ldap" make package
498.Ed
499.Pp
500Specifying a flavor that does not exist is an error.
501Additionally, some ports impose some further restrictions on flavor
502combinations, when such combinations do not make sense.
503.Pp
504Lots of ports can be built without X11 requirement and accordingly
505have a
506.Ic no_x11
507flavor.
508.Pp
509Flavor settings are not propagated to dependencies.
510If a specific combination is needed, careful hand-building of the
511required set of packages is still necessary.
512.Sh MULTI_PACKAGES
513The
514.Ox
515ports tree comes with a mechanism called
516.Ic MULTI_PACKAGES .
517This mechanism is used when a larger package is broken down into
518several smaller components referred to as subpackages.
519.Pp
520If a port is
521.Qq subpackaged ,
522each subpackage will have a corresponding description in the
523.Pa pkg/DESCR-subpackage
524file.
525.Pp
526For example, the
527.Pa databases/mariadb
528port comes with subpackages called
529.Ic -main ,
530.Ic -tests
531and
532.Ic -server .
533.Pp
534In this instance, the build will yield multiple packages, one
535corresponding to each subpackage.
536In the case of our mariadb example,
537the packages will be called
538.Ic mariadb-client-<version> ,
539.Ic mariadb-tests-<version> ,
540and
541.Ic mariadb-server-<version> .
542.Pp
543To install/deinstall a specific subpackage of a port, you may
544.Xr pkg_add 1
545them manually, or alternatively, you may set
546.Ev SUBPACKAGE
547in the environment of the
548.Xr make 1
549command during the install/deinstall phase:
550.Bd -literal -offset indent
551$ env SUBPACKAGE="-server" make install
552$ env SUBPACKAGE="-server" make deinstall
553.Ed
554.Sh PORT VARIABLES
555These can be changed in the environment, or in
556.Pa /etc/mk.conf
557for persistence.
558They can also be set on make's command line, e.g.,
559.Ic make VAR_FOO Ns = Ns Dv foo
560.Pp
561Boolean variables should be set to
562.Dv Yes
563instead of simply being defined, for uniformity and future compatibility.
564.Pp
565Variable names starting with
566.Sq _
567are private to the ports infrastructure,
568should not be changed by the user, and are liable to change without notice.
569.Bl -tag -width MASTER_SITES
570.It Ev PORTS_PRIVSEP
571If set to
572.Sq Yes ,
573all operations will happen as restricted users
574.Ar _pfetch
575and
576.Ar _pbuild .
577.It Ev PORTSDIR
578Location of the ports tree
579(usually
580.Pa /usr/ports ) .
581.It Ev DISTDIR
582Where to find/put distfiles, normally
583.Pa ${PORTSDIR}/distfiles .
584.It Ev PACKAGE_REPOSITORY
585Used only for the
586.Cm package
587target; the base directory for the packages tree, normally
588.Pa ${PORTSDIR}/packages .
589If this directory exists, the package tree will be (partially) constructed.
590.It Ev BULK_COOKIES_DIR
591During bulk package building, used to store cookies for already built
592packages to avoid rebuilding them, since the actual
593working directory will already have been cleaned out.
594Defaults to
595.Pa ${PORTSDIR}/bulk/${MACHINE_ARCH} .
596.It Ev UPDATE_COOKIES_DIR
597Used to store cookies for package updates, defaults to
598.Pa ${PORTSDIR}/update/${MACHINE_ARCH} .
599If set to empty, it will revert to a file under
600.Pa ${WRKDIR} .
601.It Ev LOCALBASE
602Where to install things in general
603(usually
604.Pa /usr/local ) .
605.It Ev MASTER_SITES
606Primary sites for distribution files if not found locally.
607.It Ev CLEANDEPENDS
608If set to
609.Dv Yes ,
610let
611.Cm clean
612recurse to dependencies.
613.It Ev FETCH_CMD
614Command to use to fetch files.
615Normally
616.Xr ftp 1 .
617.It Ev FETCH_PACKAGES
618If set,
619try to use as options to
620.Xr pkg_add 1
621to install missing packages from
622.Ev PKG_PATH .
623.Xr bsd.port.mk 5
624does not set
625.Ev FETCH_PACKAGES ,
626so even an empty value amounts to setting the variable.
627.Pp
628For instance, to run
629.Xr pkg_add 1
630with default options :
631.Bd -literal -offset indent
632make FETCH_PACKAGES=
633.Ed
634.Pp
635or, to use the snapshots directory during the final beta period:
636.Bd -literal -offset indent
637make FETCH_PACKAGES=-Dsnap
638.Ed
639.It Ev PATCH_DEBUG
640If defined, display verbose output when applying each patch.
641.It Ev INTERACTIVE
642If defined, only operate on a port if it requires interaction.
643.It Ev BATCH
644If defined, only operate on a port if it can be installed 100% automatically.
645.El
646.Sh USING A READ-ONLY PORTS TREE
647Select read-write partition(s) that can accommodate working directories, the
648distfiles repository, and the built packages.
649Set
650.Ev WRKOBJDIR ,
651.Ev PACKAGE_REPOSITORY ,
652.Ev BULK_COOKIES_DIR ,
653.Ev UPDATE_COOKIES_DIR ,
654.Ev DISTDIR ,
655and
656.Ev PLIST_REPOSITORY
657in
658.Pa /etc/mk.conf
659accordingly.
660.Sh FILES
661.Bl -tag -width /usr/ports/xxxxxxxx -compact
662.It Pa /usr/ports
663The default ports directory.
664.It Pa /usr/ports/Makefile
665Ports master Makefile.
666.It Pa /usr/local/share/ports-INDEX
667Ports index, part of the
668.Pa portlist
669package.
670.It Pa /usr/ports/pobj
671Build directories.
672A number of insecurely coded ports require a dedicated file system with the
673.Cm wxallowed
674.Xr mount 8
675option.
676.It Pa /usr/ports/infrastructure/mk/bsd.port.mk
677The ports main engine.
678.It Pa /usr/ports/infrastructure/db/network.conf
679Network configuration.
680.It Pa /usr/ports/infrastructure/db/user.list
681List of users and groups created by ports.
682.El
683.Sh SEE ALSO
684.Xr dpb 1 ,
685.Xr make 1 ,
686.Xr pkg_add 1 ,
687.Xr pkg_create 1 ,
688.Xr pkg_delete 1 ,
689.Xr pkg_info 1 ,
690.Xr bsd.port.mk 5 ,
691.Xr port-modules 5 ,
692.Xr mirroring-ports 7 ,
693.Xr packages 7
694.Pp
695The
696.Ox
697Ports System:
698.Lk https://www.openbsd.org/faq/ports/ports.html
699.Pp
700The
701.Ox
702Porter's Handbook:
703.Lk https://www.openbsd.org/faq/ports/
704.Sh HISTORY
705.Nm The Ports Collection
706appeared in
707.Fx 1.0 .
708It was introduced in
709.Ox
710by Ejovi Nuwere, with much initial effort by Angelos D. Keromytis.
711Maintenance passed then to Marco S. Hyman, and then to Christopher Turan.
712It is currently managed by Marc Espie, Christian Weisgerber,
713along with a host of others found at
714.Mt ports@openbsd.org .
715.Sh AUTHORS
716This man page was originated by
717.An David O'Brien ,
718from the
719.Fx
720project.
721