ETCUPDATE(8) | MidnightBSD System Manager's Manual | ETCUPDATE(8) |
etcupdate
— manage
updates to system files not updated by installworld
etcupdate |
[-npBF ] [-d
workdir] [-r |
-s source |
-t tarball]
[-A patterns]
[-D destdir]
[-I patterns]
[-L logfile]
[-M options] |
etcupdate |
build [-B ]
[-d workdir]
[-s source]
[-L logfile]
[-M options]
tarball |
etcupdate |
diff [-d
workdir] [-D
destdir] [-I
patterns] [-L
logfile] |
etcupdate |
extract [-B ]
[-d workdir]
[-s source |
-t tarball]
[-D destdir]
[-L logfile]
[-M options] |
etcupdate |
resolve [-p ]
[-d workdir]
[-D destdir]
[-L logfile] |
etcupdate |
revert [-d
workdir] [-D
destdir] [-L
logfile] file ... |
etcupdate |
status [-d
workdir] [-D
destdir] |
The etcupdate
utility is a tool for
managing updates to files that are not updated as part of ‘make
installworld’ such as files in /etc. It
manages updates by doing a three-way merge of changes made to these files
against the local versions. It is also designed to minimize the amount of
user intervention with the goal of simplifying upgrades for clusters of
machines.
To perform a three-way merge, etcupdate
keeps copies of the current and previous versions of files that it manages.
These copies are stored in two trees known as the “current”
and “previous” trees. During a merge,
etcupdate
compares the “current” and
“previous” copies of each file to determine which changes need
to be merged into the local version of each file. If a file can be updated
without generating a conflict, etcupdate
will update
the file automatically. If the local changes to a file conflict with the
changes made to a file in the source tree, then a merge conflict is
generated. The conflict must be resolved after the merge has finished. The
etcupdate
utility will not perform a new merge until
all conflicts from an earlier merge are resolved.
The etcupdate
utility supports several
modes of operation. The mode is specified via an optional command argument.
If present, the command must be the first argument on the command line. If a
command is not specified, the default mode is used.
The default mode merges changes from the source tree to the destination directory. First, it updates the “current” and “previous” trees. Next, it compares the two trees merging changes into the destination directory. Finally, it displays warnings for any conditions it could not handle automatically.
If the -r
option is not specified, then
the first step taken is to update the “current” and
“previous” trees. If a “current” tree already
exists, then that tree is saved as the “previous” tree. An
older “previous” tree is removed if it exists. By default the
new “current” tree is built from a source tree. However, if a
tarball is specified via the -t
option, then the
tree is extracted from that tarball instead.
Next, etcupdate
compares the files in the
“current” and “previous” trees. If a file was
removed from the “current” tree, then it will be removed from
the destination directory only if it does not have any local modifications.
If a file was added to the “current” tree, then it will be
copied to the destination directory only if it would not clobber an existing
file. If a file is changed in the “current” tree, then
etcupdate
will attempt to merge the changes into the
version of the file in the destination directory. If the merge encounters
conflicts, then a version of the file with conflict markers will be saved
for future resolution. If the merge does not encounter conflicts, then the
merged version of the file will be saved in the destination directory. If
etcupdate
is not able to safely merge in changes to
a file other than a merge conflict, it will generate a warning.
For each file that is updated a line will be output with a leading character to indicate the action taken. The possible actions follow:
Finally, if any warnings were encountered they are displayed after the merge has completed.
Note that for certain files etcupdate
will
perform post-install actions any time that the file is updated.
Specifically,
pwd_mkdb(8) is invoked
if /etc/master.passwd is changed,
cap_mkdb(1) is invoked
to update /etc/login.conf.db if
/etc/login.conf is changed,
newaliases(1) is
invoked if /etc/mail/aliases is changed,
services_mkdb(8)
is invoked if /etc/services is changed,
tzsetup(8) is invoked if
/etc/localtime is changed and if
/var/db/zoneinfo exists, and
/etc/rc.d/motd is invoked if
/etc/motd is changed. One exception is that if
/etc/mail/aliases is changed and the destination
directory is not the default, then a warning will be issued instead. This is
due to a limitation of the
newaliases(1)
command. Similarly, if /etc/motd is changed and the
destination directory is not the default, then
/etc/rc.d/motd will not be executed due to a
limitation of that script. In this case no warning is issued as the result
of /etc/rc.d/motd is merely cosmetic and will be
corrected on the next reboot.
The build
mode is used to build a tarball
that contains a snapshot of a “current” tree. This tarball can
be used by the default and extract modes. Using a tarball can allow
etcupdate
to perform a merge without requiring a
source tree that matches the currently installed world. The
tarball argument specifies the name of the file to
create. The file will be a
tar(5) file compressed with
bzip2(1).
The diff
mode compares the versions of
files in the destination directory to the “current” tree and
generates a unified format diff of the changes. This can be used to
determine which files have been locally modified and how. Note that
etcupdate
does not manage files that are not
maintained in the source tree such as /etc/fstab and
/etc/rc.conf.
The extract
mode generates a new
“current” tree. Unlike the default mode, it does not save any
existing “current” tree and does not modify any existing
“previous” tree. The new “current” tree can
either be built from a source tree or extracted from a tarball.
The resolve
mode is used to resolve any
conflicts encountered during a merge. In this mode,
etcupdate
iterates over any existing conflicts
prompting the user for actions to take on each conflicted file. For each
file, the following actions are available:
The revert
mode is used to restore the
stock versions of files. In this mode, etcupdate
installs the stock version of requested files. This mode cannot be used to
restore directories, only individual files.
The status
mode shows a summary of the
results of the most recent merge. First it lists any files for which there
are unresolved conflicts. Next it lists any warnings generated during the
last merge. If the last merge did not generate any conflicts or warnings,
then nothing will be output.
The following options are available. Note that most options do not apply to all modes.
-A
patternsIGNORE_FILES
variable or the
-I
option will not be installed.-B
-D
destdirDESTDIR
variable used with
‘make installworld’. The default destination directory is an
empty string which results in merges updating /etc
on the local machine.-d
workdir-F
diff
mode, this
reduces noise due to FreeBSD ID string changes in the output. During an
update this can simplify handling for harmless conflicts caused by FreeBSD
ID string changes.
Specifically, if a file in the destination directory is
identical to the same file in the “previous” tree modulo
the FreeBSD ID string, then the file is treated as if it was unmodified
and the “current” version of the file will be installed.
Similarly, if a file in the destination directory is identical to the
same file in the “current” tree modulo the FreeBSD ID
string, then the “current” version of the file will be
installed to update the ID string. If the “previous” and
“current” versions of the file are identical, then
etcupdate
will not change the file in the
destination directory.
Due to limitations in the diff(1) command, this option may not have an effect if there are other changes in a file that are close to the FreeBSD ID string.
-I
patterns-L
logfileetcupdate
utility logs each command that it
invokes along with the standard output and standard error to this file. By
default the log file is stored in a file named log
in the work directory.-M
optionsTARGET
or TARGET_ARCH
variables for a cross-build.-n
-r
option is not specified, then a temporary
“current” tree will be extracted to perform the
comparison.-p
resolve
.-r
-s
source-t
tarballbuild
command rather than
building the tree from a source tree.The etcupdate
utility can also be
configured by setting variables in an optional configuration file named
/etc/etcupdate.conf. Note that command line options
override settings in the configuration file. The configuration file is
executed by sh(1), so it uses
that syntax to set configuration variables. The following variables can be
set:
ALWAYS_INSTALL
-A
option.DESTDIR
-D
option.EDITOR
FREEBSD_ID
-F
option. This is enabled by setting the variable
to a non-empty value.IGNORE_FILES
-I
option.LOGFILE
-L
option.MAKE_OPTIONS
-M
option.SRCDIR
-s
option.WORKDIR
-d
option.The etcupdate
utility uses the program
identified in the EDITOR
environment variable to
edit merge conflicts. If EDITOR
is not set,
vi(1) is used as the default
editor.
The etcupdate
utility exits 0 on
success, and >0 if an error occurs.
To compare the files in /etc with the stock versions:
etcupdate diff
To merge changes after an upgrade via the buildworld and installworld process:
etcupdate
To resolve any conflicts generated during a merge:
etcupdate resolve
The etcupdate
utility may need to be
bootstrapped before it can be used. The diff
command
will fail with an error about a missing reference tree if bootstrapping is
needed.
Bootstrapping etcupdate
requires a source
tree that matches the currently installed world. The easiest way to ensure
this is to bootstrap etcupdate
before updating the
source tree to start the next world upgrade cycle. First, generate a
reference tree:
etcupdate extract
Second, use the diff
command to compare
the reference tree to your current files in /etc.
Undesired differences should be removed using an editor,
patch(1), or by copying
files from the reference tree (located at
/var/db/etcupdate/current by default)
If the tree at /usr/src is already newer
than the currently installed world, a new tree matching the currently
installed world can be checked out to a temporary location. The reference
tree for etcupdate
can then be generated via:
etcupdate extract -s
/path/to/tree
The diff
command can be used as above to
remove undesired differences. Afterwards, the changes in the tree at
/usr/src can be merged via a regular merge.
The following warning messages may be generated during a merge. Note that several of these warnings cover obscure cases that should occur rarely if at all in practice. For example, if a file changes from a file to a directory in the “current” tree and the file was modified in the destination directory, then a warning will be triggered. In general, when a warning references a pathname, the corresponding file in the destination directory is not changed by a merge operation.
etcupdate
was not able to refresh
/etc/localtime from its source file in
/usr/share/zoneinfo. Running
tzsetup(8) will both
refresh /etc/localtime and generate
/var/db/zoneinfo permitting future updates to
refresh /etc/localtime automatically.etcupdate
was not able to automatically
update the corresponding aliases database.cap_mkdb(1), diff(1), make(1), newaliases(1), sh(1), pwd_mkdb(8), services_mkdb(8), tzsetup(8)
The etcupdate
utility first appeared in
FreeBSD 10.0.
The etcupdate
utility was written by
John Baldwin
<jhb@FreeBSD.org>.
Rerunning a merge does not automatically delete conflicts left over from a previous merge. Any conflicts must be resolved before the merge can be rerun. It is not clear if this is a feature or a bug.
There is no way to easily automate conflict resolution for specific files. For example, one can imagine a syntax along the lines of
etcupdate resolve tf
/some/file
to resolve a specific conflict in an automated fashion.
Bootstrapping etcupdate
often results in
gratuitous diffs in /etc/mail/*.cf that cause
conflicts in the first merge. If an object tree that matches the source tree
is present when bootstrapping, then passing the -B
flag to the extract
command can work around
this.
April 20, 2021 | midnightbsd-3.1 |