]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - usr.sbin/mergemaster/mergemaster.8
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / usr.sbin / mergemaster / mergemaster.8
1 .\" Copyright (c) 1998-2009 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 March 18, 2009
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 .Op Fl m
65 command line option, or specify the destination
66 directory with the
67 .Op 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 .Op Fl s
95 option.
96 Using the
97 .Op 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 .Op 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 The options are as follows:
169 .Bl -tag -width Fl
170 .It Fl s
171 Perform a strict comparison, diffing every pair of files.
172 This comparison is performed line by line,
173 without regard to VCS Ids.
174 .It Fl c
175 Use context diffs instead of unified diffs.
176 .It Fl r
177 Re-run
178 .Nm
179 on a previously cleaned directory, skipping the creation of
180 the temporary root environment.
181 This option is compatible
182 with all other options.
183 .It Fl v
184 Be more verbose about the process.
185 You should probably use
186 this option the first time you run
187 .Nm .
188 This option also gives you a list of files that exist
189 only in the installed version of
190 .Pa /etc .
191 .It Fl a
192 Run automatically.
193 This option will leave all the files that
194 differ from the installed versions in the temporary directory
195 to be dealt with by hand.
196 If the
197 .Pa temproot
198 directory exists, it creates a new one in a previously
199 non-existent directory.
200 This option unsets the verbose flag,
201 but is compatible with all other options.
202 Setting
203 .Op Fl a
204 makes
205 .Op Fl w
206 superfluous.
207 .It Fl h
208 Display usage and help information.
209 .It Fl i
210 Automatically install any files that do not exist in the
211 destination directory.
212 .It Fl p
213 Pre-buildworld mode.
214 Compares only files known to be essential to the success of
215 {build|install}world,
216 including
217 .Pa /etc/make.conf .
218 .It Fl F
219 If the files differ only by VCS Id ($FreeBSD)
220 install the new file.
221 .It Fl C
222 After a standard
223 .Nm
224 run,
225 compares your rc.conf[.local] options to the defaults.
226 .It Fl P
227 Preserve files that you replace in
228 .Pa /var/tmp/mergemaster/preserved-files-<date> ,
229 or another directory you specify in your
230 .Nm
231 rc file.
232 .It Fl U
233 Attempt to auto upgrade files that have not been user modified.
234 .It Fl m Ar /path/to/sources
235 Specify the path to the directory where you want to do the
236 .Xr make 1 .
237 (In other words, where your sources are, but -s was already
238 taken.)
239 In previous versions of
240 .Nm
241 you needed to specify the path all the way to
242 .Pa src/etc .
243 Starting with r186678 you only need to specify the path to
244 .Pa src .
245 .Nm
246 will convert the path for you if you use the old method.
247 .It Fl t Ar /path/to/temp/root
248 Create the temporary root environment in
249 .Pa /path/to/temp/root
250 instead of the default
251 .Pa /var/tmp/temproot .
252 .It Fl d
253 Add the date and time to the name of the temporary
254 root directory.
255 If
256 .Op Fl t
257 is specified, this option must
258 follow it if you want the date added too.
259 .It Fl u Ar N
260 Specify a numeric umask.
261 The default is 022.
262 .It Fl w Ar N
263 Supply an alternate screen width to the
264 .Xr sdiff 1
265 command in numbers of columns.
266 The default is 80.
267 .It Fl A Ar Target architecture
268 Specify an alternative
269 .Ev TARGET_ARCH
270 architecture name.
271 .It Fl D Ar /path
272 Specify the destination directory for the installed files.
273 .El
274 .Sh ENVIRONMENT
275 The
276 .Nm
277 utility uses the
278 .Ev PAGER
279 environment variable if set.
280 Otherwise it uses
281 .Xr more 1 .
282 If
283 .Ev PAGER
284 specifies a program outside
285 its
286 limited
287 .Ev PATH
288 without specifying the full path,
289 .Nm
290 prompts you with options on how to proceed.
291 The
292 .Ev MM_PRE_COMPARE_SCRIPT
293 and
294 .Ev MM_EXIT_SCRIPT
295 variables are used as described above.
296 Other variables that are used by the script internally
297 can be specified in
298 .Pa .mergemasterrc
299 as described in more detail below.
300 .Sh FILES
301 .Bl -tag -width $HOME/.mergemasterrc -compact
302 .It Pa /etc/mergemaster.rc
303 .It Pa $HOME/.mergemasterrc
304 .El
305 .Pp
306 The
307 .Nm
308 utility will
309 .Ic .\&
310 (source) these files if they exist.
311 Command line options
312 will override rc file options.
313 .Pa $HOME/.mergemasterrc
314 overrides
315 .Pa /etc/mergemaster.rc .
316 Here is an example
317 with all values commented out:
318 .Pp
319 .Bd -literal
320 # These are options for mergemaster, with their default values listed
321 # The following options have command line overrides
322 #
323 # The target architecture (unset by default)
324 #ARCHSTRING='TARGET_ARCH=<foo>'
325 #
326 # Sourcedir is the directory to do the 'make' in (where the new files are)
327 #SOURCEDIR='/usr/src'
328 #
329 # Directory to install the temporary root environment into
330 #TEMPROOT='/var/tmp/temproot'
331 #
332 # Specify the destination directory for the installed files
333 #DESTDIR=
334 #
335 # Strict comparison skips the VCS Id test and compares every file
336 #STRICT=no
337 #
338 # Type of diff, such as unified, context, etc.
339 #DIFF_FLAG='-u'
340 #
341 # Install the new file if it differs only by VCS Id ($FreeBSD)
342 #FREEBSD_ID=
343 #
344 # Verbose mode includes more details and additional checks
345 #VERBOSE=
346 #
347 # Automatically install files that do not exist on the system already
348 #AUTO_INSTALL=
349 #
350 # Automatically upgrade files that have not been user modified
351 #AUTO_UPGRADE=
352 #
353 # Compare /etc/rc.conf[.local] to /etc/defaults/rc.conf
354 #COMP_CONFS=yes
355 #
356 # Preserve files that you replace
357 #PRESERVE_FILES=yes
358 #PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
359 #
360 # The umask for mergemaster to compare the default file's modes to
361 #NEW_UMASK=022
362 #
363 # The following options have no command line overrides
364 #
365 # Files to always avoid comparing
366 #IGNORE_FILES='/etc/motd /etc/printcap foo bar'
367 #
368 # Additional options for diff.  This will get unset when using -s.
369 #DIFF_OPTIONS='-Bb'     # Ignore changes in whitespace
370 #
371 # Location to store the list of mtree values for AUTO_UPGRADE purposes
372 #MTREEDB='/var/db'
373 #
374 # For those who just cannot stand including the full path to PAGER
375 #DONT_CHECK_PAGER=
376 #
377 # If you set 'yes' above, make sure to include the PATH to your pager
378 #PATH=/bin:/usr/bin:/usr/sbin
379 #
380 # Specify the path to scripts to run before the comparison starts,
381 # and/or after the script has finished its work
382 #MM_PRE_COMPARE_SCRIPT=
383 #MM_EXIT_SCRIPT=
384 .Ed
385 .Sh EXIT STATUS
386 Exit status is 0 on successful completion, or if the user bails out
387 manually at some point during execution.
388 .Pp
389 Exit status is 1 if it fails for one of the following reasons:
390 .Pp
391 Invalid command line option
392 .Pp
393 Failure to create the temporary root environment
394 .Pp
395 Failure to populate the temporary root
396 .Pp
397 Presence of the 'nodev' option in
398 .Pa <DESTDIR>/etc/fstab
399 .Pp
400 Failure to install a file
401 .Sh EXAMPLES
402 Typically all you will need to do is type
403 .Nm
404 at the prompt and the script will do all the work for you.
405 .Pp
406 To use context diffs and have
407 .Nm
408 explain more things as it goes along, use:
409 .Pp
410 .Dl # mergemaster -cv
411 .Pp
412 To specify that
413 .Nm
414 put the temporary root environment in
415 .Pa /usr/tmp/root ,
416 use:
417 .Pp
418 .Dl # mergemaster -t /usr/tmp/root
419 .Pp
420 To specify a 110 column screen with a strict
421 comparison, use:
422 .Pp
423 .Dl # mergemaster -sw 110
424 .Sh SEE ALSO
425 .Xr diff 1 ,
426 .Xr make 1 ,
427 .Xr more 1 ,
428 .Xr sdiff 1 ,
429 .Xr pwd_mkdb 8
430 .Pp
431 .Pa /usr/src/etc/Makefile
432 .Rs
433 .%O http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
434 .%T The Cutting Edge (using make world)
435 .%A Nik Clayton
436 .Re
437 .Sh HISTORY
438 The
439 .Nm
440 utility was first publicly available on one of my
441 web pages in a much simpler form under the name
442 .Pa comproot
443 on 13 March 1998.
444 The idea for creating the
445 temporary root environment comes from Nik Clayton's
446 make world tutorial which is referenced above.
447 .Sh AUTHORS
448 This manual page and the script itself were written by
449 .An Douglas Barton Aq DougB@FreeBSD.org .
450 .Sh BUGS
451 There are no known bugs.
452 Please report any problems,
453 comments or suggestions to the author.
454 Several of the
455 improvements to this program have come from user
456 suggestions.
457 Thank you.