1*565a3eb6Sjmc.\" $OpenBSD: packages.7,v 1.47 2022/01/05 17:39:25 jmc Exp $ 23ef84422Sespie.\" 33ef84422Sespie.\" Copyright (c) 2000 Marc Espie 43ef84422Sespie.\" 53ef84422Sespie.\" All rights reserved. 63ef84422Sespie.\" 73ef84422Sespie.\" Redistribution and use in source and binary forms, with or without 83ef84422Sespie.\" modification, are permitted provided that the following conditions 93ef84422Sespie.\" are met: 103ef84422Sespie.\" 1. Redistributions of source code must retain the above copyright 113ef84422Sespie.\" notice, this list of conditions and the following disclaimer. 123ef84422Sespie.\" 2. Redistributions in binary form must reproduce the above copyright 133ef84422Sespie.\" notice, this list of conditions and the following disclaimer in the 143ef84422Sespie.\" documentation and/or other materials provided with the distribution. 153ef84422Sespie.\" 163ef84422Sespie.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 173ef84422Sespie.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 183ef84422Sespie.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 193ef84422Sespie.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 203ef84422Sespie.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 213ef84422Sespie.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 223ef84422Sespie.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 233ef84422Sespie.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 243ef84422Sespie.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 253ef84422Sespie.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 263ef84422Sespie.\" 27*565a3eb6Sjmc.Dd $Mdocdate: January 5 2022 $ 283ef84422Sespie.Dt PACKAGES 7 293ef84422Sespie.Os 303ef84422Sespie.Sh NAME 313ef84422Sespie.Nm packages 323ef84422Sespie.Nd overview of the binary package system 333ef84422Sespie.Sh DESCRIPTION 3476181e52SespieThe 3576181e52Sespie.Ox 3625a0a303Sespiebinary packages feature a vast array of third-party software ready 3725a0a303Sespieto be installed on a new machine. 3825a0a303SespieThey are built through the 3925a0a303Sespie.Xr ports 7 4025a0a303Sespieinfrastructure. 411186295dSespieAdding a new package is as simple as 42fef2ebb4Sjmc.Pp 431baf2c59Srpe.Dl # pkg_add foo-1.0-vanilla.tgz 4476181e52Sespie.Pp 458de37ab6SjmcIn appearance, packages seem to be .tgz archives and, as such, can be 468de37ab6Sjmcexamined on almost any computer system; but there is a bit more to it, 47569ad5c9Sespieas described in 48569ad5c9Sespie.Xr package 5 . 4925a0a303Sespie.Pp 5025a0a303SespieEven though the names are similar, 5125a0a303Sespienote that the basic 5225a0a303Sespie.Ox 5325a0a303Sespiedistribution 5425a0a303Sespie.Po 5525a0a303Sespie.Pa baseXX.tgz , 5625a0a303Sespie.Pa compXX.tgz ... 5725a0a303Sespie.Pc 5825a0a303Sespieis not composed of such packages, but of plain tarballs. 59112e2feaSespie.Sh FINDING PACKAGES 60112e2feaSespieThe official builds feature packages that will help with finding a given piece 61112e2feaSespieof software: 62112e2feaSespie.Bl -tag -width ports-readmes-dancer 63112e2feaSespie.It pkglocatedb 64112e2feaSespiea 65112e2feaSespie.Xr locate 1 66112e2feaSespiedatabase of all files in the ports tree, 67112e2feaSespie.It sqlports 68112e2feaSespiean sqlite database of all meta-info of each port, along with an index, 69112e2feaSespieand a tool to trace dependencies chains, 70112e2feaSespie.It ports-readmes-dancer 71112e2feaSespiea simple local webserver that interfaces with that database to 72112e2feaSespiedisplay information. 73112e2feaSespie.Po 74112e2feaSespieThere is a running instance of that server hosted on 75112e2feaSespie.Lk https://openports.pl/ 76112e2feaSespie.Pc . 77112e2feaSespie.El 7876181e52Sespie.Sh SECURITY CAVEAT 7981f9a2e6SavsmThe packages are not as thoroughly audited as the main 8076181e52Sespie.Ox 8176181e52Sespiesource tree (in many cases, they have not been audited at all). 821baf2c59SrpeThis is in part a scale issue: the source tree weighs in at 150MB, compressed, 831baf2c59Srpewhereas the source files to the ports tree exceed 20GB. 84b3c75b6fSmpechAlso, most 8576181e52Sespie.Ox 861186295dSespiedevelopers concentrate on making the release as safe as possible and, 8776181e52Sespiecorrespondingly, human resources for the ports tree are somewhat lacking. 880143e17bSespie.Pp 890143e17bSespieStarting with 900143e17bSespie.Ox 5.5 , 910143e17bSespiepackages are now signed using 920143e17bSespie.Xr pkg_sign 1 : 930143e17bSespieunderstand that this is only a basic guarantee that the binary package 940143e17bSespiecan't be tampered with while in transit. 9501fcde83Sespie.Pp 9601fcde83SespieStarting with 9701fcde83Sespie.Ox 5.6 , 9801fcde83Sespiethe special package 9901fcde83Sespie.Ar quirks 10001fcde83Sespieis always updated, and its signature date displayed. 10101fcde83SespieAmong other things it contains a list of older packages that have 10201fcde83Sespiesecurity issues and 10301fcde83Sespie.Xr pkg_add 1 10401fcde83Sespiewill warn if those are installed and cannot be updated. 10501fcde83SespieThis prevents a scenario where a bad guy would maintain a partial mirror 10601fcde83Sespiewith outdated packages. 107ba6872ddSschwarze.Pp 108ba6872ddSschwarzeA small number of packages contain insecure code requiring 109ba6872ddSschwarze.Xr mmap 2 110ba6872ddSschwarzememory both writeable and executable. 111ba6872ddSschwarzeTo use such insecurely written software, a separate 112ba6872ddSschwarze.Pa /usr/local 113ba6872ddSschwarzefile system with the 114ba6872ddSschwarze.Cm wxallowed 115ba6872ddSschwarze.Xr mount 8 116ba6872ddSschwarzeoption is needed. 11776181e52Sespie.Sh MANAGING FILES 11866b526a3SschwarzeThe package system offers some strong warranties. 11976181e52Sespie.Ss "Installing a package won't erase existing files" 12076181e52Sespie.Xr pkg_add 1 121569ad5c9Sespiewill instead identify conflicts, display an 122569ad5c9Sespieerror message and stop. 12376181e52Sespie.Ss "Modifying installed files is safe" 12476181e52Sespie.Xr pkg_delete 1 1251186295dSespiewill checksum the files it installed before removing them. 1261186295dSespieIf the checksum changed, it will normally notify the user and not remove 12751b7405bSjmcthe changed file. 12851b7405bSjmcThis is particularly true of configuration files, 12951b7405bSjmcwhich will usually be left around after removing the package 13051b7405bSjmcif modified by the user. 13176181e52Sespie.Pp 13276181e52SespieThese should apply to most packages. 133569ad5c9SespieThe actual packing-lists follow that rule, but the few shell fragments 134569ad5c9Sespieembedded in some packages may break this assumption. 13576181e52SespieSuch a problem is a bug and should be reported. 13676181e52Sespie.Ss "Packages install to /usr/local" 13776181e52SespieThis includes X11 packages, which no longer install under 13876181e52Sespie.Pa /usr/X11R6 . 1394bea7435SaanriotThe only exception is 140c94a944cSjmcJapanese dictionaries, which install under 141569ad5c9Sespie.Pa /var/dict , 142569ad5c9Sespieand some web packages, which install under 143569ad5c9Sespie.Pa /var/www . 14476181e52Sespie.Pp 1451186295dSespieSome packages installation scripts will also create new configuration 1461186295dSespiefiles in 1471186295dSespie.Pa /etc , 1480bb3564eSespieinstall daemon control scripts in 1490bb3564eSespie.Pa /etc/rc.d , 1501186295dSespieor need some working directory under 1511186295dSespie.Pa /var 1521186295dSespieto function correctly (e.g., 1531186295dSespie.Nm squid , 1541186295dSespieor 155c3071ac2Sbrad.Nm mariadb ) . 1561186295dSespie.Pp 1570bb3564eSespie.Ox 1580bb3564eSespiespecific information installs under 1590bb3564eSespie.Pa /usr/local/share/doc/pkg-readmes . 1600bb3564eSespie.Pp 1611c388339SespieThe current package system has some deliberate design limitations. 16223fef8b1Sespie.Ss "The package system cannot account for system failures" 16323fef8b1SespieIf the system shuts down abruptly in the middle of a package change, 16423fef8b1Sespiethe information under 16523fef8b1Sespie.Pa /var/db/pkg 16623fef8b1Sespiemay well be corrupted. 16723fef8b1SespieUse 168cb4b231eSschwarze.Xr pkg_check 8 16923fef8b1Sespiein case of such problems. 17076181e52Sespie.Ss "The package system is not aware of shared network installations" 17176181e52SespieAnd thus, it does not handle that situation well. 17276181e52SespieFor instance, there is no mechanism to mark some files as being shareable 17376181e52Sespieon several machines, or even on several architectures. 1741c388339SespieBear in mind that the package database is normally stored in 1751c388339Sespie.Pa /var/db/pkg , 17676181e52Sespiewhich is usually not shared across machines. 17776181e52Sespie.Pp 1781c388339SespieAlways installing packages on the same machine, and exporting 1791c388339Sespie.Pa /usr/local 180b3c75b6fSmpechto other machines should mostly work. 181b3c75b6fSmpechIn such a case, always run 18276181e52Sespie.Xr pkg_add 1 1831186295dSespiein 1841186295dSespie.Qq "verbose, don't actually install the package" 1851186295dSespiemode first, so that 18676181e52Sespieadditional steps may be figured out. 18776181e52Sespie.Ss "The package system does not handle shared files across packages" 18876181e52SespieIf two packages install a file with the same name, there is a conflict. 18976181e52SespieTwo packages can't safely install an exact identical 19076181e52Sespiecopy of a given file: 19176181e52Sespie.Xr pkg_delete 1 19276181e52Sespiewould blindly remove that file when deleting the first package, thus 19376181e52Sespiebreaking the other installed package. 19476181e52Sespie.Pp 19576181e52SespiePackages that are distinct but rely on a common subset of files usually 19676181e52Sespieinstall a basic 197ed7d2371Sespie.Qq common 1981186295dSespiepackage that holds those files, and is not useful as a stand-alone package. 19906bafed7Sespie.Sh PACKAGE VERSIONS 20006bafed7SespieAll packages have an obvious version number in their name, 20106bafed7Sespieand a not so obvious version inside the actual package: 2021c388339Sespiethe run-time dependencies used for building. 2031c388339SespieTools like 2041c388339Sespie.Nm pkg_add Fl u 2051c388339Sespieand 206d8bf2c20Sjmc.Xr pkg_outdated 1 2071c388339Sespiewill look at those dependencies to 20806bafed7Sespiedecide when to perform an update. 20906bafed7Sespie.Pp 21006bafed7SespieThe full version (package name and dependency names) is known as the 2110143e17bSespie.Sq update signature , 2120143e17bSespieand can be queried with 2131c388339Sespie.Nm pkg_info Fl S , 2141c388339Sespiefor packages, or 2150143e17bSespie.Nm make Ar print-update-signature 2161c388339Sespiefor ports. 21706bafed7Sespie.Pp 21806bafed7SespieAdditionally, some packages with similar names and different versions may 21906bafed7Sespieexist at the same moment, because they have been built from different places 22006bafed7Sespiein the ports tree: snapshot versus stable version of some software, or 22106bafed7Sespiedifferent flavors (note that this is different from the usual -current versus 22206bafed7Sespie-stable versions of the 22306bafed7Sespie.Ox 22406bafed7Sespieports tree). 22506bafed7Sespie.Pp 2261c388339SespieEvery package includes at least one 2271c388339Sespie.Xr pkgpath 7 2281c388339Sespiemarker to record the ports tree 22906bafed7Sespielocation used to build it, so that users do not have their packages randomly 23006bafed7Sespieswitch from a stable to a snapshot package, or from a gtk to a gtk2 flavor. 23176181e52Sespie.Sh PACKAGE NAMING 232569ad5c9SespieAll package names follow the pattern 233ed7d2371Sespie.Qq name-version-flavor , 23476181e52Sespiewhere 235c9b5108fSjmc.Qq name 2364bea7435Saanriot(also called stem, see 2374bea7435Saanriot.Xr packages-specs 7 ) 23876181e52Sespieis the actual package name, 239ed7d2371Sespie.Qq version 24076181e52Sespieis the version number, and 241ed7d2371Sespie.Qq flavor 24276181e52Sespiedenotes some options that were used when creating the package. 24376181e52Sespie.Pp 24476181e52SespiePackages with the same name will usually not coexist peacefully, as 24576181e52Sespiethey contain different instances of the same program. 246569ad5c9SespieHence, by default, 24776181e52Sespie.Xr pkg_add 1 24876181e52Sespiedoes not allow several packages with the same name to be installed 24976181e52Sespiesimultaneously, and prints an error message instead. 25076181e52Sespie.Pp 25176181e52SespieThe most notable exception is the tcl/tk suite, where several versions 25276181e52Sespieof the tcl/tk packages will coexist peacefully on a single machine. 25376181e52Sespie.Pp 25476181e52SespieMembers of the 25576181e52Sespie.Ox 2561c388339Sespieproject routinely scan built packages for conflicting files, 2571c388339Sespieusing 2583230665aSjmc.Xr pkg_check-problems 1 . 25976181e52SespieMost packages should contain correct annotations, and not allow themselves 26076181e52Sespieto be installed on top of a conflicting package. 26187d708c7Sespie.Pp 26287d708c7SespieSome packages follow special naming conventions: 26387d708c7Sespie.Pp 26487d708c7Sespie.Bl -tag -width *-firmware-* -compact 26587d708c7Sespie.It Pa .lib-* 26687d708c7Sespieshared libraries kept after update, to be deleted once they are no longer used. 26787d708c7Sespie.It debug-* 26887d708c7Sespiedebug information for the corresponding package. 26987d708c7Sespie.It Pa partial-* 27087d708c7Sespiepartial installation of a package that couldn't finish. 27187d708c7Sespie.It Pa quirks-* 27287d708c7Sespiesupplementary information used by the package tools to handle special needs 27387d708c7Sespiefor updates. 27487d708c7Sespie.It Pa *-firmware-* 27587d708c7Sespiespecial system packages managed by 276*565a3eb6Sjmc.Xr fw_update 8 . 27787d708c7Sespie.El 27876181e52Sespie.Sh PACKAGE DEPENDENCIES 27976181e52SespieEach package holds a full list of pre-required packages. 28076181e52Sespie.Xr pkg_add 1 28176181e52Sespiewill automatically install required dependencies before installing a given 28276181e52Sespiepackage. 28376181e52SespieInstalls through 28476181e52Sespie.Xr ftp 1 28576181e52Sespieare supported: pointing 28676181e52Sespie.Ev PKG_PATH 28776181e52Sespieto a distant package repository, e.g., 2881277c4b6Sjmc.Bd -literal -offset 1n 2898a6e2931Sfcambus# export PKG_PATH=ftp.openbsd.org 2901277c4b6Sjmc.Ed 291fef2ebb4Sjmc.Pp 29276181e52Sespiewill let 29376181e52Sespie.Xr pkg_add 1 29476181e52Sespieautomatically download dependencies as well. 29576181e52Sespie.Pp 29676181e52SespieAlways a difficult balancing act writing proper dependencies is (but the 29776181e52SespieSource is strong with this one). 29876181e52SespieSince many packages can interact with lots of other packages, it is very easy 29976181e52Sespieto get over-eager, and have each package depend on more or less all the 3001186295dSespieothers. 3011186295dSespieTo counteract that problem, as a rule, packages only record a set of 30276181e52Sespiedependencies required to obtain a functional package. 30376181e52SespieSome extra packages may enable further functionalities, and this is 30476181e52Sespieusually mentioned at the end of installation, or in the package description. 30576181e52Sespie.Pp 30676181e52SespieSome flavors are also explicitly provided to avoid having to depend on the 30776181e52Sespiekitchen sink. 30876181e52SespieFor instance, an 3091c388339Sespie.Nm emacs--no_x11 3101186295dSespiepackage is provided, which does not depend on X11 being installed to be 31176181e52Sespiefunctional. 3123ef84422Sespie.Sh SEE ALSO 3133ef84422Sespie.Xr pkg_add 1 , 3143ef84422Sespie.Xr pkg_delete 1 , 315cb2157fcSmpech.Xr pkg_info 1 , 3160143e17bSespie.Xr pkg_sign 1 , 31776181e52Sespie.Xr tar 1 , 318569ad5c9Sespie.Xr package 5 , 3196f76d38bSespie.Xr packages-specs 7 , 3203ef84422Sespie.Xr ports 7 321