tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
install -v
Hi!
Some install(1) tools have a -v (verbose) option that describes what
they did, and some software uses it. FreeBSD supports it too.
I'd like to add this to NetBSD's install(1). I based the changes on
FreeBSD's version.
Please review & comment!
Thanks,
Thomas
Index: install.1
===================================================================
RCS file: /cvsroot/src/usr.bin/xinstall/install.1,v
retrieving revision 1.47
diff -u -r1.47 install.1
--- install.1 8 Apr 2012 22:00:40 -0000 1.47
+++ install.1 9 May 2024 19:51:02 -0000
@@ -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 @@
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,
Index: xinstall.c
===================================================================
RCS file: /cvsroot/src/usr.bin/xinstall/xinstall.c,v
retrieving revision 1.127
diff -u -r1.127 xinstall.c
--- xinstall.c 20 Jul 2023 16:21:23 -0000 1.127
+++ xinstall.c 9 May 2024 19:51:02 -0000
@@ -120,6 +120,7 @@
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 @@
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 @@
case 'U':
dounpriv = 1;
break;
+ case 'v':
+ verbose = 1;
+ break;
case '?':
default:
usage();
@@ -470,6 +474,8 @@
err(EXIT_FAILURE, "%s: mktemp", tmpl);
ret = link(from_name, tmpl);
if (ret == 0) {
+ if (verbose)
+ printf("install: link %s -> %s\n", from_name, to_name);
ret = rename(tmpl, to_name);
/* If rename has posix semantics, then the temporary
* file may still exist when from_name and to_name point
@@ -478,8 +484,11 @@
(void)unlink(tmpl);
}
return (ret);
- } else
+ } else {
+ if (verbose)
+ printf("install: link %s -> %s\n", from_name, to_name);
return (link(from_name, to_name));
+ }
}
/*
@@ -500,12 +509,16 @@
if (symlink(from_name, tmpl) == -1)
err(EXIT_FAILURE, "symlink %s -> %s", from_name, tmpl);
+ if (verbose)
+ printf("install: symlink %s -> %s\n", from_name, to_name);
if (rename(tmpl, to_name) == -1) {
/* remove temporary link before exiting */
(void)unlink(tmpl);
err(EXIT_FAILURE, "%s: rename", to_name);
}
} else {
+ if (verbose)
+ printf("install: symlink %s -> %s\n", from_name, to_name);
if (symlink(from_name, to_name) == -1)
err(EXIT_FAILURE, "symlink %s -> %s", from_name, to_name);
}
@@ -736,6 +749,8 @@
if ((to_fd = open(to_name,
O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR)) < 0)
err(EXIT_FAILURE, "%s: open", to_name);
+ if (verbose)
+ (void)printf("install: %s -> %s\n", from_name, to_name);
}
digestresult = NULL;
if (!devnull) {
@@ -817,6 +832,8 @@
(void)close(to_fd);
if (dorename) {
+ if (verbose)
+ (void)printf("install: %s -> %s\n", to_name, oto_name);
if (rename(to_name, oto_name) == -1)
err(EXIT_FAILURE, "%s: rename", to_name);
to_name = oto_name;
@@ -1135,6 +1152,8 @@
(void)snprintf(bname, FILENAME_MAX, "%s%s", to_name, suffix);
}
+ if (verbose)
+ (void)printf("install: %s -> %s\n", to_name, bname);
(void)rename(to_name, bname);
}
@@ -1171,6 +1190,8 @@
path);
}
}
+ if (verbose)
+ (void)printf("install: mkdir %s\n", path);
if (!(*p = ch))
break;
}
@@ -1305,13 +1326,13 @@
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);
Home |
Main Index |
Thread Index |
Old Index