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