AptConf

Parses /etc/apt/apt.conf and /etc/apt/apt.conf.d/*

Author: Raphael Pinson rap.nosp@m.hink@gmai.nosp@m.l.com

Summary
AptConfParses /etc/apt/apt.conf and /etc/apt/apt.conf.d/*
ReferenceThis lens tries to keep as close as possible to `man 5 apt.conf` where possible.
LicenseThis file is licenced under the LGPL v2+, like the rest of Augeas.
Lens UsageTo be documented
Configuration filesThis lens applies to /etc/apt/apt.conf and /etc/apt/apt.conf.d/*.
USEFUL PRIMITIVES
eolAnd Util.eol end of line
emptyA C-style empty line
indentAn indentation
comment_simpleA one-line comment, C-style
comment_multiA multiline comment, C-style
commentA comment, either comment_simple or comment_multi
ENTRIES
name_reRegex for entry names
name_re_colonsRegex for entry names with colons
entryAn apt.conf entry, recursive
includeA file inclusion /!\ The manpage is not clear on the syntax
clearA list of variables to clear /!\ The manpage is not clear on the syntax
LENS AND FILTER
lnsThe apt.conf lens
filter

Reference

This lens tries to keep as close as possible to `man 5 apt.conf` where possible.

License

This file is licenced under the LGPL v2+, like the rest of Augeas.

Lens Usage

To be documented

Configuration files

This lens applies to /etc/apt/apt.conf and /etc/apt/apt.conf.d/*.  See filter.

USEFUL PRIMITIVES

eol

let eol = Util.eol

And Util.eol end of line

empty

let empty = Util.empty_any

A C-style empty line

indent

let indent = Util.indent

An indentation

comment_simple

let comment_simple = Util.comment_c_style_or_hash

A one-line comment, C-style

comment_multi

let comment_multi = Util.comment_multiline

A multiline comment, C-style

comment

let comment = comment_simple | comment_multi

A comment, either comment_simple or comment_multi

ENTRIES

name_re

let name_re = /[A-Za-z][A-Za-z-]*/

Regex for entry names

name_re_colons

let name_re_colons = /[A-Za-z][A-Za-z:-]*/

Regex for entry names with colons

entry

let rec entry_noeol = let value = Util.del_str "\"" . store /[^"\n]+/ . del /";?/ "\";" in let opt_eol = del /[ \t\n]*/ "\n" in let long_eol = del /[ \t]*\n+/ "\n" in let list_elem = [ opt_eol . label "@elem" . value ] in let eol_comment = del /([ \t\n]*\n)?/ "" . comment in [ key name_re . Sep.space . value ] | [ key name_re . del /[ \t\n]*\{/ " {" . ( (opt_eol . entry_noeol) | list_elem | eol_comment )* . del /[ \t\n]*\};?/ "\n};" ] | [ key name_re . Util.del_str "::" . entry_noeol ]

An apt.conf entry, recursive

WARNING

This lens exploits a put ambiguity since apt.conf allows for both APT { Clean-Installed { “true” } } and APT::Clean-Installed “true”; but we’re chosing to map them the same way

The recursive lens doesn’t seem to care and defaults to the first item in the union.

This is why the APT { Clean-Installed { “true”; } } form is listed first, since it supports all subnodes (which Dpkg::Conf) doesn’t.

Exchanging these two expressions in the union makes tests fails since the tree cannot be mapped back.

This situation results in existing configuration being modified when the associated tree is modified.  For example, changing the value of APT::Clean-Installed “true”; to “false” results in APT { Clean-Installed “false”; }

(see unit tests)

include

let include = [ indent . key "#include" . Sep.space . store Rx.fspath . eol ]

A file inclusion /!\ The manpage is not clear on the syntax

clear

let clear = let name = [ label "name" . store name_re_colons ] in [ indent . key "#clear" . Sep.space . Build.opt_list name Sep.space . eol ]

A list of variables to clear /!\ The manpage is not clear on the syntax

LENS AND FILTER

lns

let lns = (empty|comment|entry|include|clear)*

The apt.conf lens

filter

let eol = Util.eol
And Util.eol end of line
let eol = del /[ \t]*\n/ "\n"
Delete end of line, including optional trailing whitespace
let empty = Util.empty_any
A C-style empty line
let indent = Util.indent
An indentation
let comment_simple = Util.comment_c_style_or_hash
A one-line comment, C-style
let comment_multi = Util.comment_multiline
A multiline comment, C-style
let comment = comment_simple | comment_multi
A comment, either comment_simple or comment_multi
let name_re = /[A-Za-z][A-Za-z-]*/
Regex for entry names
let name_re_colons = /[A-Za-z][A-Za-z:-]*/
Regex for entry names with colons
let rec entry_noeol = let value = Util.del_str "\"" . store /[^"\n]+/ . del /";?/ "\";" in let opt_eol = del /[ \t\n]*/ "\n" in let long_eol = del /[ \t]*\n+/ "\n" in let list_elem = [ opt_eol . label "@elem" . value ] in let eol_comment = del /([ \t\n]*\n)?/ "" . comment in [ key name_re . Sep.space . value ] | [ key name_re . del /[ \t\n]*\{/ " {" . ( (opt_eol . entry_noeol) | list_elem | eol_comment )* . del /[ \t\n]*\};?/ "\n};" ] | [ key name_re . Util.del_str "::" . entry_noeol ]
An apt.conf entry, recursive
let include = [ indent . key "#include" . Sep.space . store Rx.fspath . eol ]
A file inclusion /!\ The manpage is not clear on the syntax
let clear = let name = [ label "name" . store name_re_colons ] in [ indent . key "#clear" . Sep.space . Build.opt_list name Sep.space . eol ]
A list of variables to clear /!\ The manpage is not clear on the syntax
let lns = (empty|comment|entry|include|clear)*
The apt.conf lens
Close