-.\" $NetBSD: install.1,v 1.11 1998/09/28 08:16:15 christos Exp $
-.\"
.\" Copyright (c) 1987, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)install.1 8.1 (Berkeley) 6/6/93
+.\" From: @(#)install.1 8.1 (Berkeley) 6/6/93
+.\" $FreeBSD: src/usr.bin/xinstall/install.1,v 1.21 2001/05/30 09:45:47 ru Exp $
.\"
-.Dd June 6, 1993
+.Dd May 7, 2001
.Dt INSTALL 1
-.Os BSD 4.2
+.Os
.Sh NAME
.Nm install
.Nd install binaries
.Sh SYNOPSIS
-.Nm
-.Op Fl cps
+.Nm install
+.Op Fl bCcMpSsv
+.Op Fl B Ar suffix
.Op Fl f Ar flags
+.Op Fl g Ar group
.Op Fl m Ar mode
.Op Fl o Ar owner
-.Op Fl g Ar group
-.Op Fl l Ar linkflags
-.Op Fl S Ar stripflag
.Ar file1 file2
-.Nm ""
-.Op Fl cps
+.Nm install
+.Op Fl bCcMpSsv
+.Op Fl B Ar suffix
.Op Fl f Ar flags
+.Op Fl g Ar group
.Op Fl m Ar mode
.Op Fl o Ar owner
+.Ar file1 ... fileN directory
+.Nm install
+.Fl d
+.Op Fl v
.Op Fl g Ar group
-.Op Fl l Ar linkflags
-.Op Fl S Ar stripflag
-.Ar file1
-\&...
-.Ar fileN directory
-.Nm ""
-.Fl pd
.Op Fl m Ar mode
.Op Fl o Ar owner
-.Op Fl g Ar group
-.Ar directory
-\&...
+.Ar directory ...
.Sh DESCRIPTION
-The file(s) are moved (copied if the
-.Fl c
-option is specified, or linked if the
-.Fl l
-option is specified) to the target file or directory.
+The file(s) are copied
+to the target file or directory.
If the destination is a directory, then the
.Ar file
-is moved into
+is copied into
.Ar directory
with its original filename.
-If the target file already exists, it is overwritten if permissions
-allow.
+If the target file already exists, it is
+either renamed to
+.Ar file Ns Pa .old
+if the
+.Fl b
+option is given
+or overwritten
+if permissions allow.
+An alternate backup suffix may be specified via the
+.Fl B
+option's argument.
.Pp
-.Bl -tag -width Ds
+The options are as follows:
+.Bl -tag -width indent
+.\" ==========
+.It Fl B Ar suffix
+Use
+.Ar suffix
+as the backup suffix if
+.Fl b
+is given.
+.\" ==========
+.It Fl b
+Back up any existing files before overwriting them by renaming
+them to
+.Ar file Ns Pa .old .
+See
+.Fl B
+for specifying a different backup suffix.
+.\" ==========
+.It Fl C
+Copy the file.
+If the target file already exists and the files are the same,
+then don't change the modification time of the target.
+.\" ==========
.It Fl c
Copy the file.
-This flag turns off the default behavior of
-.Nm
-where it deletes the original file after creating the target.
+This is actually the default.
+The
+.Fl c
+option is only included for backwards compatibility.
+.\" ==========
+.It Fl d
+Create directories.
+Missing parent directories are created as required.
+.\" ==========
.It Fl f
-Specify the target's file flags.
-(See
+Specify the target's file flags; see
.Xr chflags 1
-for a list of possible flags and their meanings.)
+for a list of possible flags and their meanings.
+.\" ==========
.It Fl g
Specify a group.
+A numeric GID is allowed.
+.\" ==========
+.It Fl M
+Disable all use of
+.Xr mmap 2 .
+.\" ==========
.It Fl m
-Specify an alternative mode.
+Specify an alternate mode.
The default mode is set to rwxr-xr-x (0755).
The specified mode may be either an octal or symbolic value; see
-.Xr chmod 1
+.Xr chmod 1
for a description of possible mode values.
-.It Fl l Ar linkflags
-Instead of copying the file make a link to the source. The type of the
-link is determined by the
-.Ar linkflags
-argument. Valid
-.Ar linkflags
-are:
-.Ar a
-(absolute),
-.Ar r
-(relative),
-.Ar h
-(hard),
-.Ar s
-(symbolic),
-.Ar m
-(mixed). Absolute and relative have effect only for symbolic links. Mixed links
-are hard links for files on the same filesystem, symbolic otherwise.
+.\" ==========
.It Fl o
Specify an owner.
+A numeric UID is allowed.
+.\" ==========
.It Fl p
-Preserve the source files access and modification times.
+Preserve the modification time.
+Copy the file, as if the
+.Fl C
+(compare and copy) option is specified,
+except if the target file doesn't already exist or is different,
+then preserve the modification time of the file.
+.\" ==========
+.It Fl S
+Safe copy.
+Normally,
+.Nm install
+unlinks an existing target before installing the new file.
+With the
+.Fl S
+flag a temporary file is used and then renamed to be
+the target.
+The reason this is safer is that if the copy or
+rename fails, the existing target is left untouched.
+.\" ==========
.It Fl s
-.Nm
+.Nm install
exec's the command
-.Xr strip 1
-to strip binaries so that install can be portable over a large
-number of systems and binary types. If the environment variable
-.Ev STRIP
-is set, it is used as the
.Xr strip 1
-program.
-.It Fl S Ar stripflags
-.Nm
-passes
-.Ar stripflags
-as option arguments to
-.Xr strip 1 .
-When -S is used,
-.Xr strip 1
-is invoked via the
-.Xr sh 1
-shell, allowing a single -S argument be to specified to
-.Nm
-which the shell can then tokenize. Normally,
-.Nm
-invokes
-.Xr strip 1
-directly. This flag implies -s.
-.It Fl d
-Create directories.
-Missing parent directories are created as required.
+to strip binaries so that
+.Nm install
+can be portable over a large
+number of systems and binary types.
+.\" ==========
+.It Fl v
+Causes
+.Nm install
+to show when
+.Fl C
+actually installs something.
.El
.Pp
By default,
-.Nm
-preserves all file flags, with the exception of the ``nodump'' flag.
+.Nm install
+preserves all file flags, with the exception of the
+.Dq nodump
+flag.
.Pp
The
-.Nm
+.Nm install
utility attempts to prevent moving a file onto itself.
.Pp
Installing
.Pa /dev/null
creates an empty file.
-.Pp
-Upon successful completion a value of 0 is returned.
-Otherwise, a value of 1 is returned.
+.Sh DIAGNOSTICS
+The
+.Nm install
+utility exits 0 on success, and 1 otherwise.
+.Sh FILES
+.Bl -tag -width INS@XXXX -compact
+.It Pa INS@XXXX
+If either
+.Fl S
+option is specified, or the
+.Fl C
+or
+.Fl p
+option is used in conjuction with the
+.Fl s
+option, temporary files named
+.Pa INS@XXXX ,
+where
+.Pa XXXX
+is decided by
+.Xr mkstemp 3 ,
+are created in the target directory.
+.El
+.Sh COMPATIBILITY
+Historically
+.Nm install
+moved files by default.
+The default was changed to copy in
+.Fx 4.4 .
.Sh SEE ALSO
.Xr chflags 1 ,
.Xr chgrp 1 ,
.Xr cp 1 ,
.Xr mv 1 ,
.Xr strip 1 ,
+.Xr mmap 2 ,
.Xr chown 8
.Sh HISTORY
The
-.Nm
+.Nm install
utility appeared in
.Bx 4.2 .
+.Sh BUGS
+Temporary files may be left in the target directory if
+.Nm install
+exits abnormally.
+.Pp
+File flags cannot be set by
+.Xr fchflags 2
+over a NFS file system. Other file systems do not have a concept of flags.
+.Nm install
+will only warn when flags could not be set on a file system
+that does not support them.
+.Pp
+.Nm install
+with
+.Fl v
+falsely says a file is copied when
+.Fl C
+snaps hard links.