[augeas-devel] Apt.conf lens
David Lutterkort
lutter at redhat.com
Wed Nov 23 00:06:11 UTC 2011
On Fri, 2011-11-18 at 13:32 +0100, Raphaël Pinson wrote:
> Hello,
>
>
> A few months ago, I started working on a lens for apt.conf(.d/*)?
> files. This is a recursive lens, and it took me quite a lot of time to
> get it working.
> The working lens (and the test file) are pasted at the end of this email.
>
> One problem I've had with this lens is that apt.conf has two ways of
> defining subnodes, so that
>
> APT::Clean-Installed "true";
>
> is equivalent to
>
> APT {
> Clean-Installed "true";
> }
>
> The first approach I tried was to not use "::" as a separator, and use
> "APT::Clean-Installed" as a node label in the first case. This works,
> but doesn't really help with parsing, since you never know which
> syntax the configuration uses (and there can be more than 2 levels, so
> it can get _really_ messy), so the first case is parsed as:
>
> { "APT::Clean-Installed" = "true" }
>
> while the second syntax is parsed as:
>
> { "APT" { "Clean-Installed" = "true" } }
>
>
> Another approach is to consider "::" as a separator, and map the two
> syntaxes in the exact same fashion. Obviously, that leads to an
> ambiguity in the put direction, since the { "APT" { "Clean-Installed"
> = "true" } } tree can be mapped back to two different syntaxes.
> Since this is a recursive lens, this kind of ambiguity is not raised
> however, and the lens works fine this way, defaulting to the second
> syntax because it is the one that supports all of the options (and for
> that reason, I list it first in the union). There is just one little
> detail: it modifies the existing syntax when the tree is changed.
>
> So, for example,
>
> APT::Clean-Installed "true";
>
> is mapped to
>
> { "APT" { "Clean-Installed" = "true" } }
>
> but if we then do a set /APT/Clean-Installed "false" and save, we get:
>
> APT {
> Clean-Installed "false";
> };
>
> which is perfectly correct, but modifies the logic that was previously
> chosen. I can't think of a way to avoid this, and I'm very reluctant
> on giving up on parsing the "::" syntax as subnodes since it really
> improves the user interface.
>
>
> What do you guys think?
I don't use apt, so I wouldn't get too upset if the syntax changes; I
think that that is preferrable to having two different trees - that gets
very messy for users.
Of course, the fact that an ambiguity is exploited deserves a big
comment, and a test that will fail loudly if the way the ambiguity is
resolved ever changes.
David
More information about the augeas-devel
mailing list