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.85 2011/07/03 15:25:10 schwarze Exp $ 27.\" $FreeBSD: ports.7,v 1.7 1998/06/23 04:38:50 hoek Exp $ 28.\" 29.Dd $Mdocdate: July 3 2011 $ 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 197The 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 , 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 depends 261Install 262.Pq or package if only compilation is necessary 263any dependencies of the current port. 264When called by the 265.Ar extract , install 266or 267.Ar fetch 268targets, this is run in scattered pieces as 269.Ar lib-depends , build-depends 270and 271.Ar run-depends . 272Defining 273.Ev NO_DEPENDS 274to 275.Dv Yes 276will skip this step. 277.It Ar extract 278Expand the distfile into a work directory. 279.It Ar patch 280Apply any patches that are necessary for the port. 281.It Ar configure 282Configure the port. 283Some ports will ask questions during this stage. 284See 285.Ev INTERACTIVE 286and 287.Ev BATCH . 288.It Ar build 289Build the port. 290This is the same as calling the 291.Ar all 292target. 293.It Ar fake 294Pretend to install the port under a subdirectory of the work directory. 295.It Ar package 296Create a binary package from the fake installation. 297The package is a .tgz file that can be used to 298install the port on several machines with 299.Xr pkg_add 1 . 300.It Ar install 301Install the resulting package. 302.El 303.Pp 304The following targets are not run during the normal install process. 305.Bl -tag -width fetch-list 306.It Ar print-build-depends print-run-depends 307Print an ordered list of all the compile and run dependencies. 308.It Ar clean 309Remove the expanded source code. 310This does not recurse to dependencies unless 311.Ev CLEANDEPENDS 312is defined to 313.Dv Yes . 314.It Ar distclean 315Remove the port's distfile(s). 316This does not recurse to dependencies. 317.It Ar regress 318Runs the ports regression tests. 319Usually needs a completed build. 320.It Ar reinstall 321Use this to restore a port after using 322.Xr pkg_delete 1 . 323.It Ar update 324Alternative target to 325.Ar install . 326Does not install new packages, but updates existing ones. 327.It Ar link-categories 328Populate the ports tree with symbolic links for each category the port 329belongs to. 330.It Ar unlink-categories 331Remove the symbolic links created by 332.Ar link-categories . 333.El 334.Sh LOCK INFRASTRUCTURE 335The ports tree can be used concurrently for building several ports at the 336same time, thanks to a locking mechanism. 337By default, locks are stored under 338.Pa /tmp/portslocks . 339Defining 340.Ev LOCKDIR 341will point them elsewhere, or disable the mechanism if set to an empty value. 342.Pp 343All locks will be stored in 344.Pa ${LOCKDIR} . 345.Ev LOCK_CMD 346should be used to acquire a lock, and 347.Ev UNLOCK_CMD 348should be used to release it. 349.Pp 350Locks are named ${LOCKDIR}/${FULLPKGNAME}.lock, 351or ${LOCKDIR}/${DISTFILE}.lock for distfiles fetching. 352.Pp 353The default values of 354.Ev LOCK_CMD 355and 356.Ev UNLOCK_CMD 357are appropriate for most uses. 358.Pp 359The locking protocol follows a big-lock model: each top-level target 360in a port directory will acquire the corresponding lock, complete its job, 361then release the lock, e.g., running 362.Bd -literal -offset indent 363$ make build 364.Ed 365.Pp 366will acquire the lock, run the port 367through 368.Ar fetch , 369.Ar checksum , 370.Ar extract , 371.Ar patch , 372.Ar configure , 373.Ar build , 374then release the lock. 375If dependencies are involved, they will invoke top-level targets in other 376directories, and thus acquire some other locks as well. 377.Pp 378The infrastructure contains some protection against acquiring the same lock 379twice, thus recursive locking is not needed for 380.Ev LOCK_CMD . 381.Pp 382Starting with 383.Ox 4.3 , 384the infrastructure supports manual locking: the targets 385.Ar lock 386and 387.Ar unlock 388can be used to acquire and release individual locks. 389Both these targets output a shell command that must be used to update 390environment variables. 391Manual locking can be used to protect a directory against interference 392by an automated build job, while the user is looking at or modifying a 393given port. 394.Sh UPDATING PACKAGES 395Instead of deinstalling each package and rebuilding from scratch, the 396ports tree can be used to update installed packages. 397The 398.Ar update 399target will replace an installed package using 400.Xr pkg_add 1 401in replacement mode. 402If 403.Ev FORCE_UPDATE 404is set to 405.Sq Yes , 406dependencies will also be updated first, and packages will always be updated, 407even if there is no difference between the old and the new packages. 408.Pp 409Updates use a mechanism similar to bulk cookies and deposit cookies in 410the 411.Ev UPDATE_COOKIES_DIR . 412See the next section for more details, since most of the fine points of 413bulk package building also apply to updates. 414.Pp 415There are bugs in the ports tree, most related to libtool, which make some 416updates prefer the already installed libraries instead of the newly built 417ones. 418This shows up as undefined references in libraries, in which case there 419is no choice but to proceed the old way: deinstall the offending package 420and everything built on top of it, build and install new packages. 421.Sh BULK PACKAGE BUILDING 422The ports tree contains some mechanisms to save space when building 423large collections of packages. 424If 425.Ev TRUST_PACKAGES 426and 427.Ev BULK 428are set to 429.Sq Yes 430for a package build, some shortcuts are taken to allow cleaning up working 431directories on the fly. 432.Pp 433Some important caveats apply: 434the packages already built in the package repository are assumed to be 435up-to-date, the database of installed packages is assumed 436to be accurate (TRUST_PACKAGES), and the bulk cookies are assumed to be 437up-to-date (BULK). 438.Pp 439This means that newer iterations of package buildings should make sure 440those conditions are met, which entails erasing old package repository, 441removing packages that need to be rebuilt from the base of installed 442packages, and cleaning up old bulk cookies. 443.Pp 444If any of these conditions is not met, the package build may run into weird 445problems. 446.Pp 447Some experimental framework allows for building a new set of packages 448without first uninstalling the old ones: move the old packages away, 449remove all bulk cookies and update cookies, and use the 450.Ar update 451target with 452.Ev FORCE_UPDATE 453set to 454.Sq Yes 455for the build. 456.Sh NETWORK CONFIGURATION 457The variables pertaining to network access have been marshalled into 458.Pa ${PORTSDIR}/infrastructure/templates/network.conf.template . 459.Pp 460To customize that setup, copy that file into 461.Pa ${PORTSDIR}/infrastructure/db/network.conf 462and edit it. 463.Bl -tag -width MASTER_SITES 464.It Ev MASTER_SITE_OPENBSD 465If set to 466.Dv Yes , 467include the master 468.Ox 469site when fetching files. 470.It Ev MASTER_SITE_FREEBSD 471If set to 472.Dv Yes , 473include the master 474.Fx 475site when fetching files. 476.It Ev MASTER_SITE_OVERRIDE 477Go to this site first for all files. 478.El 479.Sh FLAVORS 480The 481.Ox 482ports tree comes with a mechanism called 483.Ic FLAVORS . 484Thanks to this mechanism, users can select specific options provided by 485a given port. 486.Pp 487If a port is "flavored", there should be a terse description of 488available flavors in the 489.Pa pkg/DESCR 490file. 491.Pp 492For example, the misc/screen port comes with a flavor called 493.Ic static . 494This changes the building process so a statically compiled version of 495the program will be built. 496To avoid confusion with other packages or flavors, 497the package name will be extended with a dash-separated list of 498the selected flavors. 499.Pp 500In this instance, the corresponding package will be called 501.Ic screen-4.0.2-static . 502.Pp 503To build a port with a specific flavor, just pass 504.Ev FLAVOR 505in the environment of the 506.Xr make 1 507command: 508.Bd -literal -offset indent 509$ env FLAVOR="static" make package 510.Ed 511.Pp 512and of course, use the same settings for the subsequent invocations of make: 513.Bd -literal -offset indent 514$ env FLAVOR="static" make install 515$ env FLAVOR="static" make clean 516.Ed 517.Pp 518More than one flavor may be specified: 519.Bd -literal -offset indent 520$ cd /usr/ports/mail/exim 521$ env FLAVOR="mysql ldap" make package 522.Ed 523.Pp 524Specifying a flavor that does not exist is an error. 525Additionally, some ports impose some further restrictions on flavor 526combinations, when such combinations do not make sense. 527.Pp 528Lots of ports can be built without X11 requirement and accordingly 529have a 530.Ic no_x11 531flavor. 532.Pp 533Flavor settings are not propagated to dependencies. 534If a specific combination is needed, careful hand-building of the 535required set of packages is still necessary. 536.Sh MULTI_PACKAGES 537The 538.Ox 539ports tree comes with a mechanism called 540.Ic MULTI_PACKAGES . 541This mechanism is used when a larger package is broken down into 542several smaller components referred to as subpackages. 543.Pp 544If a port is "subpackaged", each subpackage will have 545a corresponding description in the 546.Pa pkg/DESCR-subpackage 547file. 548.Pp 549For example, the database/mysql port comes with subpackages called 550.Ic -main , 551.Ic -tests 552and 553.Ic -server . 554.Pp 555In this instance, the build will yield multiple packages, one 556corresponding to each subpackage. 557In the case of our mysql example, 558the packages will be called 559.Ic mysql-client-<version> , 560.Ic mysql-tests-<version> , 561and 562.Ic mysql-server-<version> . 563.Pp 564To install/deinstall a specific subpackage of a port, you may 565.Xr pkg_add 1 566them manually, or alternatively, you may set 567.Ev SUBPACKAGE 568in the environment of the 569.Xr make 1 570command during the install/deinstall phase: 571.Bd -literal -offset indent 572$ env SUBPACKAGE="-server" make install 573$ env SUBPACKAGE="-server" make deinstall 574.Ed 575.Sh PORT VARIABLES 576These can be changed in the environment, or in 577.Pa /etc/mk.conf 578for persistence. 579They can also be set on make's command line, e.g., 580.Ic make VAR_FOO=foo 581.Pp 582Boolean variables should be set to 583.Dv Yes 584instead of simply being defined, for uniformity and future compatibility. 585.Pp 586Variable names starting with _ are private to the ports infrastructure, 587should not be changed by the user, and are liable to change without notice. 588.Bl -tag -width MASTER_SITES 589.It Ev PORTSDIR 590Location of the ports tree 591(usually 592.Pa /usr/ports ) . 593.It Ev DISTDIR 594Where to find/put distfiles, normally 595.Pa distfiles/ 596in 597.Ev PORTSDIR . 598.It Ev PACKAGE_REPOSITORY 599Used only for the 600.Ar package 601target; the base directory for the packages tree, normally 602.Pa packages 603in 604.Ev PORTSDIR . 605If this directory exists, the package tree will be (partially) constructed. 606.It Ev BULK_COOKIES_DIR 607During bulk package building, used to store cookies for already built 608packages to avoid rebuilding them, since the actual 609working directory will already have been cleaned out. 610Defaults to bulk/${MACHINE_ARCH} under 611.Ev PORTSDIR . 612.It Ev UPDATE_COOKIES_DIR 613Used to store cookies for package updates, defaults to update/${MACHINE_ARCH} 614under 615.Ev PORTSDIR . 616If set to empty, it will revert to a file under ${WRKDIR}. 617.It Ev LOCALBASE 618Where to install things in general 619(usually 620.Pa /usr/local ) . 621.It Ev MASTER_SITES 622Primary sites for distribution files if not found locally. 623.It Ev CLEANDEPENDS 624If set to 625.Dv Yes , 626let 627.Sq clean 628recurse to dependencies. 629.It Ev FETCH_CMD 630Command to use to fetch files. 631Normally 632.Xr ftp 1 . 633.It Ev FETCH_PACKAGES 634If set to 635.Dq Yes , 636try to use 637.Xr pkg_add 1 638to install the missing packages from 639.Ev PKG_PATH . 640.It Ev PATCH_DEBUG 641If defined, display verbose output when applying each patch. 642.It Ev INTERACTIVE 643If defined, only operate on a port if it requires interaction. 644.It Ev BATCH 645If defined, only operate on a port if it can be installed 100% automatically. 646.It Ev USE_SYSTRACE 647Set to 648.Sq Yes 649to protect the 650.Ar configure , build , 651and 652.Ar fake 653targets with 654.Xr systrace 1 . 655This way it is ensured that ports do not make any network connections 656during build or write outside some well defined directories. 657The filter list is stored in 658.Pa ${PORTSDIR}/infrastructure/db/systrace.filter . 659.El 660.Sh USING A READ-ONLY PORTS TREE 661Select read-write partition(s) that can accommodate working directories, the 662distfiles repository, and the built packages. 663Set 664.Ev WRKOBJDIR , 665.Ev PACKAGE_REPOSITORY , 666.Ev BULK_COOKIES_DIR , 667.Ev UPDATE_COOKIES_DIR , 668.Ev DISTDIR , 669and 670.Ev PLIST_DB 671in 672.Pa /etc/mk.conf 673accordingly. 674.Sh FILES 675.Bl -tag -width /usr/ports/xxxxxxxx -compact 676.It Pa /usr/ports 677The default ports directory. 678.It Pa /usr/ports/Makefile 679Ports master Makefile. 680.It Pa /usr/ports/INDEX 681Ports index. 682.It Pa /usr/ports/infrastructure/mk/bsd.port.mk 683The ports main engine. 684.It Pa /usr/ports/infrastructure/templates/network.conf.template 685Network configuration defaults. 686.It Pa /usr/ports/infrastructure/db/network.conf 687Local network configuration. 688.It Pa /usr/ports/infrastructure/db/systrace.filter 689Filter list for systrace. 690.It Pa /usr/ports/infrastructure/db/user.list 691List of users and groups created by ports. 692.El 693.Sh SEE ALSO 694.Xr make 1 , 695.Xr pkg_add 1 , 696.Xr pkg_create 1 , 697.Xr pkg_delete 1 , 698.Xr pkg_info 1 , 699.Xr bsd.port.mk 5 , 700.Xr port-modules 5 , 701.Xr packages 7 702.Pp 703The 704.Ox 705Ports System: 706.Pa http://www.openbsd.org/faq/ports/ports.html 707.Pp 708The 709.Ox 710Porter's Handbook: 711.Pa http://www.openbsd.org/faq/ports/ 712.Sh HISTORY 713.Nm The Ports Collection 714appeared in 715.Fx 1.0 . 716It was introduced in 717.Ox 718by Ejovi Nuwere, with much initial effort by Angelos D. Keromytis. 719Maintenance passed then to Marco S. Hyman, and then to Christopher Turan. 720It is currently managed by Marc Espie, Christian Weisgerber, 721along with a host of others found at ports@openbsd.org. 722.Sh AUTHORS 723This man page was originated by 724David O'Brien, from the 725.Fx 726project. 727