1.\" $OpenBSD: packages.7,v 1.45 2019/12/04 11:07:58 espie Exp $ 2.\" 3.\" Copyright (c) 2000 Marc Espie 4.\" 5.\" All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd $Mdocdate: December 4 2019 $ 28.Dt PACKAGES 7 29.Os 30.Sh NAME 31.Nm packages 32.Nd overview of the binary package system 33.Sh DESCRIPTION 34The 35.Ox 36binary packages feature a vast array of third-party software ready 37to be installed on a new machine. 38They are built through the 39.Xr ports 7 40infrastructure. 41Adding a new package is as simple as 42.Pp 43.Dl # pkg_add foo-1.0-vanilla.tgz 44.Pp 45In appearance, packages seem to be .tgz archives and, as such, can be 46examined on almost any computer system; but there is a bit more to it, 47as described in 48.Xr package 5 . 49.Pp 50Even though the names are similar, 51note that the basic 52.Ox 53distribution 54.Po 55.Pa baseXX.tgz , 56.Pa compXX.tgz ... 57.Pc 58is not composed of such packages, but of plain tarballs. 59.Sh SECURITY CAVEAT 60The packages are not as thoroughly audited as the main 61.Ox 62source tree (in many cases, they have not been audited at all). 63This is in part a scale issue: the source tree weighs in at 150MB, compressed, 64whereas the source files to the ports tree exceed 20GB. 65Also, most 66.Ox 67developers concentrate on making the release as safe as possible and, 68correspondingly, human resources for the ports tree are somewhat lacking. 69.Pp 70Starting with 71.Ox 5.5 , 72packages are now signed using 73.Xr pkg_sign 1 : 74understand that this is only a basic guarantee that the binary package 75can't be tampered with while in transit. 76.Pp 77Starting with 78.Ox 5.6 , 79the special package 80.Ar quirks 81is always updated, and its signature date displayed. 82Among other things it contains a list of older packages that have 83security issues and 84.Xr pkg_add 1 85will warn if those are installed and cannot be updated. 86This prevents a scenario where a bad guy would maintain a partial mirror 87with outdated packages. 88.Pp 89A small number of packages contain insecure code requiring 90.Xr mmap 2 91memory both writeable and executable. 92To use such insecurely written software, a separate 93.Pa /usr/local 94file system with the 95.Cm wxallowed 96.Xr mount 8 97option is needed. 98.Sh MANAGING FILES 99The package system offers some strong warranties. 100.Ss "Installing a package won't erase existing files" 101.Xr pkg_add 1 102will instead identify conflicts, display an 103error message and stop. 104.Ss "Modifying installed files is safe" 105.Xr pkg_delete 1 106will checksum the files it installed before removing them. 107If the checksum changed, it will normally notify the user and not remove 108the changed file. 109This is particularly true of configuration files, 110which will usually be left around after removing the package 111if modified by the user. 112.Pp 113These should apply to most packages. 114The actual packing-lists follow that rule, but the few shell fragments 115embedded in some packages may break this assumption. 116Such a problem is a bug and should be reported. 117.Ss "Packages install to /usr/local" 118This includes X11 packages, which no longer install under 119.Pa /usr/X11R6 . 120The only exception is 121Japanese dictionaries, which install under 122.Pa /var/dict , 123and some web packages, which install under 124.Pa /var/www . 125.Pp 126Some packages installation scripts will also create new configuration 127files in 128.Pa /etc , 129install daemon control scripts in 130.Pa /etc/rc.d , 131or need some working directory under 132.Pa /var 133to function correctly (e.g., 134.Nm squid , 135or 136.Nm mariadb ) . 137.Pp 138.Ox 139specific information installs under 140.Pa /usr/local/share/doc/pkg-readmes . 141.Pp 142The current package system has some deliberate design limitations. 143.Ss "The package system cannot account for system failures" 144If the system shuts down abruptly in the middle of a package change, 145the information under 146.Pa /var/db/pkg 147may well be corrupted. 148Use 149.Xr pkg_check 8 150in case of such problems. 151.Ss "The package system is not aware of shared network installations" 152And thus, it does not handle that situation well. 153For instance, there is no mechanism to mark some files as being shareable 154on several machines, or even on several architectures. 155Bear in mind that the package database is normally stored in 156.Pa /var/db/pkg , 157which is usually not shared across machines. 158.Pp 159Always installing packages on the same machine, and exporting 160.Pa /usr/local 161to other machines should mostly work. 162In such a case, always run 163.Xr pkg_add 1 164in 165.Qq "verbose, don't actually install the package" 166mode first, so that 167additional steps may be figured out. 168.Ss "The package system does not handle shared files across packages" 169If two packages install a file with the same name, there is a conflict. 170Two packages can't safely install an exact identical 171copy of a given file: 172.Xr pkg_delete 1 173would blindly remove that file when deleting the first package, thus 174breaking the other installed package. 175.Pp 176Packages that are distinct but rely on a common subset of files usually 177install a basic 178.Qq common 179package that holds those files, and is not useful as a stand-alone package. 180.Sh PACKAGE VERSIONS 181All packages have an obvious version number in their name, 182and a not so obvious version inside the actual package: 183the run-time dependencies used for building. 184Tools like 185.Nm pkg_add Fl u 186and 187.Xr pkg_outdated 1 188will look at those dependencies to 189decide when to perform an update. 190.Pp 191The full version (package name and dependency names) is known as the 192.Sq update signature , 193and can be queried with 194.Nm pkg_info Fl S , 195for packages, or 196.Nm make Ar print-update-signature 197for ports. 198.Pp 199Additionally, some packages with similar names and different versions may 200exist at the same moment, because they have been built from different places 201in the ports tree: snapshot versus stable version of some software, or 202different flavors (note that this is different from the usual -current versus 203-stable versions of the 204.Ox 205ports tree). 206.Pp 207Every package includes at least one 208.Xr pkgpath 7 209marker to record the ports tree 210location used to build it, so that users do not have their packages randomly 211switch from a stable to a snapshot package, or from a gtk to a gtk2 flavor. 212.Sh PACKAGE NAMING 213All package names follow the pattern 214.Qq name-version-flavor , 215where 216.Qq name 217(also called stem, see 218.Xr packages-specs 7 ) 219is the actual package name, 220.Qq version 221is the version number, and 222.Qq flavor 223denotes some options that were used when creating the package. 224.Pp 225Packages with the same name will usually not coexist peacefully, as 226they contain different instances of the same program. 227Hence, by default, 228.Xr pkg_add 1 229does not allow several packages with the same name to be installed 230simultaneously, and prints an error message instead. 231.Pp 232The most notable exception is the tcl/tk suite, where several versions 233of the tcl/tk packages will coexist peacefully on a single machine. 234.Pp 235Members of the 236.Ox 237project routinely scan built packages for conflicting files, 238using 239.Xr pkg_check-problems 1 . 240Most packages should contain correct annotations, and not allow themselves 241to be installed on top of a conflicting package. 242.Pp 243Some packages follow special naming conventions: 244.Pp 245.Bl -tag -width *-firmware-* -compact 246.It Pa .lib-* 247shared libraries kept after update, to be deleted once they are no longer used. 248.It debug-* 249debug information for the corresponding package. 250.It Pa partial-* 251partial installation of a package that couldn't finish. 252.It Pa quirks-* 253supplementary information used by the package tools to handle special needs 254for updates. 255.It Pa *-firmware-* 256special system packages managed by 257.Xr fw_update 1 . 258.El 259.Sh PACKAGE DEPENDENCIES 260Each package holds a full list of pre-required packages. 261.Xr pkg_add 1 262will automatically install required dependencies before installing a given 263package. 264Installs through 265.Xr ftp 1 266are supported: pointing 267.Ev PKG_PATH 268to a distant package repository, e.g., 269.Bd -literal -offset 1n 270# export PKG_PATH=ftp.openbsd.org 271.Ed 272.Pp 273will let 274.Xr pkg_add 1 275automatically download dependencies as well. 276.Pp 277Always a difficult balancing act writing proper dependencies is (but the 278Source is strong with this one). 279Since many packages can interact with lots of other packages, it is very easy 280to get over-eager, and have each package depend on more or less all the 281others. 282To counteract that problem, as a rule, packages only record a set of 283dependencies required to obtain a functional package. 284Some extra packages may enable further functionalities, and this is 285usually mentioned at the end of installation, or in the package description. 286.Pp 287Some flavors are also explicitly provided to avoid having to depend on the 288kitchen sink. 289For instance, an 290.Nm emacs--no_x11 291package is provided, which does not depend on X11 being installed to be 292functional. 293.Sh SEE ALSO 294.Xr pkg_add 1 , 295.Xr pkg_delete 1 , 296.Xr pkg_info 1 , 297.Xr pkg_sign 1 , 298.Xr tar 1 , 299.Xr package 5 , 300.Xr packages-specs 7 , 301.Xr ports 7 302