xref: /freebsd/usr.bin/xinstall/install.1 (revision b0d29bc47dba79f6f38e67eabadfb4b32ffd9390)
1.\" Copyright (c) 1987, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	From: @(#)install.1	8.1 (Berkeley) 6/6/93
29.\" $FreeBSD$
30.\"
31.Dd August 12, 2019
32.Dt INSTALL 1
33.Os
34.Sh NAME
35.Nm install
36.Nd install binaries
37.Sh SYNOPSIS
38.Nm
39.Op Fl bCcpSsUv
40.Op Fl B Ar suffix
41.Op Fl D Ar destdir
42.Op Fl f Ar flags
43.Op Fl g Ar group
44.Op Fl h Ar hash
45.Op Fl l Ar linkflags
46.Op Fl M Ar metalog
47.Op Fl m Ar mode
48.Op Fl N Ar dbdir
49.Op Fl o Ar owner
50.Op Fl T Ar tags
51.Ar file1 file2
52.Nm
53.Op Fl bCcpSsUv
54.Op Fl B Ar suffix
55.Op Fl D Ar destdir
56.Op Fl f Ar flags
57.Op Fl g Ar group
58.Op Fl h Ar hash
59.Op Fl l Ar linkflags
60.Op Fl M Ar metalog
61.Op Fl m Ar mode
62.Op Fl N Ar dbdir
63.Op Fl o Ar owner
64.Op Fl T Ar tags
65.Ar file1 ... fileN directory
66.Nm
67.Fl d
68.Op Fl Uv
69.Op Fl D Ar destdir
70.Op Fl g Ar group
71.Op Fl h Ar hash
72.Op Fl M Ar metalog
73.Op Fl m Ar mode
74.Op Fl N Ar dbdir
75.Op Fl o Ar owner
76.Op Fl T Ar tags
77.Ar directory ...
78.Sh DESCRIPTION
79The file(s) are copied
80(or linked if the
81.Fl l
82option is specified) to the target file or directory.
83If the destination is a directory, then the
84.Ar file
85is copied into
86.Ar directory
87with its original filename.
88If the target file already exists, it is
89either renamed to
90.Ar file Ns Pa .old
91if the
92.Fl b
93option is given
94or overwritten
95if permissions allow.
96An alternate backup suffix may be specified via the
97.Fl B
98option's argument.
99.Pp
100The options are as follows:
101.Bl -tag -width indent
102.It Fl b
103Back up any existing files before overwriting them by renaming
104them to
105.Ar file Ns Pa .old .
106See
107.Fl B
108for specifying a different backup suffix.
109.It Fl B Ar suffix
110Use
111.Ar suffix
112as the backup suffix if
113.Fl b
114is given.
115.It Fl C
116Copy the file.
117If the target file already exists and the files are the same,
118then do not change the modification time of the target.
119If the target's file flags and mode need not to be changed,
120the target's inode change time is also unchanged.
121.It Fl c
122Copy the file.
123This is actually the default.
124The
125.Fl c
126option is only included for backwards compatibility.
127.It Fl D Ar destdir
128Specify the
129.Ev DESTDIR
130(top of the file hierarchy) that the items are installed in to.
131If
132.Fl M Ar metalog
133is in use, a leading string of
134.Dq Ar destdir
135will be removed from the file names logged to the
136.Ar metalog .
137This option does not affect where the actual files are installed.
138.It Fl d
139Create directories.
140Missing parent directories are created as required.
141.It Fl f Ar flags
142Specify the target's file flags; see
143.Xr chflags 1
144for a list of possible flags and their meanings.
145.It Fl g Ar group
146Specify a group.
147A numeric GID is allowed.
148.It Fl h Ar hash
149When copying, calculate the digest of the files with
150.Ar hash
151to store in the
152.Fl M Ar metalog .
153When
154.Fl d
155is given no hash is emitted.
156Supported digests:
157.Bl -tag -width rmd160 -offset indent
158.It Sy none
159No hash.
160This is the default.
161.It Sy md5
162The MD5 cryptographic message digest.
163.It Sy rmd160
164The RMD-160 cryptographic message digest.
165.It Sy sha1
166The SHA-1 cryptographic message digest.
167.It Sy sha256
168The 256-bits SHA-2 cryptographic message digest of the file.
169.It Sy sha512
170The 512-bits SHA-2 cryptographic message digest of the file.
171.El
172.It Fl l Ar linkflags
173Instead of copying the file make a link to the source.
174The type of the link is determined by the
175.Ar linkflags
176argument.
177Valid
178.Ar linkflags
179are:
180.Ar a
181(absolute),
182.Ar r
183(relative),
184.Ar h
185(hard),
186.Ar s
187(symbolic),
188.Ar m
189(mixed).
190Absolute and relative have effect only for symbolic links.
191Mixed links
192are hard links for files on the same filesystem, symbolic otherwise.
193.It Fl M Ar metalog
194Write the metadata associated with each item installed to
195.Ar metalog
196in an
197.Xr mtree 8
198.Dq full path
199specification line.
200The metadata includes: the file name and file type, and depending upon
201other options, the owner, group, file flags, modification time, and tags.
202.It Fl m Ar mode
203Specify an alternate mode.
204The default mode is set to rwxr-xr-x (0755).
205The specified mode may be either an octal or symbolic value; see
206.Xr chmod 1
207for a description of possible mode values.
208.It Fl N Ar dbdir
209Use the user database text file
210.Pa master.passwd
211and group database text file
212.Pa group
213from
214.Ar dbdir ,
215rather than using the results from the system's
216.Xr getpwnam 3
217and
218.Xr getgrnam 3
219(and related) library calls.
220.It Fl o Ar owner
221Specify an owner.
222A numeric UID is allowed.
223.It Fl p
224Preserve the access and modification times.
225Copy the file, as if the
226.Fl C
227(compare and copy) option is specified,
228except if the target file does not already exist or is different,
229then preserve the access and modification times of the source file.
230.It Fl S
231Safe copy.
232Normally,
233.Nm
234unlinks an existing target before installing the new file.
235With the
236.Fl S
237flag a temporary file is used and then renamed to be
238the target.
239The reason this is safer is that if the copy or
240rename fails, the existing target is left untouched.
241.It Fl s
242.Nm
243exec's the command
244.Xr strip 1
245to strip binaries so that
246.Nm
247can be portable over a large
248number of systems and binary types.
249See below for how
250.Nm
251can be instructed to use another program to strip binaries.
252.It Fl T Ar tags
253Specify the
254.Xr mtree 8
255tags to write out for the file when using
256.Fl M Ar metalog .
257.It Fl U
258Indicate that install is running unprivileged, and that it should not
259try to change the owner, the group, or the file flags of the destination.
260The information that would have been updated can be stored in a log
261file with
262.Fl M Ar metalog .
263.It Fl v
264Cause
265.Nm
266to be verbose,
267showing files as they are installed or backed up.
268.El
269.Pp
270By default,
271.Nm
272preserves all file flags, with the exception of the
273.Dq nodump
274flag.
275.Pp
276The
277.Nm
278utility attempts to prevent moving a file onto itself.
279.Pp
280Installing
281.Pa /dev/null
282creates an empty file.
283.Sh ENVIRONMENT
284The
285.Nm
286utility checks for the presence of the
287.Ev STRIPBIN
288environment variable and if present,
289uses the assigned value as the program to run if and when the
290.Fl s
291option has been specified.
292.Pp
293If the
294.Ev DONTSTRIP
295environment variable is present,
296.Nm
297will ignore any specification of the
298.Fl s
299option.
300This is mainly for use in debugging the
301.Fx
302Ports Collection.
303.Sh FILES
304.Bl -tag -width "INS@XXXX" -compact
305.It Pa INS@XXXX
306If either
307.Fl S
308option is specified, or the
309.Fl C
310or
311.Fl p
312option is used in conjunction with the
313.Fl s
314option, temporary files named
315.Pa INS@XXXX ,
316where
317.Pa XXXX
318is decided by
319.Xr mkstemp 3 ,
320are created in the target directory.
321.El
322.Sh EXIT STATUS
323.Ex -std
324.Sh COMPATIBILITY
325Historically
326.Nm
327moved files by default.
328The default was changed to copy in
329.Fx 4.4 .
330.Sh SEE ALSO
331.Xr chflags 1 ,
332.Xr chgrp 1 ,
333.Xr chmod 1 ,
334.Xr cp 1 ,
335.Xr mv 1 ,
336.Xr strip 1 ,
337.Xr mmap 2 ,
338.Xr getgrnam 3 ,
339.Xr getpwnam 3 ,
340.Xr chown 8
341.Sh HISTORY
342The
343.Nm
344utility appeared in
345.Bx 4.2 .
346.Sh BUGS
347The meaning of the
348.Fl M
349option has changed as of
350.Fx 9.2
351and it now takes an argument.
352Command lines that used the old
353.Fl M
354will get an error or in rare cases will append logs to the first of
355multiple source files rather than installing it.
356.Pp
357Temporary files may be left in the target directory if
358.Nm
359exits abnormally.
360.Pp
361File flags cannot be set by
362.Xr fchflags 2
363over a NFS file system.
364Other file systems do not have a concept of flags.
365The
366.Nm
367utility will only warn when flags could not be set on a file system
368that does not support them.
369.Pp
370The
371.Nm
372utility with
373.Fl v
374falsely says a file is copied when
375.Fl C
376snaps hard links.
377