diff options
author | 2015-07-18 14:32:36 +0000 | |
---|---|---|
committer | 2015-07-18 14:32:36 +0000 | |
commit | 90a7db4b95589d5208a62de812f03e07f1c5918c (patch) | |
tree | 2d7622c3f698d6cf3e69c4350a4a8f63e922a468 | |
parent | remove note in BUGS about the he capability; (diff) | |
download | wireguard-openbsd-90a7db4b95589d5208a62de812f03e07f1c5918c.tar.xz wireguard-openbsd-90a7db4b95589d5208a62de812f03e07f1c5918c.zip |
add -D to create the full destination path before installing the source into it
ok millert@
-rw-r--r-- | usr.bin/xinstall/install.1 | 9 | ||||
-rw-r--r-- | usr.bin/xinstall/xinstall.c | 19 |
2 files changed, 21 insertions, 7 deletions
diff --git a/usr.bin/xinstall/install.1 b/usr.bin/xinstall/install.1 index 1a6f7039492..015e59334bc 100644 --- a/usr.bin/xinstall/install.1 +++ b/usr.bin/xinstall/install.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: install.1,v 1.25 2010/09/29 07:44:57 jmc Exp $ +.\" $OpenBSD: install.1,v 1.26 2015/07/18 14:32:36 jasper Exp $ .\" $NetBSD: install.1,v 1.4 1994/11/14 04:57:17 jtc Exp $ .\" .\" Copyright (c) 1987, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)install.1 8.1 (Berkeley) 6/6/93 .\" -.Dd $Mdocdate: September 29 2010 $ +.Dd $Mdocdate: July 18 2015 $ .Dt INSTALL 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Nd install binaries .Sh SYNOPSIS .Nm install -.Op Fl bCcdpSs +.Op Fl bCcDdpSs .Op Fl B Ar suffix .Op Fl f Ar flags .Op Fl g Ar group @@ -94,6 +94,8 @@ This is actually the default. The .Fl c option is only included for backwards compatibility. +.It Fl D +Create all leading components of the target before installing into it. .It Fl d Create directories. Missing parent directories are created as required. @@ -209,6 +211,7 @@ utility appeared in .Sh CAVEATS The .Fl C , +.Fl D , .Fl p , and .Fl S diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index f208e5d6416..b88c5ee21e3 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xinstall.c,v 1.59 2015/04/18 03:15:46 guenther Exp $ */ +/* $OpenBSD: xinstall.c,v 1.60 2015/07/18 14:32:36 jasper Exp $ */ /* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */ /* @@ -49,6 +49,7 @@ #include <limits.h> #include <sysexits.h> #include <utime.h> +#include <libgen.h> #include "pathnames.h" @@ -61,7 +62,7 @@ struct passwd *pp; struct group *gp; -int dobackup, docompare, dodir, dopreserve, dostrip, safecopy; +int dobackup, docompare, dodest, dodir, dopreserve, dostrip, safecopy; int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; char pathbuf[PATH_MAX], tempfile[PATH_MAX]; char *suffix = BACKUP_SUFFIX; @@ -90,7 +91,7 @@ main(int argc, char *argv[]) char *flags, *to_name, *group = NULL, *owner = NULL; iflags = 0; - while ((ch = getopt(argc, argv, "B:bCcdf:g:m:o:pSs")) != -1) + while ((ch = getopt(argc, argv, "B:bCcDdf:g:m:o:pSs")) != -1) switch(ch) { case 'C': docompare = 1; @@ -131,6 +132,9 @@ main(int argc, char *argv[]) case 's': dostrip = 1; break; + case 'D': + dodest = 1; + break; case 'd': dodir = 1; break; @@ -168,6 +172,13 @@ main(int argc, char *argv[]) /* NOTREACHED */ } + if (dodest) { + char *dest = dirname(argv[argc - 1]); + if (dest == NULL) + errx(EX_OSERR, "cannot determine dirname"); + install_dir(dest); + } + no_target = stat(to_name = argv[argc - 1], &to_sb); if (!no_target && S_ISDIR(to_sb.st_mode)) { for (; *argv != to_name; ++argv) @@ -603,7 +614,7 @@ void usage(void) { (void)fprintf(stderr, "\ -usage: install [-bCcdpSs] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner]\n source ... target ...\n"); +usage: install [-bCcDdpSs] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner]\n source ... target ...\n"); exit(EX_USAGE); /* NOTREACHED */ } |