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