Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 72306 - etc-update could benefit from using base copy of configuration files
Summary: etc-update could benefit from using base copy of configuration files
Status: RESOLVED DUPLICATE of bug 72304
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-23 19:54 UTC by Matt Ball
Modified: 2005-07-17 13:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Ball 2004-11-23 19:54:58 UTC
As most people have experienced, the etc-update tool performs poorly when updating several configuration files.

I have found several threads that talk about using an MD5 checksum to determine whether a config file has changed (See #4709, for example), then automerge the unchanged config files.  However, I think the MD5 approach is inheritly flawed, because it does not help with merges.  Ideally, what we need is a three-file merge system.  This gives full flexibility and power when dealing with collisions.

Here is a proposal that could enhance the processing of config files within /etc:

1) Keep a base copy of each config file that resides in /etc.  As an example, each base config file could reside in a sub-directory named ".base".  Each time portage adds a config file (for the first time), it could place a copy in both the /etc/subdir and /etc/subdir/.base directories, where subdir is a possible sub-directory within /etc.  If we are worried about config file authenticity, then we could add MD5 checksums in the .base directory, along with the config files.

2) When updating a package (and corresponding config files), portage would compare the existing config file to the copy in the .base directory.  If the two files match, then portage copies the new config file into both places (i.e. /etc/subdir and /etc/subdir/.base).  This is the case when the user does not change anything, and does not need to get involved.

3) If Portage is updating a config file and notices that the existing file does not match the copy within the .base directory, then the user has changed the previous config file.  In this case, we need to perform a merge operation.  Fortunately, we can perform a powerful three-file merge, unlike the existing method that uses only two files (new and old).  With a three-file merge, it is possible to now tell exactly which lines the user changed in the current file, and which lines the package changed in the new file.  If none of these lines coincide, it is possible to seemlessly merge the new into the old by using the diff3 tool (using something like the --merge option).

4) If there is a conflict (i.e. both the user and package changed the same lines in the config file), then portage would save the new config file in the same manner as today, and let etc-update take care of the conflict.  The big difference is that etc-update can now detect the presence of a .base directory and use a three-file diff.  The three-file diffs are very nice because you can see exactly who changed which lines and why.  The user could then walk through the differences in much the same way as today, except with a 3-file diff instead of a 2-file.

5) portage could still work if the existing /etc directory does not have a .base subdirectory, or a matching config file within the .base directory.  In this case, portage would simply perform the existing behavior to resolve config file conflicts, then would save a copy of the new base config file in the .base directory.  This would allow the full power of a 3-file merge for the next update.

I would greatly appreciate if someone could give this idea some thought and maybe shoot some holes through it.  In any case, the existing system of etc-update is horribly ineffective with dealing with config file collisions and needs some improvement.

-Matt

Reproducible: Always
Steps to Reproduce:
Comment 1 Jason Stubbs (RETIRED) gentoo-dev 2004-11-23 19:58:13 UTC

*** This bug has been marked as a duplicate of 72304 ***