View | Details | Raw Unified | Return to bug 122271
Collapse All | Expand All

(-)xinstall/install.1 (-2 / +5 lines)
Lines 40-46 Link Here
40
.Nd install binaries
40
.Nd install binaries
41
.Sh SYNOPSIS
41
.Sh SYNOPSIS
42
.Nm
42
.Nm
43
.Op Fl bCcMpSsv
43
.Op Fl bCcDMpSsv
44
.Op Fl B Ar suffix
44
.Op Fl B Ar suffix
45
.Op Fl f Ar flags
45
.Op Fl f Ar flags
46
.Op Fl g Ar group
46
.Op Fl g Ar group
Lines 48-54 Link Here
48
.Op Fl o Ar owner
48
.Op Fl o Ar owner
49
.Ar file1 file2
49
.Ar file1 file2
50
.Nm
50
.Nm
51
.Op Fl bCcMpSsv
51
.Op Fl bCcDMpSsv
52
.Op Fl B Ar suffix
52
.Op Fl B Ar suffix
53
.Op Fl f Ar flags
53
.Op Fl f Ar flags
54
.Op Fl g Ar group
54
.Op Fl g Ar group
Lines 112-117 Link Here
112
.It Fl d
112
.It Fl d
113
Create directories.
113
Create directories.
114
Missing parent directories are created as required.
114
Missing parent directories are created as required.
115
.It Fl D
116
If necessary, create target's parent directories before
117
installing file(s).
115
.It Fl f
118
.It Fl f
116
Specify the target's file flags; see
119
Specify the target's file flags; see
117
.Xr chflags 1
120
.Xr chflags 1
(-)xinstall/xinstall.c (-6 / +40 lines)
Lines 82-88 Link Here
82
struct group *gp;
82
struct group *gp;
83
gid_t gid;
83
gid_t gid;
84
uid_t uid;
84
uid_t uid;
85
int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose;
85
int dobackup, docompare, doparentdir, dodir, dopreserve, dostrip, nommap, safecopy, verbose;
86
mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
86
mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
87
const char *suffix = BACKUP_SUFFIX;
87
const char *suffix = BACKUP_SUFFIX;
88
88
Lines 92-97 Link Here
92
int	create_tempfile(const char *, char *, size_t);
92
int	create_tempfile(const char *, char *, size_t);
93
void	install(const char *, const char *, u_long, u_int);
93
void	install(const char *, const char *, u_long, u_int);
94
void	install_dir(char *);
94
void	install_dir(char *);
95
void	install_parentdir(char *);
95
u_long	numeric_id(const char *, const char *);
96
u_long	numeric_id(const char *, const char *);
96
void	strip(const char *);
97
void	strip(const char *);
97
int	trymmap(int);
98
int	trymmap(int);
Lines 110-116 Link Here
110
111
111
	iflags = 0;
112
	iflags = 0;
112
	group = owner = NULL;
113
	group = owner = NULL;
113
	while ((ch = getopt(argc, argv, "B:bCcdf:g:Mm:o:pSsv")) != -1)
114
	while ((ch = getopt(argc, argv, "B:bCcDdf:g:Mm:o:pSsv")) != -1)
114
		switch((char)ch) {
115
		switch((char)ch) {
115
		case 'B':
116
		case 'B':
116
			suffix = optarg;
117
			suffix = optarg;
Lines 124-129 Link Here
124
		case 'c':
125
		case 'c':
125
			/* For backwards compatibility. */
126
			/* For backwards compatibility. */
126
			break;
127
			break;
128
		case 'D':
129
			doparentdir = 1;
130
			break;
127
		case 'd':
131
		case 'd':
128
			dodir = 1;
132
			dodir = 1;
129
			break;
133
			break;
Lines 211-216 Link Here
211
		/* NOTREACHED */
215
		/* NOTREACHED */
212
	}
216
	}
213
217
218
	if (doparentdir) {
219
		if(argc == 2) install_parentdir(argv[argc - 1]);
220
		/*
221
		 * more than one file to install :
222
		 * destination has to be a directory
223
		 */
224
		else install_dir(argv[argc - 1]);
225
	}
226
214
	no_target = stat(to_name = argv[argc - 1], &to_sb);
227
	no_target = stat(to_name = argv[argc - 1], &to_sb);
215
	if (!no_target && S_ISDIR(to_sb.st_mode)) {
228
	if (!no_target && S_ISDIR(to_sb.st_mode)) {
216
		for (; *argv != to_name; ++argv)
229
		for (; *argv != to_name; ++argv)
Lines 219-226 Link Here
219
		/* NOTREACHED */
232
		/* NOTREACHED */
220
	}
233
	}
221
234
222
	/* can't do file1 file2 directory/file */
235
	/*
223
	if (argc != 2) {
236
	 * can do file1 file2 directory/ only if parent
237
	 * directories have been created
238
	 */
239
	if ((argc != 2) && (!doparentdir)) {
224
		if (no_target)
240
		if (no_target)
225
			warnx("target directory `%s' does not exist", 
241
			warnx("target directory `%s' does not exist", 
226
			    argv[argc - 1]);
242
			    argv[argc - 1]);
Lines 767-772 Link Here
767
}
783
}
768
784
769
/*
785
/*
786
 * install_parentdir --
787
 *	build directory hierarchy
788
 *  ignoring last non-directory part
789
 */
790
void
791
install_parentdir(char *path)
792
{
793
	char parentpath[MAXPATHLEN];
794
	char *p;
795
796
	(void)strncpy(parentpath, path, MAXPATHLEN);
797
	if ((p = strrchr(parentpath, '/')) != NULL) {
798
		*p = '\0';
799
		install_dir(parentpath);
800
	}
801
}
802
803
/*
770
 * usage --
804
 * usage --
771
 *	print a usage message and die
805
 *	print a usage message and die
772
 */
806
 */
Lines 774-782 Link Here
774
usage()
808
usage()
775
{
809
{
776
	(void)fprintf(stderr,
810
	(void)fprintf(stderr,
777
"usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
811
"usage: install [-bCcDpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
778
"               [-o owner] file1 file2\n"
812
"               [-o owner] file1 file2\n"
779
"       install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
813
"       install [-bCcDpSsv] [-B suffix] [-f flags] [-g group] [-m mode]\n"
780
"               [-o owner] file1 ... fileN directory\n"
814
"               [-o owner] file1 ... fileN directory\n"
781
"       install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n");
815
"       install -d [-v] [-g group] [-m mode] [-o owner] directory ...\n");
782
	exit(EX_USAGE);
816
	exit(EX_USAGE);

Return to bug 122271