1.\" Copyright (c) 1998-2003 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: src/usr.sbin/mergemaster/mergemaster.8,v 1.5.2.12 2003/03/02 02:45:01 dougb Exp $
26.\"
27.Dd February 5, 2001
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 scrvahipC
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 D Ar /path
42.Sh DESCRIPTION
43The
44.Nm
45utility is a Bourne shell script which is designed to aid you
46in updating the various configuration and other files
47associated with
48.Dx .
49It is
50.Sy HIGHLY
51recommended that you back up your
52.Pa /etc
53directory before beginning this process.
54.Pp
55The script uses
56.Pa /usr/src/etc/Makefile
57to build a temporary root environment from
58.Pa /
59down, populating that environment with the various
60files.
61You can specify a different source directory
62with the
63.Op Fl m
64command line option, or specify the destination
65directory with the
66.Op Fl D
67option.
68It then compares each file in that environment
69to its installed counterpart.
70When the script finds a
71change in the new file, or there is no installed
72version of the new file it gives you four options to
73deal with it.
74You can install the new file as is,
75delete the new file, merge the old and new
76files (as appropriate) using
77.Xr sdiff 1
78or leave the file in the temporary root environment to
79merge by hand later.
80.Pp
81By default it creates the temporary root in
82.Pa /var/tmp/temproot
83and compares the
84.Xr cvs 1
85version $Id/$DragonFly strings for files that have them, deleting
86the temporary file if the strings match.
87If there is
88no $Id string, or if the strings are different it
89compares the files themselves.
90You can
91also specify that the script ignore the $Id strings and
92compare every file.
93.Pp
94The
95.Nm
96utility checks your umask and issues a warning for anything
97other than 022. While it is not mandatory to grant
98world read permissions for most configuration files, you
99may run into problems without them.
100If you choose a
101umask other than 022 and experience trouble later this
102could be the cause.
103.Pa /etc/master.passwd
104is treated as a special case.
105If you choose to install
106this file or a merged version of it the file permissions
107are always 600 (rw-------) for security reasons.
108After
109installing an updated version of this file you should
110probably run
111.Xr pwd_mkdb 8
112with the -p option to rebuild your password databases
113and recreate
114.Pa /etc/passwd .
115.Pp
116The script uses the owner and group id's
117that the files are created with by
118.Pa /usr/src/etc/Makefile ,
119and file permissions as specified by the umask.
120Unified diffs are used by default to display any
121differences unless you choose context diffs.
122.Pp
123The
124.Nm
125utility will source scripts that you specify right before
126it starts the comparison, and after it's done running.
127The easiest way to handle this is to place the path
128to the script(s) in the appropriate variables in your
129.Pa .mergemasterrc
130file.
131The script sourced before comparison is named in
132.Ev MM_PRE_COMPARE_SCRIPT ,
133and the one sourced after the script is done is
134.Ev MM_EXIT_SCRIPT .
135This is the recommended way to specify local modifications,
136or files that you want to give special handling to.
137This includes files that you want to be deleted without
138being compared.
139Because the named scripts are sourced from within
140.Nm ,
141all of the script's variables are available for use in
142your custom script.
143You can also use
144.Pa /etc/mergemaster.rc
145which will be read before
146.Pa .mergemasterrc .
147Options specified on the command line are updated last,
148and therefore can override both files.
149.Pp
150The options are as follows:
151.Bl -tag -width Fl
152.It Fl s
153Perform a strict comparison, diff'ing every pair of files.
154This comparison is performed line by line,
155without regard to CVS $Id's.
156.It Fl c
157Use context diffs instead of unified diffs.
158.It Fl r
159Re-run
160.Nm
161on a previously cleaned directory, skipping the creation of
162the temporary root environment.
163This option is compatible
164with all other options.
165.It Fl v
166Be more verbose about the process.
167You should probably use
168this option the first time you run
169.Nm .
170This option also gives you a list of files that exist
171only in the installed version of
172.Pa /etc .
173.It Fl a
174Run automatically.
175This option will leave all the files that
176differ from the installed versions in the temporary directory
177to be dealt with by hand.
178If the
179.Pa temproot
180directory exists, it creates a new one in a previously
181non-existent directory.
182This option unsets the verbose flag,
183but is compatible with all other options.
184Setting -a makes
185-w superfluous.
186.It Fl h
187Display usage and help information.
188.It Fl i
189Automatically install any files that do not exist in the
190destination directory.
191.It Fl p
192Pre-buildworld mode.
193Compares only files known to be essential to the success of
194{build|install}world,
195including
196.Pa /etc/make.conf .
197.It Fl C
198After a standard
199.Nm
200run,
201compares your rc.conf[.local] options to the defaults.
202.It Fl m Ar /path/to/sources
203Specify the path to the directory where you want to do the
204.Xr make 1 .
205(In other words, where your sources are, but -s was already
206taken.)
207.It Fl t Ar /path/to/temp/root
208Create the temporary root environment in
209.Pa /path/to/temp/root
210instead of the default
211.Pa /var/tmp/temproot .
212.It Fl d
213Add the date and time to the name of the temporary
214root directory.
215If -t is specified, this option must
216follow it if you want the date added too.
217.It Fl u Ar N
218Specify a numeric umask.
219The default is 022.
220.It Fl w Ar N
221Supply an alternate screen width to the
222.Xr sdiff 1
223command in numbers of columns.
224The default is 80.
225.It Fl D Ar /path
226Specify the destination directory for the installed files.
227.El
228.Sh ENVIRONMENT
229The
230.Nm
231utility uses the
232.Ev PAGER
233environment variable if set.
234Otherwise it uses
235.Xr more 1 .
236If
237.Ev PAGER
238specifies a program outside
239its
240limited
241.Ev PATH
242without specifying the full path,
243.Nm
244prompts you with options on how to proceed.
245The
246.Ev MM_PRE_COMPARE_SCRIPT
247and
248.Ev MM_EXIT_SCRIPT
249variables are used as described above.
250Other variables that are used by the script internally
251can be specified in
252.Pa .mergemasterrc
253as described in more detail below.
254.Sh FILES
255.Bl -tag -width $HOME/.mergemasterrc -compact
256.It Pa /etc/mergemaster.rc
257.It Pa $HOME/.mergemasterrc
258.El
259.Pp
260The
261.Nm
262utility will . (source) these files if they exist.
263Command line options
264will override rc file options.
265.Pa $HOME/.mergemasterrc
266overrides
267.Pa /etc/mergemaster.rc .
268Here is an example
269with all values commented out:
270.Bd -literal
271# These are options for mergemaster, with their default values listed
272# The following options have command line overrides
273#
274# Directory to install the temporary root environment into
275#TEMPROOT='/var/tmp/temproot'
276#
277# Strict comparison bypasses the CVS $Id tests and compares every file
278#STRICT=no
279#
280# Type of diff, such as unified, context, etc.
281#DIFF_FLAG='-u'
282#
283# Additional options for diff.  This will get unset when using -s.
284#DIFF_OPTIONS='-I$\&DragonFly:.*[$]'	# Ignores CVS Id tags
285#
286# Verbose mode includes more details and additional checks
287#VERBOSE=
288#
289# Automatically install files that do not exist on the system already
290#AUTO_INSTALL=
291#
292# Compare /etc/rc.conf[.local] to /etc/defaults/rc.conf
293#COMP_CONFS=yes
294#
295# Sourcedir is the directory to do the 'make' in (where the new files are)
296#SOURCEDIR='/usr/src/etc'
297#
298# The umask for mergemaster to compare the default file's modes to
299#NEW_UMASK=022
300#
301# Specify the destination directory for the installed files
302#DESTDIR=
303#
304# The following options have no command line overrides
305# For those who just cannot stand including the full path to PAGER
306#DONT_CHECK_PAGER=
307#
308# If you set 'yes' above, make sure to include the PATH to your pager
309#PATH=/bin:/usr/bin:/usr/sbin
310#
311# Don't compare the old and new motd files
312#IGNORE_MOTD=yes
313#
314# Specify the path to scripts to run before the comparison starts,
315# and/or after the script has finished its work
316#MM_PRE_COMPARE_SCRIPT=
317#MM_EXIT_SCRIPT=
318.Ed
319.Sh EXIT STATUS
320Exit status is 0 on successful completion, or if the user bails out
321manually at some point during execution.
322.Pp
323Exit status is 1 if it fails for one of the following reasons:
324.Pp
325Invalid command line option
326.Pp
327Failure to create the temporary root environment
328.Pp
329Failure to populate the temporary root
330.Sh EXAMPLES
331Typically all you will need to do is type
332.Nm
333at the prompt and the script will do all the work for you.
334.Pp
335To use context diff's and have
336.Nm
337explain more things as it goes along, use:
338.Pp
339.Dl # mergemaster -cv
340.Pp
341To specify that
342.Nm
343put the temporary root environment in
344.Pa /usr/tmp/root ,
345use:
346.Pp
347.Dl # mergemaster -t /usr/tmp/root
348.Pp
349To specify a 110 column screen with a strict
350comparison, use:
351.Pp
352.Dl # mergemaster -sw 110
353.Sh SEE ALSO
354.Xr cvs 1 ,
355.Xr diff 1 ,
356.Xr make 1 ,
357.Xr more 1 ,
358.Xr sdiff 1 ,
359.Xr pwd_mkdb 8
360.Pp
361.Pa /usr/src/etc/Makefile
362.Rs
363.%U http://www.FreeBSD.org/doc/handbook/makeworld.html
364.%T The Cutting Edge (using make world)
365.%A Nik Clayton
366.Re
367.Sh HISTORY
368The
369.Nm
370utility was first publicly available on one of my
371web pages in a much simpler form under the name
372.Pa comproot
373on 13 March 1998. The idea for creating the
374temporary root environment comes from Nik Clayton's
375make world tutorial which is referenced above.
376.Sh AUTHORS
377This manual page and the script itself were written by
378.An Douglas Barton Aq Mt DougB@FreeBSD.org .
379.Sh BUGS
380There are no known bugs.
381Please report any problems,
382comments or suggestions to the author.
383Several of the
384improvements to this program have come from user
385suggestions.
386Thank you.
387