Implement -d in install. Update the man page to reflect this change.
This commit is contained in:
parent
38d54d33e4
commit
a9c6b614f6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=18551
@ -30,9 +30,9 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" From: @(#)install.1 8.1 (Berkeley) 6/6/93
|
||||
.\" $Id: install.1,v 1.5 1996/04/06 01:50:39 julian Exp $
|
||||
.\" $Id: install.1,v 1.6 1996/09/24 04:14:58 imp Exp $
|
||||
.\"
|
||||
.Dd October 9, 1995
|
||||
.Dd September 22, 1996
|
||||
.Dt INSTALL 1
|
||||
.Os BSD 4.2
|
||||
.Sh NAME
|
||||
@ -40,14 +40,14 @@
|
||||
.Nd install binaries
|
||||
.Sh SYNOPSIS
|
||||
.Nm install
|
||||
.Op Fl cs
|
||||
.Op Fl CcDps
|
||||
.Op Fl f Ar flags
|
||||
.Op Fl g Ar group
|
||||
.Op Fl m Ar mode
|
||||
.Op Fl o Ar owner
|
||||
.Ar file1 file2
|
||||
.Nm install
|
||||
.Op Fl Ccdps
|
||||
.Op Fl CcDps
|
||||
.Op Fl f Ar flags
|
||||
.Op Fl g Ar group
|
||||
.Op Fl m Ar mode
|
||||
@ -55,6 +55,13 @@
|
||||
.Ar file1
|
||||
\&...
|
||||
.Ar fileN directory
|
||||
.Nm install
|
||||
.Fl d
|
||||
.Op Fl g Ar group
|
||||
.Op Fl m Ar mode
|
||||
.Op Fl o Ar owner
|
||||
.Ar directory
|
||||
\&...
|
||||
.Sh DESCRIPTION
|
||||
The file(s) are moved (or copied if the
|
||||
.Fl c
|
||||
@ -79,18 +86,21 @@ Copy the file.
|
||||
This flag turns off the default behavior of
|
||||
.Nm install
|
||||
where it deletes the original file after creating the target.
|
||||
.It Fl D
|
||||
.It Fl D
|
||||
Print debugging information.
|
||||
If
|
||||
.Fl d
|
||||
.Fl D
|
||||
is specified one or more times,
|
||||
then print the renaming steps for
|
||||
.Fl C .
|
||||
If
|
||||
.Fl d
|
||||
.Fl D
|
||||
is specified two or more times,
|
||||
then warn about files that aren't installed with
|
||||
.Fl C .
|
||||
.It Fl d
|
||||
Create directories.
|
||||
Missing parent directories are created as required.
|
||||
.It Fl f
|
||||
Specify the target's file flags.
|
||||
(See
|
||||
|
@ -80,7 +80,7 @@ static const char rcsid[] =
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
int debug, docompare, docopy, dopreserve, dostrip, verbose;
|
||||
int debug, docompare, dodir, docopy, dopreserve, dostrip, verbose;
|
||||
int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
|
||||
char *group, *owner, pathbuf[MAXPATHLEN];
|
||||
char pathbuf2[MAXPATHLEN];
|
||||
@ -93,6 +93,7 @@ void copy __P((int, char *, int, char *, off_t));
|
||||
int compare __P((int, const char *, int, const char *,
|
||||
const struct stat *, const struct stat *));
|
||||
void install __P((char *, char *, u_long, u_int));
|
||||
void install_dir __P((char *));
|
||||
u_long string_to_flags __P((char **, u_long *, u_long *));
|
||||
void strip __P((char *));
|
||||
void usage __P((void));
|
||||
@ -128,7 +129,7 @@ main(argc, argv)
|
||||
char *flags, *to_name;
|
||||
|
||||
iflags = 0;
|
||||
while ((ch = getopt(argc, argv, "CcDf:g:m:o:psv")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "CcdDf:g:m:o:psv")) != EOF)
|
||||
switch((char)ch) {
|
||||
case 'C':
|
||||
docompare = docopy = 1;
|
||||
@ -139,6 +140,9 @@ main(argc, argv)
|
||||
case 'D':
|
||||
debug++;
|
||||
break;
|
||||
case 'd':
|
||||
dodir = 1;
|
||||
break;
|
||||
case 'f':
|
||||
flags = optarg;
|
||||
if (string_to_flags(&flags, &fset, NULL))
|
||||
@ -172,7 +176,13 @@ main(argc, argv)
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc < 2)
|
||||
|
||||
/* some options make no sense when creating directories */
|
||||
if ((docompare || dostrip) && dodir)
|
||||
usage();
|
||||
|
||||
/* must have at least two arguments, except when creating directories */
|
||||
if (argc < 2 && !dodir)
|
||||
usage();
|
||||
|
||||
#ifdef ALLOW_NUMERIC_IDS
|
||||
@ -192,6 +202,13 @@ main(argc, argv)
|
||||
|
||||
#endif /* ALLOW_NUMERIC_IDS */
|
||||
|
||||
if (dodir) {
|
||||
for (; *argv != NULL; ++argv)
|
||||
install_dir(*argv);
|
||||
exit(EX_OK);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
no_target = stat(to_name = argv[argc - 1], &to_sb);
|
||||
if (!no_target && (to_sb.st_mode & S_IFMT) == S_IFDIR) {
|
||||
for (; *argv != to_name; ++argv)
|
||||
@ -620,6 +637,38 @@ strip(to_name)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* install_dir --
|
||||
* build directory heirarchy
|
||||
*/
|
||||
void
|
||||
install_dir(path)
|
||||
char *path;
|
||||
{
|
||||
register char *p;
|
||||
struct stat sb;
|
||||
int ch;
|
||||
|
||||
for (p = path;; ++p)
|
||||
if (!*p || (p != path && *p == '/')) {
|
||||
ch = *p;
|
||||
*p = '\0';
|
||||
if (stat(path, &sb)) {
|
||||
if (errno != ENOENT || mkdir(path, 0777) < 0) {
|
||||
err(EX_OSERR, "%s", path);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
if (!(*p = ch))
|
||||
break;
|
||||
}
|
||||
|
||||
if (((gid != (gid_t)-1 || uid != (uid_t)-1) && chown(path, uid, gid)) ||
|
||||
chmod(path, mode)) {
|
||||
warn("%s", path);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* usage --
|
||||
* print a usage message and die
|
||||
@ -627,8 +676,10 @@ strip(to_name)
|
||||
void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: install [-CcDps] [-f flags] [-g group] [-m mode] [-o owner] file1 file2;\n\tor file1 ... fileN directory\n");
|
||||
(void)fprintf(stderr,"\
|
||||
usage: install [-CcDpSs] [-f flags] [-g group] [-m mode] [-o owner] file1 file2\n\
|
||||
install [-CcDpSs] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory\n\
|
||||
install -d [-g group] [-m mode] [-o owner] directory ...\n");
|
||||
exit(EX_USAGE);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user