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