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