]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/mergemaster/mergemaster.8
Merge from projects/mips to head by hand:
[FreeBSD/FreeBSD.git] / usr.sbin / mergemaster / mergemaster.8
1 .\" Copyright (c) 1998-2010 Douglas Barton
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 .\" SUCH DAMAGE.
24 .\"
25 .\" $FreeBSD$
26 .\"
27 .Dd January 7, 2010
28 .Dt MERGEMASTER 8
29 .Os
30 .Sh NAME
31 .Nm mergemaster
32 .Nd merge configuration files, et al during an upgrade
33 .Sh SYNOPSIS
34 .Nm
35 .Op Fl scrvahipFCPU
36 .Op Fl m Ar /path/to/sources
37 .Op Fl t Ar /path/to/temp/root
38 .Op Fl d
39 .Op Fl u Ar N
40 .Op Fl w Ar N
41 .Op Fl A Ar Target architecture
42 .Op Fl D Ar /destdir/path
43 .Sh DESCRIPTION
44 The
45 .Nm
46 utility is a Bourne shell script which is designed to aid you
47 in updating the various configuration and other files
48 associated with
49 .Fx .
50 It is
51 .Sy HIGHLY
52 recommended that you back up your
53 .Pa /etc
54 directory before beginning this process.
55 .Pp
56 The script uses
57 .Pa /usr/src/Makefile
58 to build a temporary root environment from
59 .Pa /
60 down, populating that environment with the various
61 files.
62 You can specify a different source directory
63 with the
64 .Fl m
65 command line option, or specify the destination
66 directory with the
67 .Fl D
68 option.
69 It then compares each file in that environment
70 to its installed counterpart.
71 When the script finds a
72 change in the new file, or there is no installed
73 version of the new file it gives you four options to
74 deal with it.
75 You can install the new file as is,
76 delete the new file, merge the old and new
77 files (as appropriate) using
78 .Xr sdiff 1
79 or leave the file in the temporary root environment to
80 merge by hand later.
81 .Pp
82 By default it creates the temporary root in
83 .Pa /var/tmp/temproot
84 and compares the
85 Version Control System (VCS) Id strings ($FreeBSD)
86 for files that have them, deleting
87 the temporary file if the strings match.
88 If there is
89 no Id string, or if the strings are different it
90 compares the files themselves.
91 You can
92 also specify that the script ignore the Id strings and
93 compare every file with the
94 .Fl s
95 option.
96 Using the
97 .Fl F
98 option
99 .Nm
100 will install the new file for you if they differ only by
101 VCS strings.
102 .Pp
103 The merge menu option is designed to let you easily combine your
104 customizations from the old version of a file into the new one.
105 While you can use the merge function to incorporate changes from
106 files that you have not customized,
107 it is not recommended.
108 .Pp
109 The
110 .Nm
111 utility checks your umask and issues a warning for anything
112 other than 022.
113 While it is not mandatory to grant
114 world read permissions for most configuration files, you
115 may run into problems without them.
116 If you choose a
117 umask other than 022 and experience trouble later this
118 could be the cause.
119 .Pa /etc/master.passwd
120 is treated as a special case.
121 If you choose to install
122 this file or a merged version of it the file permissions
123 are always 600 (rw-------) for security reasons.
124 After
125 installing an updated version of this file you should
126 probably run
127 .Xr pwd_mkdb 8
128 with the
129 .Fl p
130 option to rebuild your password databases
131 and recreate
132 .Pa /etc/passwd .
133 .Pp
134 The script uses the owner and group ids
135 that the files are created with by
136 .Pa /usr/src/etc/Makefile ,
137 and file permissions as specified by the umask.
138 Unified diffs are used by default to display any
139 differences unless you choose context diffs.
140 .Pp
141 The
142 .Nm
143 utility will source scripts that you specify right before
144 it starts the comparison, and after it is done running.
145 The easiest way to handle this is to place the path
146 to the script(s) in the appropriate variables in your
147 .Pa .mergemasterrc
148 file.
149 The script sourced before comparison is named in
150 .Ev MM_PRE_COMPARE_SCRIPT ,
151 and the one sourced after the script is done is
152 .Ev MM_EXIT_SCRIPT .
153 This is the recommended way to specify local modifications,
154 or files that you want to give special handling to.
155 This includes files that you want to be deleted without
156 being compared.
157 Because the named scripts are sourced from within
158 .Nm ,
159 all of the script's variables are available for use in
160 your custom script.
161 You can also use
162 .Pa /etc/mergemaster.rc
163 which will be read before
164 .Pa .mergemasterrc .
165 Options specified on the command line are updated last,
166 and therefore can override both files.
167 .Pp
168 When the comparison is done if there are any files remaining
169 in the temproot directory they will be listed, and if the
170 .Fl a
171 option is not in use the user will be given the option of 
172 deleting the temproot directory.
173 If there are no files remaining in the temproot directory
174 it will be deleted.
175 .Pp
176 The options are as follows:
177 .Bl -tag -width Fl
178 .It Fl s
179 Perform a strict comparison, diffing every pair of files.
180 This comparison is performed line by line,
181 without regard to VCS Ids.
182 .It Fl c
183 Use context diffs instead of unified diffs.
184 .It Fl r
185 Re-run
186 .Nm
187 on a previously cleaned directory, skipping the creation of
188 the temporary root environment.
189 This option is compatible
190 with all other options.
191 .It Fl v
192 Be more verbose about the process.
193 You should probably use
194 this option the first time you run
195 .Nm .
196 This option also gives you a list of files that exist
197 only in the installed version of
198 .Pa /etc .
199 .It Fl a
200 Run automatically.
201 This option will leave all the files that
202 differ from the installed versions in the temporary directory
203 to be dealt with by hand.
204 If the
205 .Pa temproot
206 directory exists, it creates a new one in a previously
207 non-existent directory.
208 This option unsets the verbose flag,
209 but other than
210 .Fl U
211 it is compatible with all other options.
212 Setting
213 .Fl a
214 makes
215 .Fl w
216 superfluous.
217 .It Fl h
218 Display usage and help information.
219 .It Fl i
220 Automatically install any files that do not exist in the
221 destination directory.
222 .It Fl p
223 Pre-buildworld mode.
224 Compares only files known to be essential to the success of
225 {build|install}world,
226 including
227 .Pa /etc/make.conf .
228 .It Fl F
229 If the files differ only by VCS Id ($FreeBSD)
230 install the new file.
231 .It Fl C
232 After a standard
233 .Nm
234 run,
235 compares your rc.conf[.local] options to the defaults.
236 .It Fl P
237 Preserve files that you replace in
238 .Pa /var/tmp/mergemaster/preserved-files-<date> ,
239 or another directory you specify in your
240 .Nm
241 rc file.
242 .It Fl U
243 Attempt to auto upgrade files that have not been user modified.
244 .It Fl m Ar /path/to/sources
245 Specify the path to the directory where you want to do the
246 .Xr make 1 .
247 (In other words, where your sources are, but -s was already
248 taken.)
249 In previous versions of
250 .Nm
251 you needed to specify the path all the way to
252 .Pa src/etc .
253 Starting with r186678 you only need to specify the path to
254 .Pa src .
255 .Nm
256 will convert the path for you if you use the old method.
257 .It Fl t Ar /path/to/temp/root
258 Create the temporary root environment in
259 .Pa /path/to/temp/root
260 instead of the default
261 .Pa /var/tmp/temproot .
262 .It Fl d
263 Add the date and time to the name of the temporary
264 root directory.
265 If
266 .Fl t
267 is specified, this option must
268 follow it if you want the date added too.
269 .It Fl u Ar N
270 Specify a numeric umask.
271 The default is 022.
272 .It Fl w Ar N
273 Supply an alternate screen width to the
274 .Xr sdiff 1
275 command in numbers of columns.
276 The default is 80.
277 .It Fl A Ar Target architecture
278 Specify an alternative
279 .Ev TARGET_ARCH
280 architecture name.
281 .It Fl D Ar /path
282 Specify the destination directory for the installed files.
283 .El
284 .Sh ENVIRONMENT
285 The
286 .Nm
287 utility uses the
288 .Ev PAGER
289 environment variable if set.
290 Otherwise it uses
291 .Xr more 1 .
292 If
293 .Ev PAGER
294 specifies a program outside
295 its
296 limited
297 .Ev PATH
298 without specifying the full path,
299 .Nm
300 prompts you with options on how to proceed.
301 The
302 .Ev MM_PRE_COMPARE_SCRIPT
303 and
304 .Ev MM_EXIT_SCRIPT
305 variables are used as described above.
306 Other variables that are used by the script internally
307 can be specified in
308 .Pa .mergemasterrc
309 as described in more detail below.
310 .Sh FILES
311 .Bl -tag -width $HOME/.mergemasterrc -compact
312 .It Pa /etc/mergemaster.rc
313 .It Pa $HOME/.mergemasterrc
314 .El
315 .Pp
316 The
317 .Nm
318 utility will
319 .Ic .\&
320 (source) these files if they exist.
321 Command line options
322 will override rc file options.
323 .Pa $HOME/.mergemasterrc
324 overrides
325 .Pa /etc/mergemaster.rc .
326 Here is an example
327 with all values commented out:
328 .Pp
329 .Bd -literal
330 # These are options for mergemaster, with their default values listed
331 # The following options have command line overrides
332 #
333 # The target architecture (-A, unset by default)
334 #ARCHSTRING='TARGET_ARCH=<foo>'
335 #
336 # Sourcedir is the directory to do the 'make' in (-m)
337 #SOURCEDIR='/usr/src'
338 #
339 # Directory to install the temporary root environment into (-t)
340 #TEMPROOT='/var/tmp/temproot'
341 #
342 # Specify the destination directory for the installed files (-D)
343 #DESTDIR=
344 #
345 # Strict comparison skips the VCS Id test and compares every file (-s)
346 #STRICT=no
347 #
348 # Type of diff, such as unified, context, etc. (-c)
349 #DIFF_FLAG='-u'
350 #
351 # Install the new file if it differs only by VCS Id ($FreeBSD, -F)
352 #FREEBSD_ID=
353 #
354 # Verbose mode includes more details and additional checks (-v)
355 #VERBOSE=
356 #
357 # Automatically install files that do not exist on the system already (-i)
358 #AUTO_INSTALL=
359 #
360 # Automatically upgrade files that have not been user modified (-U)
361 #AUTO_UPGRADE=
362 #
363 # Compare /etc/rc.conf[.local] to /etc/defaults/rc.conf (-C)
364 #COMP_CONFS=
365 #
366 # Preserve files that you replace (-P)
367 #PRESERVE_FILES=
368 #PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
369 #
370 # The umask for mergemaster to compare the default file's modes to (-u)
371 #NEW_UMASK=022
372 #
373 # The following options have no command line overrides
374 #
375 # Files to always avoid comparing
376 #IGNORE_FILES='/etc/motd /etc/printcap foo bar'
377 #
378 # Additional options for diff.  This will get unset when using -s.
379 #DIFF_OPTIONS='-Bb'     # Ignore changes in whitespace
380 #
381 # Location to store the list of mtree values for AUTO_UPGRADE purposes
382 #MTREEDB='/var/db'
383 #
384 # For those who just cannot stand including the full path to PAGER
385 #DONT_CHECK_PAGER=
386 #
387 # If you set 'yes' above, make sure to include the PATH to your pager
388 #PATH=/bin:/usr/bin:/usr/sbin
389 #
390 # Delete stale files in /etc/rc.d without prompting
391 #DELETE_STALE_RC_FILES=
392 #
393 # Specify the path to scripts to run before the comparison starts,
394 # and/or after the script has finished its work
395 #MM_PRE_COMPARE_SCRIPT=
396 #MM_EXIT_SCRIPT=
397 .Ed
398 .Sh EXIT STATUS
399 Exit status is 0 on successful completion, or if the user bails out
400 manually at some point during execution.
401 .Pp
402 Exit status is 1 if it fails for one of the following reasons:
403 .Pp
404 Invalid command line option
405 .Pp
406 Failure to create the temporary root environment
407 .Pp
408 Failure to populate the temporary root
409 .Pp
410 Presence of the 'nodev' option in
411 .Pa <DESTDIR>/etc/fstab
412 .Pp
413 Failure to install a file
414 .Sh EXAMPLES
415 Typically all you will need to do is type
416 .Nm
417 at the prompt and the script will do all the work for you.
418 .Pp
419 To use context diffs and have
420 .Nm
421 explain more things as it goes along, use:
422 .Pp
423 .Dl # mergemaster -cv
424 .Pp
425 To specify that
426 .Nm
427 put the temporary root environment in
428 .Pa /usr/tmp/root ,
429 use:
430 .Pp
431 .Dl # mergemaster -t /usr/tmp/root
432 .Pp
433 To specify a 110 column screen with a strict
434 comparison, use:
435 .Pp
436 .Dl # mergemaster -sw 110
437 .Sh SEE ALSO
438 .Xr diff 1 ,
439 .Xr make 1 ,
440 .Xr more 1 ,
441 .Xr sdiff 1 ,
442 .Xr pwd_mkdb 8
443 .Pp
444 .Pa /usr/src/etc/Makefile
445 .Rs
446 .%O http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
447 .%T The Cutting Edge (using make world)
448 .%A Nik Clayton
449 .Re
450 .Sh HISTORY
451 The
452 .Nm
453 utility was first publicly available on one of my
454 web pages in a much simpler form under the name
455 .Pa comproot
456 on 13 March 1998.
457 The idea for creating the
458 temporary root environment comes from Nik Clayton's
459 make world tutorial which is referenced above.
460 .Sh AUTHORS
461 This manual page and the script itself were written by
462 .An Douglas Barton Aq DougB@FreeBSD.org .
463 .Sh BUGS
464 There are no known bugs.
465 Please report any problems,
466 comments or suggestions to the author.
467 Several of the
468 improvements to this program have come from user
469 suggestions.
470 Thank you.