From Gentoo Wiki
Jump to: navigation, search

The dispatch-conf a utility is included with Portage and is used on Gentoo to manage configuration file updates. It allows system administrators to review then accept or reject upstream configuration changes, which frequently happens when packages are updated. It is capable of integrating with rcs to allow for version-controlled configuration file management.

RCS integration

When dispatch-conf is configured to integrate with rcs, it will store all changes in /etc/config-archive.

Install revision control system:

root #emerge --ask dev-vcs/rcs

This process of configuration is as simple as editing the configuration file to include the following:

FILE /etc/dispatch-conf.conf

Administrators can then view the differences using the rcs utilities like rlog as well as roll-back changes using co. The rcs utilities work with file locking itself, so the moment you want to use it in your administrative tasks, understand that:

  • dispatch-conf only stores the changes made when the package suggests to alter the file. Changes you made afterwards are not registered yet
  • when you check out a file, rcs will want to write the file to the file system, so make sure you backup your existing file first, or work with standard output (see later)
  • if you want to check in a file, you first need to take a lock on said file. Also, make sure you opt not to remove the working file

To view the commit history on /etc/conf.d/udev:

user $rlog /etc/config-archive/etc/conf.d/udev,v
RCS file: /etc/config-archive/etc/conf.d/udev,v
Working file: udev
head: 1.1
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2;     selected revisions: 2
Archived config file.
revision 1.1
date: 2011/06/15 18:14:59;  author: root;  state: Exp;
branches:  1.1.1;
dispatch-conf update.
date: 2011/06/15 18:14:59;  author: root;  state: Exp;  lines: +3 -2
dispatch-conf update.

If you want to roll back to a particular version, a simple way to do so is to check out a previous version:

root #cp udev udev.orig
root #co -p -r1.1.1.1 /etc/config-archive/etc/conf.d/udev,v > udev
etc/config-archive/etc/conf.d/udev,v  -->  standard output
revision 1.1.1.

After making your final changes (you can use the backup udev.orig to merge any changes made later), check in the file again:

root #co -p -l /etc/config-archive/etc/conf.d/udev,v

Edit the file, and finally check in the changes:

root #ci -l /etc/config-archive/etc/conf.d/udev,v
/etc/config-archive/etc/conf.d/udev,v  <--  udev
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Merged changes for persistant rules
>> .

Changing diff or merge tools

Reading changes in all grey text can be a bit annoying. Fortunately there is an alternative called app-misc/colordiff that displays the different types of changes in different colors. Configuration is simple, first install colordiff with:

root #emerge --ask app-misc/colordiff

Now change the diff line in the config file to:

FILE /etc/dispatch-conf.conf
diff="colordiff -Nu '%s' '%s'"

Use (g)vimdiff to merge changes

You may wish to try (g)vimdiff instead of the default method of merging files. To do this, modify the /etc/dispatch-conf.conf configuration file by changing the merge line:

FILE /etc/dispatch-conf.conf
merge="vimdiff -c'saveas %s' -c next -c'setlocal noma readonly' -c prev %s %s"

You can also use vimdiff (for gvimdiff use -f option moreover) to merge changes.

The left pane will hold the original config file saved as the merge output, so make changes in the left pane and save that pane. To help you remember the right hand pane (containing the new config file) will be marked unmodifiable and read-only.

Some useful commands related to merge with vimdiff:

"]c" : jump to next change
"[c" : jump to previous change
"CTRL-W <Right>" or "CTRL-W <Left>" : go to the other window
"do" (diff obtain): get the text of the highlighted block from the other window
"dp" (diff put) : put the text of the highlighted block to the other window
"zo" : open fold under the cursor
"zc" : close fold under the cursor
"zr" : open all folds
":wqa" : write and exit

See the Vim documentation for further help.