[augeas-devel] Augeas Merging Configuration

David Lutterkort lutter at redhat.com
Tue May 10 00:13:57 UTC 2011


On Sat, 2011-05-07 at 17:59 +0300, Christos Bountalis wrote:
> First of all, I want to say thanks for your help and very useful info.
> >
> > I would love to have that feature in Augeas. What do you think the user
> > interface for such a tool will be like ? Especially, what are the inputs
> > (individual values, file snippets, entire files) ?
> >
> >
> My intention is to provide two-way merge functions to the main Api as
> you suggested maybe include an argument accepting some flags to the
> aug_merge function as well (whether the old values should be kept, or
> only the new ones etc) , and then try to implement in the existing
> augtool. The inputs will be entire files.

I think the trick for getting this right is to keep lots of history
about the file changes; imagine the file /etc/foo.conf that comes with
package foo.

After you install foo-1.0, you have in /etc/foo.conf; call that version
of the file v1:
        X=x1
        Y=y1
        
The user then goes and edits the file; call the version v2:
        X=x2
        Y=y1

The update to foo-2.0 contains this /etc/foo.conf; call that version v3:
        X=x1
        Y=y2

All you have on an ordinary system is v2 and v3; since you don't know
that X was changed by the user, and Y is still the value from v1, both
changes in v3 look equally important; your only logical choices what to
do with /etc/foo.conf therefore are to either leave v2 alone or replace
it with v3 in its entirety.

If you knew about v1 and that the user produced v2, your update to
foo-2.0 would most likely produce

        X=x2
        Y=y2

which is probably closest to what the user would see as reasonable.

To capture the distinction between user-made change (very important) and
change by package manager (boring), you might want to capture the state
of files before and after each packaging operation; if the change
happened between two packaging operations, it's important, if it
happened during a packaging operation it's unimportant.

Where augeas could help you in this setup is that it would give you an
easy way to track these changes at a very granular level; though, since
your inputs are always entire files, you might first want to experiment
with tools like git or unison.

David





More information about the augeas-devel mailing list