xref: /openbsd/usr.sbin/pkg_add/pkg_add.1 (revision 80a407d2)
1*80a407d2Sespie.\"	$OpenBSD: pkg_add.1,v 1.57 2006/03/04 11:56:57 espie Exp $
2a9987ed9Sespie.\"
3a9987ed9Sespie.\" FreeBSD install - a package for the installation and maintenance
4a9987ed9Sespie.\" of non-core utilities.
5a9987ed9Sespie.\"
6a9987ed9Sespie.\" Redistribution and use in source and binary forms, with or without
7a9987ed9Sespie.\" modification, are permitted provided that the following conditions
8a9987ed9Sespie.\" are met:
9a9987ed9Sespie.\" 1. Redistributions of source code must retain the above copyright
10a9987ed9Sespie.\"    notice, this list of conditions and the following disclaimer.
11a9987ed9Sespie.\" 2. Redistributions in binary form must reproduce the above copyright
12a9987ed9Sespie.\"    notice, this list of conditions and the following disclaimer in the
13a9987ed9Sespie.\"    documentation and/or other materials provided with the distribution.
14a9987ed9Sespie.\"
15a9987ed9Sespie.\" Jordan K. Hubbard
16a9987ed9Sespie.\"
17a9987ed9Sespie.\"
18a9987ed9Sespie.\"     @(#)pkg_add.1
19a9987ed9Sespie.\"
20a9987ed9Sespie.Dd November 25, 1994
21a9987ed9Sespie.Dt PKG_ADD 1
22a9987ed9Sespie.Os
23a9987ed9Sespie.Sh NAME
24a9987ed9Sespie.Nm pkg_add
25a9987ed9Sespie.Nd install software package distributions
26a9987ed9Sespie.Sh SYNOPSIS
27a9987ed9Sespie.Nm pkg_add
282468670bSjmc.Bk -words
29f674f73cSjmc.Op Fl acIinqruvx
30a56049e0Sespie.Op Fl A Ar arch
3157ec6696Sespie.Op Fl B Ar pkg-destdir
322468670bSjmc.Op Fl F Ar keywords
33e95d9ee4Sespie.Op Fl L Ar localbase
34a56049e0Sespie.Op Fl P Ar type
35bc4c08b2Sjmc.Op Fl Q Ar quick-destdir
36a9987ed9Sespie.Ar pkg-name Op Ar ...
372468670bSjmc.Ek
38a9987ed9Sespie.Sh DESCRIPTION
39a9987ed9SespieThe
40a9987ed9Sespie.Nm
41acb899f4Sespiecommand is used to install packages created
42a9987ed9Sespiewith the
43a9987ed9Sespie.Xr pkg_create 1
44a9987ed9Sespiecommand.
45a9987ed9SespieSelected packages containing pre-compiled applications from the
46a9987ed9Sespie.Pa /usr/ports
47a9987ed9Sespietree can be found on the
48a9987ed9Sespie.Ox
49a9987ed9SespieFTP site or on the official
50a9987ed9Sespie.Ox
51a9987ed9SespieCD.
52a9987ed9Sespie.Bd -filled -offset indent
53a9987ed9Sespie.Em Note :
5429b4d7a9SjmcSystem distribution files, e.g., base28.tgz, comp28.tgz, are
55a9987ed9Sespie.Em not
56a9987ed9Sespiepackages and may not be installed using
5729b4d7a9Sjmc.Nm .
58a9987ed9Sespie.Ed
59a9987ed9Sespie.Pp
60*80a407d2Sespie.Nm
61*80a407d2Sespiecan be used to install new packages, to replace existing packages with other
62*80a407d2Sespieflavors
63*80a407d2Sespie.Po
64*80a407d2Sespieoption
65*80a407d2Sespie.Fl r
66*80a407d2Sespie.Pc
67*80a407d2Sespieor to update packages to newer versions
68*80a407d2Sespie.Po
69*80a407d2Sespieoption
70*80a407d2Sespie.Fl u
71*80a407d2Sespie.Pc .
72*80a407d2Sespie.Pp
73*80a407d2SespieIn normal mode,
74*80a407d2Sespiethe package names given on the command lines are names of new packages that
75*80a407d2Sespie.Nm
76*80a407d2Sespieshould install, without ever deinstalling existing packages.
77*80a407d2Sespie.Pp
78*80a407d2SespieIn replacement mode,
79*80a407d2Sespiethe package names given on the command lines are names of new packages that
80*80a407d2Sespie.Nm
81*80a407d2Sespieshould install, possibly replacing existing installed packages.
82*80a407d2Sespie.Pp
83*80a407d2SespieIn update mode,
84*80a407d2Sespiethe package names given on the command lines are names of installed
85*80a407d2Sespiepackages, and
86*80a407d2Sespie.Nm
87*80a407d2Sespieshould figure out newer package names for these, then replace the old
88*80a407d2Sespiepackages with the new.
89*80a407d2Sespie.Pp
90060a7505SespieEach package name may be specified as a filename (which normally consists of the
91a9987ed9Sespiepackage name itself plus the
92060a7505Sespie.Dq .tgz
938e6642c9Sjmcsuffix) or a URL referring to FTP, HTTP, or SCP locations.
94aa441c49SjmcThe following examples are valid:
95a9987ed9Sespie.Pp
9629b4d7a9Sjmc.Li pkg_add -v ftp://ftp.openbsd.org/pub/OpenBSD/2.7/packages/i386/m4-1.4.tgz
97aa441c49Sjmc.Li pkg_add -v scp://login@host/usr/ports/packages/sparc/all/tcl-8.4.7.tgz
98a9987ed9Sespie.Pp
99a9987ed9SespieIf the given package names are not found in the current working directory,
100a9987ed9Sespie.Nm
101a9987ed9Sespiewill search for them in each directory named by the
102a9987ed9Sespie.Ev PKG_PATH
103a9987ed9Sespieenvironment variable.
1041d2a3765SjmcSince a few URL schemes contain colons,
10583728d2bSespie.Nm
10683728d2bSespierelies on each directory ending in a / to split the path correctly.
107a9987ed9SespieSpecifying
108a9987ed9Sespie.Ql -
109a9987ed9Sespieas a package name causes
110a9987ed9Sespie.Nm
111a9987ed9Sespieto read from the standard input.
112a9987ed9Sespie.Pp
113*80a407d2Sespie.Nm
114*80a407d2Sespiealso understands
115*80a407d2Sespie.Sq stems ,
116*80a407d2Sespiethat is, package names without any version specification.
117*80a407d2SespieFor instance, with
118*80a407d2Sespie.Li pkg_add kdelibs ,
119*80a407d2Sespie.Nm
120*80a407d2Sespiewill look in the current directory (or the PKG_PATH) for a kdelibs package.
121*80a407d2Sespie.Pp
122*80a407d2SespieIn case of ambiguities, for instance:
123*80a407d2Sespie.Li pkg_add screen
124*80a407d2Sespie(matches screen-4.02  and screen-4.02-static),
125*80a407d2Sespie.Nm
126*80a407d2Sespiewill error out, unless it is invoked in interactive mode
127*80a407d2Sespie.Po
128*80a407d2Sespieoption
129*80a407d2Sespie.Fl i
130*80a407d2Sespie.Pc .
131*80a407d2Sespie.Pp
13278a84262SespieIf the environment variable
13378a84262Sespie.Ev PKG_CACHE
13478a84262Sespieis set, every package retrieved from a distant location will also be
13578a84262Sespiecopied here.
13678a84262Sespie.Pp
137acb899f4SespieSome packages may depend on other packages.
138acb899f4SespieWhen resolving dependencies
139acb899f4Sespie.Nm
140acb899f4Sespiewill first look at already installed packages, then match
141*80a407d2Sespiedependencies with the list of packages left to install, then ask the
142*80a407d2Sespieuser's opinion in interactive mode,
143*80a407d2Sespiethen install default packages that satisfy the dependencies.
144acb899f4Sespie.Pp
14529b4d7a9SjmcAlternatively, it is possible to add packages interactively from within the
14629b4d7a9Sjmc.Xr ftp 1
14729b4d7a9Sjmcclient,
148013c217fSespiein which case setting
149013c217fSespie.Ev PKG_PATH
150013c217fSespiecorrectly will be necessary for any dependency to be found out and retrieved
151013c217fSespiethe same way.
152a9987ed9SespieFor example, the following works:
153bc4c08b2Sjmc.Bd -literal -offset indent
154a9987ed9Sespie$ ftp ftp://ftp.openbsd.org/pub/OpenBSD/2.7/packages/i386/
155a9987ed9Sespie250 CWD command successful
156a9987ed9Sespieftp> ls m*
157a9987ed9Sespie227 Entering Passive Mode (129,128,5,191,164,73)
158a9987ed9Sespie150 Opening ASCII mode data connection for m*.
159a9987ed9Sespiem4-1.4.tgz
160a9987ed9Sespiemetamail-2.7.tgz
161a9987ed9Sespiemh-6.8.4.tgz
162a9987ed9Sespiemm-1.0.12.tgz
163a9987ed9Sespiempeg_lib-1.2.1.tgz
164a9987ed9Sespiempeg_play-2.4.tgz
165a9987ed9Sespiempg123-0.59q.tgz
166a9987ed9Sespiemutt-0.95.7i.tgz
167a9987ed9Sespie226 Transfer complete.
168a9987ed9Sespieftp> get m4-1.4.tgz "|pkg_add -v -"
169a9987ed9Sespie.Ed
170a9987ed9Sespie.Pp
171a9987ed9Sespie.Sy Warning:
172a9987ed9SespieSince the
173a9987ed9Sespie.Nm
174a9987ed9Sespiecommand may execute scripts or programs contained within a package file,
175a9987ed9Sespieyour system may be susceptible to
176a9987ed9Sespie.Dq trojan horses
177a9987ed9Sespieor other subtle attacks from miscreants who create dangerous packages.
178a9987ed9SespieBe sure the specified package(s) are from trusted sources.
179a9987ed9Sespie.Pp
180a9987ed9SespieThe options are as follows:
181acb899f4Sespie.Bl -tag -width keyword
182bc4c08b2Sjmc.It Fl A Ar arch
183bc4c08b2SjmcAssume
184bc4c08b2Sjmc.Ar arch
185bc4c08b2Sjmcas current machine architecture for any package tests.
186f1c572eaSespie.It Fl a
18729b4d7a9SjmcAutomated package installation; do not record packages as installed manually.
188bc4c08b2Sjmc.It Fl B Ar pkg-destdir
189bc4c08b2SjmcSet
190bc4c08b2Sjmc.Ar pkg-destdir
191bc4c08b2Sjmcas the prefix to prepend to any object extracted from the package.
1927b2d8b10Sespie.It Fl c
1937b2d8b10SespieWhile replacing packages, delete extra configuration file in the old package,
1947b2d8b10Sespiementioned as
1957b2d8b10Sespie.Dl @extra file
1967b2d8b10Sespiein the packing-list.
197df9c49feSespie.It Fl F Ar keywords
198acb899f4SespieForce installation of the package.
199df9c49feSespie.Ar keywords
200acb899f4Sespieis a comma-separated list of keywords that state what failsafes
201acb899f4Sespieshould be waived.
202dfae7728SespieThese include:
203bc4c08b2Sjmc.Pp
204bc4c08b2Sjmc.Bl -tag -width "updatedependsXX" -compact
20578a84262Sespie.It Ar allversions
20678a84262Sespiedo not trim older p* variants of packages for updates.
20778a84262Sespie.It Ar alwaysupdate
20878a84262Sespieproceed with an update even if
20978a84262Sespie.Nm
21078a84262Sespiecan't find new packages for all installed packages.
211dfae7728Sespie.It Ar arch
212dfae7728Sespiearchitecture recorded in package may not match.
213b6ef0043Sespie.It Ar boguslibs
214b6ef0043Sespienot all shared libraries are marked with @lib.
215b6ef0043SespieInefficiently rescan package lists for non marked libraries.
216dfae7728Sespie.It Ar installed
217632d1059Sespiein update mode, reinstall an existing package with the same signature.
2185232c7d3Sespie.It Ar kitchensink
2195232c7d3Sespiewill install everything and the kitchen sink: randomly reorder the list
2205232c7d3Sespieof packages to install, and proceed after weeding out conflicts.
221dfae7728Sespie.It Ar libdepends
222e3715e9fSjmclibrary specifications may not be fulfilled.
223585fba56Sespie.It Ar noclosure
224585fba56Sespiedo not compute the closure of dependencies to figure out which packages to
225585fba56Sespieupdate when using
226585fba56Sespie.Fl u .
227dfae7728Sespie.It Ar nonroot
228dfae7728Sespieinstall even if not running as root.
2297e8fdcacSespie.It Ar pkgpath
2307e8fdcacSespiewith
2317e8fdcacSespie.Fl u ,
2327e8fdcacSespiedo not check the pkgpath matches if only one candidate is found.
233dfae7728Sespie.It Ar scripts
234632d1059Sespieexternal scripts may fail.
235e38100acSespie.It Ar update
236e38100acSespieunsafe update: old packing-list will run scripts that may fail.
237e38100acSespie.It Ar updatedepends
238e38100acSespieforce update even if forward dependencies no longer match.
239dfae7728Sespie.El
240f674f73cSjmc.It Fl I
241f674f73cSjmcIf scripts exist for a given package, do not execute them.
2429b5ce663Sespie.It Fl i
2439b5ce663SespieSwitch on interactive mode.
2449b5ce663Sespie.Nm
2459b5ce663Sespiemay ask questions to the user if faced with difficult decisions.
246e95d9ee4Sespie.It Fl L Ar localbase
247e95d9ee4SespieInstall a package under
248e95d9ee4Sespie.Ar localbase .
249e95d9ee4SespieBy default,
250e95d9ee4Sespie.Ar localbase
251e95d9ee4Sespieequals
252e95d9ee4Sespie.Pa /usr/local ,
253e95d9ee4Sespieand specifying it is not necessary.
254e95d9ee4SespieHowever, packages can be created using a different
255e95d9ee4Sespie.Ar localbase
256e95d9ee4Sespie.Po
257e95d9ee4Sespiesee
258e95d9ee4Sespie.Xr pkg_create 1
259e95d9ee4Sespie.Pc ,
260e95d9ee4Sespieand those packages can only be installed by using the same
261e95d9ee4Sespie.Ar localbase .
262e95d9ee4SespieSee
263e95d9ee4Sespie.Xr bsd.port.mk 5
264e95d9ee4Sespiefor a description of
265e95d9ee4Sespie.Ev LOCALBASE .
266bc4c08b2Sjmc.It Fl n
267bc4c08b2SjmcDon't actually install a package, just report the steps that
268bc4c08b2Sjmcwould be taken if it was.
269a56049e0Sespie.It Fl P Ar type
270a56049e0SespieCheck permissions for distribution, where
271a56049e0Sespie.Ar type
272a56049e0Sespiecan be
273a56049e0Sespie.Sq cdrom
274a56049e0Sespieor
275a56049e0Sespie.Sq ftp .
276bc4c08b2Sjmc.It Fl Q Ar quick-destdir
277bc4c08b2SjmcQuick and dirty installation under
278bc4c08b2Sjmc.Ar quick-destdir .
27929b4d7a9SjmcContrary to
280bc4c08b2Sjmc.Fl B
281bc4c08b2Sjmc.Ar pkg-destdir ,
282bc4c08b2Sjmcsymbolic links are resolved, and package installation stops at
283bc4c08b2Sjmc.Cm @endfake
284bc4c08b2Sjmcmarker.
285bc4c08b2Sjmc.It Fl q
28629b4d7a9SjmcReplace package quickly; do not bother checking MD5s before removing files.
287bc4c08b2Sjmc.It Fl r
288e70b9019SjmcReplace existing packages.
289e70b9019Sjmc.Nm
290e70b9019Sjmcwill try to take every precaution to make sure the replacement can
291bc4c08b2Sjmcproceed before removing the old package and adding the new one, and it
292bc4c08b2Sjmcshould also handle shared libraries correctly.
293c9a9437eSespieAmong other things,
294c9a9437eSespie.Nm
295e70b9019Sjmcwill refuse to replace packages as soon as it needs to run scripts that
296c9a9437eSespiemight fail
297c9a9437eSespie.Po
298c9a9437eSespieuse
299c9a9437eSespie.Fl F Ar update
300e70b9019Sjmcto force the replacement
301c9a9437eSespie.Pc ;
302c9a9437eSespie.Nm
303e70b9019Sjmcwill also refuse to replace packages when the dependencies don't quite
304c9a9437eSespiematch
305c9a9437eSespie.Po
306c9a9437eSespieuse
307c9a9437eSespie.Fl F Ar updatedepends
308e70b9019Sjmcto force the replacement
309c9a9437eSespie.Pc .
3107e8fdcacSespie.It Fl u
311bf06eee7SespieUpdate the given
312bf06eee7Sespie.Ar pkgname(s) ,
313bf06eee7Sespieand anything it depends upon.
314e70b9019SjmcIf no
3157e8fdcacSespie.Ar pkgname
3167e8fdcacSespieis given,
3177e8fdcacSespie.Nm
318bf06eee7Sespiewill update all installed packages.
3197e8fdcacSespieThis relies on
3207e8fdcacSespie.Ev PKG_PATH
3217e8fdcacSespieto figure out the new package names.
322bc4c08b2Sjmc.It Fl v
323bc4c08b2SjmcTurn on verbose output.
324bc4c08b2SjmcSeveral
325bc4c08b2Sjmc.Fl v
326bc4c08b2Sjmcturn on more verbose output.
327bc4c08b2Sjmc.It Fl x
328bc4c08b2SjmcDisable progress-meter.
329a9987ed9Sespie.El
330a9987ed9Sespie.Pp
331a9987ed9SespieBy default, when adding packages via FTP, the
332a9987ed9Sespie.Xr ftp 1
333a9987ed9Sespieprogram operates in
334a9987ed9Sespie.Dq passive
335a9987ed9Sespiemode.
336a9987ed9SespieIf you wish to use active mode instead, set the
337a9987ed9Sespie.Ev FTPMODE
338a9987ed9Sespieenvironment variable to
33929b4d7a9Sjmc.Dq active .
340a9987ed9SespieIf
341a9987ed9Sespie.Nm
342a9987ed9Sespieconsistently fails to fetch a package from a site known to work,
343a9987ed9Sespieit may be because the site does not support
34429b4d7a9Sjmcpassive mode FTP correctly.
345a9987ed9SespieThis is very rare since
346a9987ed9Sespie.Nm
34729b4d7a9Sjmcwill try active mode FTP if the server refuses a passive mode
348a9987ed9Sespieconnection.
349a9987ed9Sespie.Ss Technical details
350a9987ed9Sespie.Nm
351a9987ed9Sespieextracts each package's
352379cdfacSespie.Dq packing information
353379cdfacSespie(the packing list, description, and installation/deinstallation scripts)
354a9987ed9Sespieinto a special staging directory in
355a9987ed9Sespie.Pa /var/tmp
356a9987ed9Sespie(or
357a9987ed9Sespie.Ev PKG_TMPDIR
35829b4d7a9Sjmcif set \- see
35929b4d7a9Sjmc.Sx CAVEATS ,
36029b4d7a9Sjmcbelow)
361a9987ed9Sespieand then runs through the following sequence to fully extract the contents
362a9987ed9Sespieof the package:
363a9987ed9Sespie.Bl -enum
364a9987ed9Sespie.It
365a9987ed9SespieA check is made to determine if the package is already recorded as installed.
366a9987ed9SespieIf it is,
367a9987ed9Sespieinstallation is terminated.
368a9987ed9Sespie.It
369a9987ed9SespieA check is made to determine if the package conflicts (from
370a9987ed9Sespie.Cm @pkgcfl
37129b4d7a9Sjmcdirectives; see
372a9987ed9Sespie.Xr pkg_create 1 )
373c0f6f032Sespiewith a package already recorded as installed.
374a9987ed9SespieIf it is, installation is terminated.
375a9987ed9Sespie.It
37651a178ecSespieFor packages tagged with architecture constraints,
37751a178ecSespie.Nm
37851a178ecSespieverifies that the current machine architecture agrees with the constraints.
37951a178ecSespie.It
380a9987ed9SespieAll package dependencies (from
381f528e339Sespie.Cm @depend
382379cdfacSespieand
383f528e339Sespie.Cm @wantlib
38429b4d7a9Sjmcdirectives; see
385a9987ed9Sespie.Xr pkg_create 1 )
386a9987ed9Sespieare read from the packing list.
387e3715e9fSjmcIf any of these dependencies are not currently fulfilled,
388acb899f4Sespiean attempt is made to find a package that meets them and install it,
389acb899f4Sespielooking first in the list of packages to install passed to
390acb899f4Sespie.Nm ;
391379cdfacSespieif no adequate package can be found and installed,
392a9987ed9Sespiethe installation is terminated.
393a9987ed9Sespie.It
394acb899f4Sespie.Nm
395acb899f4Sespiechecks for collisions with installed file names, read-only file systems,
396acb899f4Sespieand enough space to store files.
397acb899f4Sespie.It
398a9987ed9SespieIf the package contains a
399a9987ed9Sespie.Ar require
400a9987ed9Sespiescript (see
401a9987ed9Sespie.Xr pkg_create 1 ) ,
402a9987ed9Sespieit is executed with the following arguments:
403a9987ed9Sespie.Bl -tag -width indentindent
404a9987ed9Sespie.It Ar pkg-name
405a9987ed9SespieThe name of the package being installed
406a9987ed9Sespie.It Cm INSTALL
407a9987ed9SespieKeyword denoting to the script that it is to run an installation requirements
408a9987ed9Sespiecheck
409a9987ed9Sespie(the keyword is useful only to scripts which serve multiple functions).
410a9987ed9Sespie.El
411a9987ed9Sespie.Pp
412a9987ed9SespieIf the
413a9987ed9Sespie.Ar require
414a9987ed9Sespiescript exits with a non-zero status code, the installation is terminated.
415a9987ed9Sespie.It
416a9987ed9SespieIf the package contains an
417a9987ed9Sespie.Ar install
418a9987ed9Sespiescript, it is executed with the following arguments:
419a9987ed9Sespie.Bl -tag -width indentindent
420a9987ed9Sespie.It Ar pkg-name
421a9987ed9SespieThe name of the package being installed.
422a9987ed9Sespie.It Cm PRE-INSTALL
423a9987ed9SespieKeyword denoting that the script is to perform any actions needed before
424a9987ed9Sespiethe package is installed.
425a9987ed9Sespie.El
426a9987ed9Sespie.Pp
427a9987ed9SespieIf the
428a9987ed9Sespie.Ar install
429a9987ed9Sespiescript exits with a non-zero status code, the installation is terminated.
430a9987ed9Sespie.It
431379cdfacSespieThe packing list is used as a guide for extracting
432379cdfacSespiefiles from the package into their final locations.
433a9987ed9Sespie.It
434a9987ed9SespieIf an
435a9987ed9Sespie.Ar install
436a9987ed9Sespiescript exists for the package, it is executed with the following arguments:
437a9987ed9Sespie.Bl -tag -width indentindent
438a9987ed9Sespie.It Ar pkg_name
439a9987ed9SespieThe name of the package being installed.
440a9987ed9Sespie.It Cm POST-INSTALL
441a9987ed9SespieKeyword denoting that the script is to perform any actions needed
442a9987ed9Sespieafter the package has been installed.
443a9987ed9Sespie.El
444a9987ed9Sespie.It
44561051699SespieAfter installation is complete, a copy of all package files
44661051699Sespiesuch as the packing-list, the
44761051699Sespie.Ar install
44861051699Sespieand
449a9987ed9Sespie.Ar deinstall
45061051699Sespiescripts, the description file is made into
451a9987ed9Sespie.Pa /var/db/pkg/<pkg-name>
452a9987ed9Sespiefor subsequent possible use by
45361051699Sespie.Xr pkg_delete 1
45461051699Sespieand
45561051699Sespie.Xr pkg_info 1 .
456a9987ed9SespieAny package dependencies are recorded in the other packages'
457a9987ed9Sespie.Pa /var/db/pkg/<other-pkg>/+REQUIRED_BY
458a9987ed9Sespiefile
459a9987ed9Sespie(if the environment variable
460a9987ed9Sespie.Ev PKG_DBDIR
461a9987ed9Sespieis set, this overrides the
462a9987ed9Sespie.Pa /var/db/pkg/
463a9987ed9Sespiepath shown above).
464a9987ed9Sespie.It
465a9987ed9SespieFinally, the staging area is deleted and the program terminates.
466a9987ed9Sespie.El
467a9987ed9Sespie.Pp
468acb899f4SespieNote that it is safe to interrupt
469acb899f4Sespie.Nm pkg_add
470acb899f4Sespiethrough
471acb899f4Sespie.Dv SIGINT ,
47278a84262Sespie.Dv SIGHUP ,
47378a84262Sespieand other signals, as it will safely record an interrupted install as
4743571b10fSespie.Pa partial-<pkgname>[.n] .
47578a84262Sespie.Pp
47678a84262SespieWhen replacing packages, the procedure is slightly different.
47778a84262Sespie.Bl -enum
47878a84262Sespie.It
47978a84262SespieA check is made to determine if a similar package is already installed.
48078a84262SespieIf its signature is identical to that of the new package, no replacement
48178a84262Sespieis performed (unless -F installed is specified).
48278a84262Sespie.It
48378a84262SespieA check is made to determine what old package the new package should replace,
48478a84262Sespieusing conflicts.
48578a84262Sespie.It
48678a84262SespieA check is made to determine whether the old package will be deleted without
48778a84262Sespieissue, and whether the new package will install correctly.
48878a84262SespieThis includes refusing to run any code (unless -F update), and verifying
48947fa19b2Sespiethat the new package still matches dependencies (unless -F updatedepends).
49078a84262Sespie.It
49178a84262SespieShared libraries deserve special treatment: each shared library from the old
49278a84262Sespiepackage that does no longer exist in the new package, but that is required
49378a84262Sespiefrom a wantlib of another package is kept along in a stub package named
49478a84262Sespie.Pa \&.libs-<pkgname> .
49578a84262Sespie.It
49678a84262SespieThe new package is extracted to the filesystem, using temporary filenames
49778a84262Sespieof the form
49878a84262Sespie.Pa pkg.XXXXXXX
49978a84262Sespiesince the old package is still there.
50078a84262SespieThe packing-list is amended to record these names as @temp annotations,
50178a84262Sespiein cases the installation fails.
50278a84262Sespie.It
50378a84262SespieThe old package is deleted as usual, except that some packages may still depend
50478a84262Sespieon it.
50578a84262Sespie.It
50647fa19b2SespieThe new package is installed as usual, except that the files are already present
50778a84262Sespieand only need to be renamed.
50878a84262Sespie.It
50978a84262SespieDependencies from the old package are adjusted to point to the new package.
51078a84262Sespie.El
51147fa19b2Sespie.Pp
51247fa19b2SespieTo update packages in -u mode,
51347fa19b2Sespie.Nm
51447fa19b2Sespieperforms the following steps.
51547fa19b2Sespie.Bl -enum
51647fa19b2Sespie.It
51747fa19b2SespiePackages to update are checked for dependencies, and their dependencies are
51847fa19b2Sespiemarked for update as well, unless -F noclosure.
51947fa19b2Sespie.It
52047fa19b2SespieEach package name is reduced to its stem, and every package name with matching
52147fa19b2Sespiestem available through
52247fa19b2Sespie.Ev PKG_PATH
52347fa19b2Sespieis considered as an update candidate.
52447fa19b2Sespie.It
52547fa19b2SespieSome minimal version matching occurs: out of all p* variations of a given
52647fa19b2Sespiepackage, only the most recent package is kept (unless -F allversions
52747fa19b2Sespieis given).
52847fa19b2SespieNote that
52947fa19b2Sespie.Nm pkg_add
53047fa19b2Sespiedoes not try to compare versions in a smarter way, thus
53147fa19b2Sespie.Ev PKG_PATH
53247fa19b2Sespieshould point to a snapshot of packages for a given version of
53347fa19b2Sespie.Ox ,
5341d2a3765Sjmcsimilar to the organization on the FTP sites.
53547fa19b2Sespie.It
53647fa19b2SespieCandidates are then matched according to their source paths (the subdirectory of
53747fa19b2Sespiethe ports dir, plus flavors and multi-packages modifiers), in order to weed
53847fa19b2Sespieout similar packages with distinct options.
53947fa19b2Sespie.It
54047fa19b2SespieThe signature of the candidate is compared to the signature of the already
54147fa19b2Sespieinstalled package: identical signatures mean no update needed.
54247fa19b2Sespie.It
54347fa19b2SespieIf several candidates are left,
54447fa19b2Sespie.Nm
54547fa19b2Sespiewill ask the user in interactive mode, and not perform the update in
54647fa19b2Sespienon-interactive mode.
54747fa19b2Sespie.It
54847fa19b2SespieOnce a suitable update candidate has been found for every package,
54947fa19b2Sespie.Nm
55047fa19b2Sespieproceeds to print out the list of new packages, and then performs the update.
55147fa19b2Sespie.It
55247fa19b2SespieIf some updates can't be solved,
55347fa19b2Sespie.Nm
55447fa19b2Sespiestops before the update, unless -F alwaysupdate.
55547fa19b2Sespie.El
556a9987ed9Sespie.Sh ENVIRONMENT
55757ec6696Sespie.Bl -tag -width PKG_DESTDIR
55829b4d7a9Sjmc.It Ev FTPMODE
55929b4d7a9SjmcSpecifies whether
56029b4d7a9Sjmc.Xr ftp 1
56129b4d7a9Sjmcshould operate in
56229b4d7a9Sjmc.Dq active
56329b4d7a9Sjmcor
56429b4d7a9Sjmc.Dq passive
56529b4d7a9Sjmcmode.
56629b4d7a9SjmcThe default is
56729b4d7a9Sjmc.Dq passive .
568*80a407d2Sespie.It Ev FETCH_CMD
569*80a407d2SespieOverride use of
570*80a407d2Sespie.Xr ftp 1 .
571*80a407d2SespieMust point to a command that understands
572*80a407d2Sespie.Li ${FETCH_CMD} -o - url .
573a9987ed9Sespie.It Ev PKG_DBDIR
574a9987ed9SespieWhere to register packages instead of
575a9987ed9Sespie.Pa /var/db/pkg .
57657ec6696Sespie.It Ev PKG_DESTDIR
57757ec6696SespieValue for
57857ec6696Sespie.Ar pkg-destdir ,
57957ec6696Sespieif no
58057ec6696Sespie.Fl B
58157ec6696Sespieoption is specified;
58257ec6696Sespievalue passed to any
58357ec6696Sespie.Cm INSTALL
58457ec6696Sespieor
58557ec6696Sespie.Cm REQUIRE
58657ec6696Sespiescript invoked from the package.
58778a84262Sespie.It Ev PKG_CACHE
58878a84262SespieIf set, any package retrieved from a distant location will be copied to
58978a84262Sespiethat directory as well.
590bc4c08b2Sjmc.It Ev PKG_PATH
591bc4c08b2SjmcIf a given package name cannot be found,
592bc4c08b2Sjmcthe directories named by
593bc4c08b2Sjmc.Ev PKG_PATH
594bc4c08b2Sjmcare searched.
595bc4c08b2SjmcIt should contain a series of entries separated by colons.
59683728d2bSespieEach entry consists of a directory name, ending in a slash.
5971d2a3765SjmcURL schemes such as FTP, HTTP, or SCP are also appropriate.
598bc4c08b2SjmcThe current directory may be indicated
599bc4c08b2Sjmcimplicitly by an empty directory name, or explicitly by a single
600bc4c08b2Sjmcperiod
60183728d2bSespie.Pq Ql \&./ .
602a9987ed9Sespie.It Ev PKG_TMPDIR
6030e815632SespieTemporary area where package information files will be extracted, instead of
604a9987ed9Sespie.Pa /var/tmp .
605a9987ed9Sespie.El
606a9987ed9Sespie.Sh SEE ALSO
60729b4d7a9Sjmc.Xr ftp 1 ,
608a9987ed9Sespie.Xr pkg_create 1 ,
609a9987ed9Sespie.Xr pkg_delete 1 ,
610a9987ed9Sespie.Xr pkg_info 1 ,
6116d9ebccbSespie.Xr bsd.port.mk 5 ,
6126d9ebccbSespie.Xr package 5
613a9987ed9Sespie.Sh AUTHORS
614a9987ed9Sespie.Bl -tag -width indent -compact
615a9987ed9Sespie.It "Jordan Hubbard"
616a9987ed9SespieInitial design.
617a9987ed9Sespie.It "Marc Espie"
618a9987ed9SespieComplete rewrite.
619a9987ed9Sespie.El
620a9987ed9Sespie.Sh CAVEATS
621a9987ed9SespiePackage extraction does need a temporary area that
622a9987ed9Sespiecan hold executable scripts.
623a9987ed9Sespie.Pp
624a9987ed9Sespie.Nm
625acb899f4Sespielooks through
626acb899f4Sespie.Ev ${PKG_TMPDIR} ,
627acb899f4Sespie.Ev ${TMPDIR} ,
628acb899f4Sespie.Pa /var/tmp ,
629acb899f4Sespie.Pa /tmp ,
63029b4d7a9Sjmcand
631acb899f4Sespie.Pa /usr/tmp
632a9987ed9Sespiefor such an area, in sequence.
633a9987ed9Sespie.Pp
634acb899f4SespieIf
635acb899f4Sespie.Ev ${TMPDIR}
636acb899f4Sespieand
637acb899f4Sespie.Pa /var/tmp
638acb899f4Sespieare mounted noexec, you must currently set
639acb899f4Sespie.Ev PKG_TMPDIR
640a9987ed9Sespieto a suitable area, as
641a9987ed9Sespie.Nm
642acb899f4Sespiedoes not check for noexec status except by failing to run installation
643a9987ed9Sespiescripts.
644bc4c08b2Sjmc.Sh BUGS
645716a5542Sespie.Xr scp 1
646716a5542Sespieprocesses do not die like they should when their pipe is closed,
647e4765148Sjmcso using
648716a5542Sespie.Nm
649e4765148Sjmcover SCP consumes an insane amount of resources.
650