nstall(1): add support for -v
Reviewed by rillig@ and thorpej@, thanks!
This commit is contained in:
parent
40dd220a53
commit
30bb22f9da
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: install.1,v 1.47 2012/04/08 22:00:40 wiz Exp $
|
||||
.\" $NetBSD: install.1,v 1.48 2024/05/10 09:14:52 wiz Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1987, 1990, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
@ -29,7 +29,7 @@
|
|||
.\"
|
||||
.\" @(#)install.1 8.1 (Berkeley) 6/6/93
|
||||
.\"
|
||||
.Dd May 1, 2009
|
||||
.Dd May 9, 2024
|
||||
.Dt INSTALL 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -37,7 +37,7 @@
|
|||
.Nd install binaries
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl bcprsU
|
||||
.Op Fl bcprsUv
|
||||
.Op Fl a Ar command
|
||||
.Op Fl B Ar suffix
|
||||
.Op Fl D Ar destdir
|
||||
|
@ -297,6 +297,11 @@ try to change the owner, the group, or the file flags of the destination.
|
|||
The information that would have been updated can be stored in a log
|
||||
file with
|
||||
.Fl M Ar metalog .
|
||||
.It Fl v
|
||||
Cause
|
||||
.Nm
|
||||
to be verbose,
|
||||
showing files as they are installed or backed up.
|
||||
.El
|
||||
.Pp
|
||||
By default,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: xinstall.c,v 1.127 2023/07/20 16:21:23 lukem Exp $ */
|
||||
/* $NetBSD: xinstall.c,v 1.128 2024/05/10 09:14:52 wiz Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
|
@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)xinstall.c 8.1 (Berkeley) 7/21/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: xinstall.c,v 1.127 2023/07/20 16:21:23 lukem Exp $");
|
||||
__RCSID("$NetBSD: xinstall.c,v 1.128 2024/05/10 09:14:52 wiz Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -120,6 +120,7 @@ __RCSID("$NetBSD: xinstall.c,v 1.127 2023/07/20 16:21:23 lukem Exp $");
|
|||
static int dobackup, dodir, dostrip, dolink, dopreserve, dorename, dounpriv;
|
||||
static int haveopt_f, haveopt_g, haveopt_m, haveopt_o;
|
||||
static int numberedbackup;
|
||||
static int verbose;
|
||||
static int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
|
||||
static char pathbuf[MAXPATHLEN];
|
||||
static uid_t uid = -1;
|
||||
|
@ -186,7 +187,7 @@ main(int argc, char *argv[])
|
|||
setprogname(argv[0]);
|
||||
|
||||
iflags = 0;
|
||||
while ((ch = getopt(argc, argv, "a:cbB:dD:f:g:h:l:m:M:N:o:prsS:T:U"))
|
||||
while ((ch = getopt(argc, argv, "a:cbB:dD:f:g:h:l:m:M:N:o:prsS:T:Uv"))
|
||||
!= -1)
|
||||
switch((char)ch) {
|
||||
case 'a':
|
||||
|
@ -307,6 +308,9 @@ main(int argc, char *argv[])
|
|||
case 'U':
|
||||
dounpriv = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
|
@ -477,9 +481,12 @@ do_link(char *from_name, char *to_name)
|
|||
*/
|
||||
(void)unlink(tmpl);
|
||||
}
|
||||
return (ret);
|
||||
} else
|
||||
return (link(from_name, to_name));
|
||||
} else {
|
||||
ret = link(from_name, to_name);
|
||||
}
|
||||
if (ret == 0 && verbose)
|
||||
(void)printf("install: link %s -> %s\n", from_name, to_name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -509,6 +516,8 @@ do_symlink(char *from_name, char *to_name)
|
|||
if (symlink(from_name, to_name) == -1)
|
||||
err(EXIT_FAILURE, "symlink %s -> %s", from_name, to_name);
|
||||
}
|
||||
if (verbose)
|
||||
(void)printf("install: symlink %s -> %s\n", from_name, to_name);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -821,6 +830,8 @@ install(char *from_name, char *to_name, u_int flags)
|
|||
err(EXIT_FAILURE, "%s: rename", to_name);
|
||||
to_name = oto_name;
|
||||
}
|
||||
if (verbose)
|
||||
(void)printf("install: %s -> %s\n", from_name, to_name);
|
||||
|
||||
/*
|
||||
* If provided a set of flags, set them, otherwise, preserve the
|
||||
|
@ -1135,7 +1146,10 @@ backup(const char *to_name)
|
|||
(void)snprintf(bname, FILENAME_MAX, "%s%s", to_name, suffix);
|
||||
}
|
||||
|
||||
(void)rename(to_name, bname);
|
||||
if (rename(to_name, bname) == 0) {
|
||||
if (verbose)
|
||||
(void)printf("install: %s -> %s\n", to_name, bname);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1171,6 +1185,8 @@ install_dir(char *path, u_int flags)
|
|||
path);
|
||||
}
|
||||
}
|
||||
if (verbose)
|
||||
(void)printf("install: mkdir %s\n", path);
|
||||
if (!(*p = ch))
|
||||
break;
|
||||
}
|
||||
|
@ -1305,13 +1321,13 @@ usage(void)
|
|||
prog = getprogname();
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: %s [-Ubcprs] [-M log] [-D dest] [-T tags] [-B suffix]\n"
|
||||
"usage: %s [-bcprsUv] [-M log] [-D dest] [-T tags] [-B suffix]\n"
|
||||
" [-a aftercmd] [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group] \n"
|
||||
" [-l linkflags] [-h hash] [-S stripflags] file1 file2\n"
|
||||
" %s [-Ubcprs] [-M log] [-D dest] [-T tags] [-B suffix]\n"
|
||||
" %s [-bcprsUv] [-M log] [-D dest] [-T tags] [-B suffix]\n"
|
||||
" [-a aftercmd] [-f flags] [-m mode] [-N dbdir] [-o owner] [-g group]\n"
|
||||
" [-l linkflags] [-h hash] [-S stripflags] file1 ... fileN directory\n"
|
||||
" %s -d [-Up] [-M log] [-D dest] [-T tags] [-a aftercmd] [-m mode]\n"
|
||||
" %s -d [-pUv] [-M log] [-D dest] [-T tags] [-a aftercmd] [-m mode]\n"
|
||||
" [-N dbdir] [-o owner] [-g group] directory ...\n",
|
||||
prog, prog, prog);
|
||||
exit(1);
|
||||
|
|
Loading…
Reference in New Issue