summaryrefslogtreecommitdiff
path: root/bin/clone.1
blob: 7c36d90fd854ea5e45605cd39f370e0d6e2127b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
.TH CLONE 1 "6 June 1989" ""
.SH NAME
clone \- make a clone of an entire directory tree
.SH SYNOPSIS
.B clone
[
.B -q
] [
.B -v
] [
.B -f
] [
.B -c | -s
] [
.B -S
]
.I "dir1 dir2"
.SH DESCRIPTION
.I Clone
makes an identical copy of an entire (source) directory tree rooted at
the directory named
.I dir1
into the (target) directory tree
rooted at
.I dir2.
The target directory
.I dir2
will be created if it does not already exist.
On the other hand, if the directory
.I dir2
exists, or if the
.I dir2
directory has any existing subdirectories, then these
directories will
.B not
be deleted or replaced by
.I clone.
.PP
.I Clone
normally creates the clone
directory tree by creating any new directories needed
beneath
.I dir2
(possibly including
.I dir2
itself).
.I Clone
then fills in the new directories with hard links
to all of the files in the original (source) directory tree
.I dir1
such that the new (target) directory tree appears to also contain
all of the files and subdirectories contained in the original (source)
directory tree.
Hard links are normally used when creating
.I clones
of the files in the source directory tree
inside the new (target) directory tree.
This insures that the cost (in disk space) of
.I cloning
a given source directory tree will be very low.
If desired, the new (clone) directory tree can be filled in with
symbolic links or with actual copies of the original files (instead of
using hard links).
.PP
.I Clone
may  be particularly useful for maintaining multiple versions
of nearly identical source trees.
.PP
An important feature of
.I clone
is that the
.I dir2
argument may already exist and may already contain some
files and subdirectories.  In such cases,
.I clone
does not disturb these existing files or subdirectories.
Rather, it simply adds the material from the source directory,
.I dir1,
to the material already present within
.I dir2.
In cases where
there are conflicts between files or directories which
already exist in
.I dir2
but which also exist in
.I dir1,
.I clone
(by default) leaves the files or directories in the target directory
.I dir2
untouched unless the
.B -f
(force) flag is used, in which case,
.I clone
will override (i.e. delete) the conflicting entries
from the target directory
.I dir2
and replace them with clones from the source directory
.I dir1.
.SH OPTIONS
.I Clone
recognizes the following options:
.TP
.BI \-q
Quite mode.  Suppress all warnings and non-fatal error messages.
.TP
.BI \-v
Verbose mode.  Print verbose messages which describe each individual
linking (or copying) action, as well as all
.I mkdir
actions that
.I clone
executes.
.TP
.BI \-f
Force mode.  In cases where an item (i.e. either a file or a directory)
exists in the source directory tree
.I dir1,
and also already exists in the target directory tree
.I dir2,
delete the item (ether a file or a directory) in 
the target directory tree and then replace it with a clone
of the corresponding item from the source directory tree.
All such deletions causes warning to be issued to
.I stderr
unless the
.B \-q
(quite mode)
option is also specified.
Note that if a given item already exists in the target directory tree,
and if it also exists in the source directory tree, and if both the
(existing) source and target items are themselves directories, then the
.B \-f
option has no effect for these items.  Existing directories in the
target directory tree are never deleted by
.I clone
unless there is a corresponding item in the source directory tree which is
.B not
a directory (i.e. is a regular file) and the
.B \-f
option is in effect.
.TP
.BI \-s
Symbolic link mode (not available on System V).  When used, this
option causes all non-directory files to be
.I cloned
by making symbolic links from the target directory tree into the source
directory tree.  This mode overrides the default mode in which
hard links are used to clone all non-directory files.
.TP
.BI \-c
Copy mode.
In this mode, a physical copy of each non-directory file in the source directory
tree is created in the target directory tree. Note that when this mode is used,
it is an error for the source directory tree to contain any block or character
device files, or any named pipe files.
.TP
.BI \-S
SCCS mode.
In this mode, only the source tree structure is cloned, not its contents.
Symbolic links are created within the destination tree to subdirectories 
in the source tree named
.B SCCS.
This mode is useful when multiple developers work from a common SCCS project
tree. To accomplish this, each developer creates a local project tree by
.I cloning
the common SCCS project directory, specifying the 
.B \-S
option.
Individual developers are then able to work within their local project tree while 
ensuring that all SCCS operations are applied to the common SCCS project tree.
Use of the 
.B \-S
option implies the use of the 
.B \-s
option and is thus not available on System V.
.SH EXAMPLES
Assume that you have
two directory trees called
.I src1
and
.I src2
and that you wish to combine the contents of these
two directories into a new directory named
.I dst
such that if there are any files with duplicate names in both
.I src1
and in
.I src2
the files from the
.I src2
directory tree will take precedence
over the corresponding files in the directory tree
.I src1.
The following commands would accomplish this task:
.sp 1
.in +0.4i
.ft B
clone  src1 dst
.br
clone  -f src2 dst
.sp 1
.in -0.4i
.ft R
Or alternatively, for this simple case, you could have said:
.ft B
.in +0.4i
.sp 1
clone  src2 dst
.br
clone  src1 dst
.br
.sp 1
.in -04.i
.ft R
.PP
To clone an SCCS project tree, such as
.B /pub/EOS_client_server,
one might use the following command, shown with the resulting output:
.sp 1
.in +0.4i
.ft B
doc% clone -S -v  /pub/EOS_client_server ~/EOS_CS
.br
clone: created new output directory: /home/ebupsn/EOS_CS
.br
clone: created new output directory: /home/ebupsn/EOS_CS/bin
.br
clone: created new output directory: /home/ebupsn/EOS_CS/lib
.br
clone: created new output directory: /home/ebupsn/EOS_CS/include
.br
clone: created new output directory: /home/ebupsn/EOS_CS/cmd
.br
clone: created new output directory: /home/ebupsn/EOS_CS/cmd/clone
.br
clone: created symlink /home/ebupsn/EOS_CS/cmd/clone/SCCS -> /pub/EOS_client_server/cmd/clone/SCCS
.br
clone: created symlink /home/ebupsn/EOS_CS/cmd/SCCS -> /pub/EOS_client_server/cmd/SCCS
.br
clone: created new output directory: /home/ebupsn/EOS_CS/man
.br
clone: created new output directory: /home/ebupsn/EOS_CS/man/man1
.br
clone: created new output directory: /home/ebupsn/EOS_CS/man/man3
.br
clone: created new output directory: /home/ebupsn/EOS_CS/man/cat1
.br
clone: created new output directory: /home/ebupsn/EOS_CS/man/cat3
.br
clone: created symlink /home/ebupsn/EOS_CS/SCCS -> /pub/EOS_client_server/SCCS
.br
.sp 1
.in -0.4i
.ft R
.SH CAVEATS
On BSD systems, if there are symbolic links in the source tree,
the effects of
.I cloning
may not be what you expect. 
A symbolic link within the source tree results in the creation of an 
identical symbolic link within the destination tree.
A warning is issued if the symbolic link is either absolute and points 
into the source directory or if the symbolic link is relative and 
points out of the source tree.
.PP
If the 
.B \-S
option is in effect and the source directory is itself a symbolic link
to a directory, the contents of the symbolic link are cloned in the
destination directory rather than setting the destination directory 
to be an identical symbolic link.
The rational for this is as follows.  
In networked environments, SCCS project directories are often configured
as NFS file systems managed by an NFS auto-mount daemon.
The NFS auto-mount daemon mounts NFS file systems in a temporary locations
and then creates symbolic links to the temporary locations.
Accesses to this symbolic links trigger the NFS auto-mount daemon.
It is therefore necessary that symbolic links in the destination tree
refer to the NFS auto-mount point symbolic link rather than to the NFS 
auto-mount point itself.
Symbolic links within the source tree are ignored.
.SH WARNINGS
There are numerous possible warning and/or error messages which
.I clone
will issue for strange circumstances.
These should all be self-explanatory.
.SH FILES
.ta 1.7i
/usr/local/bin/clone	The clone program
.SH "SEE ALSO"
ln(1), link(2), symlink(2), readlink(2), mkdir (1), mkdir (2)
.SH AUTHORS
Written by Ron Guilmette at the Microelectronics and Computer Technology
Corporation.  Current E-mail address is rfg@ics.uci.edu.
.PP
SCCS mode added 07-April-1993 by Paul Stephenson at Ericsson Business
Communications.  Current E-mail address is paul.stephenson@ebu.ericsson.se.