MERGEMASTER(8)
π mergemaster(8) π β System Manager's Manual
okay so this is the mergemaster page from the System Manager's Manual, and bestie, it's a whole β¨journeyβ¨ β so grab a snack, we're going through it together. No cap, every flag matters here.
πΈ NAME πΈ
mergemaster β merge configuration files, et al during an upgrade
π¦ SYNOPSIS π¦
mergemaster [-scrvhpCP] [-a|iFU] [--run-updates=[always|never]]
[-m /path/to/sources] [-t /path/to/temp/root] [-d] [-u N]
[-w N] [-A Target architecture] [-D /destdir/path]
β¨ DESCRIPTION β¨
Okay so the first thing you need to know, and I'm saying this with love: the mergemaster utility is deprecated and may not even be available in FreeBSD 15.0 or later π. Users are advised to use etcupdate(8) instead. Like, it's giving "your fave is retiring," iykyk.
So. The mergemaster utility is a Bourne shell script designed to aid you in updating the various configuration and other files associated with FreeBSD. And it is HIGHLY recommended that you back up your /etc directory before beginning this process β not me being dramatic, that's literally what the page says, fr fr π«Ά
π Bestie. Back up /etc. I'm serious. Do it before you do anything else.
The script uses /usr/src/Makefile to build a temporary root environment from / down, populating that environment with the various files. You can specify a different source directory with the -m command line option, or specify the destination directory with the -D option. Then it compares each file in that environment to its installed counterpart π
When the script finds a change in the new file, or there is no installed version of the new file, it gives you four options to deal with it:
- install the new file as is
- delete the new file
- merge the old and new files (as appropriate) using
sdiff(1) - leave the file in the temporary root environment to merge by hand later
By default it creates the temporary root in /var/tmp/temproot and compares the Version Control System (VCS) Id strings ($FreeBSD) for files that have them, deleting the temporary file if the strings match. If there is no Id string, or if the strings are different, it compares the files themselves. You can also specify that the script ignore the Id strings and compare every file with the -s option. Using the -F option mergemaster will install the new file for you if they differ only by VCS strings π
The merge menu option is designed to let you easily combine your customizations from the old version of a file into the new one. While you can use the merge function to incorporate changes from files that you have not customized, it is not recommended. Like, technically you can, butβ¦ don't π
The mergemaster utility checks your umask and issues a warning for anything other than 022. While it is not mandatory to grant world read permissions for most configuration files, you may run into problems without them. If you choose a umask other than 022 and experience trouble later, this could be the cause. /etc/master.passwd is treated as a special case: if you choose to install this file or a merged version of it, the file permissions are always 600 (rw-------) for security reasons π. After installing an updated version of this file you should probably run pwd_mkdb(8) with the -p option to rebuild your password databases and recreate /etc/passwd.
The script uses the owner and group ids that the files are created with by /usr/src/etc/Makefile, and file permissions as specified by the umask. Unified diffs are used by default to display any differences unless you choose context diffs.
The mergemaster utility will source scripts that you specify right before it starts the comparison, and after it is done running. The easiest way to handle this is to place the path to the script(s) in the appropriate variables in your .mergemasterrc file. The script sourced before comparison is named in MM_PRE_COMPARE_SCRIPT, and the one sourced after the script is done is MM_EXIT_SCRIPT. This is the recommended way to specify local modifications, or files that you want to give special handling to π§ β and yes, this includes files that you want to be deleted without being compared. Because the named scripts are sourced from within mergemaster, all of the script's variables are available for use in your custom script β¨
You can also use /etc/mergemaster.rc, which will be read before .mergemasterrc. Options specified on the command line are updated last, and therefore can override both files π
When the comparison is done, if there are any files remaining in the temproot directory they will be listed, and if the -a option is not in use the user will be given the option of deleting the temproot directory. If there are no files remaining in the temproot directory, it will be deleted ποΈ
π The Options Are As Follows π
-sβ Perform a strict comparison, diffing every pair of files. This comparison is performed line by line, without regard to VCS Ids. Like, no shortcuts, every single line gets read π-cβ Use context diffs instead of unified diffs.-rβ Re-runmergemasteron a previously cleaned directory, skipping the creation of the temporary root environment. This option is compatible with all other options π«-vβ Be more verbose about the process. You should probably use this option the first time you runmergemaster(fr, do it). This option also gives you a list of files that exist only in the installed version of/etcπ-aβ Run automatically. This option will leave all the files that differ from the installed versions in the temporary directory to be dealt with by hand. If the temproot directory exists, it creates a new one in a previously non-existent directory. This option unsets the verbose flag, and is not compatible with-i,-F, or-U. Setting-amakes-wsuperfluous.-hβ Display usage and help information. Your lil' "wait what does this do again" button π«Ά-iβ Automatically install any files that do not exist in the destination directory.-pβ Pre-buildworld mode. Compares only files known to be essential to the success of{build|install}world, i.e.,/etc/groupand/etc/master.passwd. The bare minimum squad π-Fβ If the files differ only by VCS Id ($FreeBSD), install the new file.-Cβ After a standardmergemasterrun, compares yourrc.conf[.local]options to the defaults.-Pβ Preserve files that you replace in/var/tmp/mergemaster/preserved-files-<date>, or another directory you specify in yourmergemasterrc file. Little memory box of your old files π-Uβ Attempt to auto upgrade files that have not been user modified. This option can be dangerous when there are critical changes in the new versions that affect your running system. Like, it's giving "yolo but with consequences," be careful π--run-updates=[always|never]β Specifyalwaysorneverto runnewaliases,pwd_mkdb, etc. at the end of the comparison run. If this option is omitted the default is to prompt the user for each update as necessary.-m /path/to/sourcesβ Specify the path to the directory where you want to do themake(1). (In other words, where your sources are, but-swas already taken π.) In older versions ofmergemasterthe path tosrc/etcwas required.mergemasterwill convert the path if this older method is used.-t /path/to/temp/rootβ Create the temporary root environment in/path/to/temp/rootinstead of the default/var/tmp/temprootπ-dβ Add the date and time to the name of the temporary root directory. If-tis specified, this option must follow it if you want the date added too. Order matters, bestie β°-u Nβ Specify a numeric umask. The default is022.-w Nβ Supply an alternate screen width to thesdiff(1)command in numbers of columns. The default is80π-A Target architectureβ Specify an alternativeTARGET_ARCHarchitecture name.-D /pathβ Specify the destination directory for the installed files.
π ENVIRONMENT π
The mergemaster utility uses the PAGER environment variable if set. Otherwise it uses less(1). If PAGER specifies a program outside its limited PATH without specifying the full path, mergemaster prompts you with options on how to proceed π€
The MM_PRE_COMPARE_SCRIPT and MM_EXIT_SCRIPT variables are used as described above. Other variables that are used by the script internally can be specified in .mergemasterrc as described in more detail below π
π FILES π
So mergemaster reads two lil config files, and only if they actually exist (no drama if they don't):
/etc/mergemaster.rc$HOME/.mergemasterrc
The mergemaster utility will . (source) these files if they exist. Command line options will override rc file options. And $HOME/.mergemasterrc overrides /etc/mergemaster.rc β bestie's personal config wins over the system one, periodt.
Here's an example with all the values commented out (so like, every single knob, ready for you to un-comment the ones you want):
# These are options for mergemaster, with their default values listed
# The following options have command line overrides
#
# The target architecture (-A, unset by default)
#ARCHSTRING='TARGET_ARCH=<foo>'
#
# Sourcedir is the directory to do the 'make' in (-m)
#SOURCEDIR='/usr/src'
#
# Directory to install the temporary root environment into (-t)
#TEMPROOT='/var/tmp/temproot'
#
# Specify the destination directory for the installed files (-D)
#DESTDIR=
#
# Strict comparison skips the VCS Id test and compares every file (-s)
#STRICT=no
#
# Type of diff, such as unified, context, etc. (-c)
#DIFF_FLAG='-u'
#
# Install the new file if it differs only by VCS Id ($FreeBSD, -F)
#FREEBSD_ID=
#
# Verbose mode includes more details and additional checks (-v)
#VERBOSE=
#
# Automatically install files that do not exist on the system already (-i)
#AUTO_INSTALL=
#
# Automatically upgrade files that have not been user modified (-U)
# ***DANGEROUS***
#AUTO_UPGRADE=
#
# Either always or never run newaliases, pwd_mkdb at the end (--run-updates)
#RUN_UPDATES=
#
# Compare /etc/rc.conf[.local] to /etc/defaults/rc.conf (-C)
#COMP_CONFS=
#
# Preserve files that you replace (-P)
#PRESERVE_FILES=
#PRESERVE_FILES_DIR=/var/tmp/mergemaster/preserved-files-`date +%y%m%d-%H%M%S`
#
# The umask for mergemaster to compare the default file's modes to (-u)
#NEW_UMASK=022
#
# The following options have no command line overrides
#
# Files to always avoid comparing
#IGNORE_FILES='/etc/motd /etc/printcap foo bar'
#
# Additional options for diff. This will get unset when using -s.
#DIFF_OPTIONS='-Bb' # Ignore changes in whitespace
#
# Location to store the list of mtree values for AUTO_UPGRADE purposes
#MTREEDB='/var/db'
#
# For those who just cannot stand including the full path to PAGER
#DONT_CHECK_PAGER=
#
# If you set 'yes' above, make sure to include the PATH to your pager
#PATH=/bin:/usr/bin:/usr/sbin
#
# Delete stale files in /etc/rc.d without prompting
#DELETE_STALE_RC_FILES=
#
# Specify the path to scripts to run before the comparison starts,
# and/or after the script has finished its work
#MM_PRE_COMPARE_SCRIPT=
#MM_EXIT_SCRIPT=
π Notice how#AUTO_UPGRADE=is literally flagged***DANGEROUS***in the original comments β that is not a vibe, that is a warning, bestie. Respect it.
π EXIT STATUS π
Exit status is 0 on successful completion, or if the user bails out manually at some point during execution. (Yes, quitting counts as a win here, we love a graceful exit π«Ά)
Exit status is 1 if it fails for one of the following reasons:
- Invalid command line option
- Failure to create the temporary root environment
- Failure to populate the temporary root
- Presence of the
nodevoption in<DESTDIR>/etc/fstab - Failure to install a file
β¨ EXAMPLES β¨
Typically all you will need to do is type mergemaster at the prompt and the script will do all the work for you. Like, that's it. That's the whole move. Iconic behaviour, honestly.
To use context diffs and have mergemaster explain more things as it goes along, use:
# mergemaster -cv
To specify that mergemaster put the temporary root environment in /usr/tmp/root, use:
# mergemaster -t /usr/tmp/root
To specify a 110 column screen with a strict comparison, use:
# mergemaster -sw 110
π SEE ALSO π
Also this file, which you should absolutely go read:
/usr/src/etc/Makefile
And the FreeBSD Handbook, at this exact URL:
https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld
π¦ HISTORY π¦
The mergemaster utility was first publicly available on one of my web pages in a much simpler form under the name comproot on 13 March 1998. The idea for creating the temporary root environment comes from Nik Clayton's make world tutorial which is referenced above. So yeah β ancient lore, but make it cute πΈ
π AUTHORS π
This manual page and the script itself were written by Douglas Barton <dougb@FreeBSD.org>. Give them their flowers, fr fr π
and that's a wrap on MERGEMASTER(8)! π This one's from the Debian fam, dated April 16, 2024, and it's living in section 8 of the manual β go forth and merge responsibly, bestie π
β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- Copyright (c) 1998-2011 Douglas Barton
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms