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