3 Parses /etc/apt/apt.conf and /etc/apt/apt.conf.d/*
5 Author: Raphael Pinson <raphink@gmail.com>
8 This lens tries to keep as close as possible to `man 5 apt.conf`
12 This file is licenced under the LGPL v2+, like the rest of Augeas.
17 About: Configuration files
18 This lens applies to /etc/apt/apt.conf and /etc/apt/apt.conf.d/*.
26 (************************************************************************
27 * Group: USEFUL PRIMITIVES
28 *************************************************************************)
31 And <Util.eol> end of line *)
35 A C-style empty line *)
36 let empty = Util.empty_any
40 let indent = Util.indent
42 (* View: comment_simple
43 A one-line comment, C-style *)
44 let comment_simple = Util.comment_c_style_or_hash
46 (* View: comment_multi
47 A multiline comment, C-style *)
48 let comment_multi = Util.comment_multiline
51 A comment, either <comment_simple> or <comment_multi> *)
52 let comment = comment_simple | comment_multi
55 (************************************************************************
57 *************************************************************************)
60 Regex for entry names *)
61 let name_re = /[A-Za-z][A-Za-z-]*/
63 (* View: name_re_colons
64 Regex for entry names with colons *)
65 let name_re_colons = /[A-Za-z][A-Za-z:-]*/
69 An apt.conf entry, recursive
72 This lens exploits a put ambiguity
73 since apt.conf allows for both
74 APT { Clean-Installed { "true" } }
75 and APT::Clean-Installed "true";
76 but we're choosing to map them the same way
78 The recursive lens doesn't seem
79 to care and defaults to the first
82 This is why the APT { Clean-Installed { "true"; } }
83 form is listed first, since it supports
84 all subnodes (which Dpkg::Conf) doesn't.
86 Exchanging these two expressions in the union
87 makes tests fails since the tree cannot
90 This situation results in existing
91 configuration being modified when the
92 associated tree is modified. For example,
94 APT::Clean-Installed "true"; to "false"
96 APT { Clean-Installed "false"; }
101 Util.del_str "\"" . store /[^"\n]+/
103 let opt_eol = del /[ \t\n]*/ "\n" in
104 let long_eol = del /[ \t]*\n+/ "\n" in
105 let list_elem = [ opt_eol . label "@elem" . value ] in
106 let eol_comment = del /([ \t\n]*\n)?/ "" . comment in
107 [ key name_re . Sep.space . value ]
108 | [ key name_re . del /[ \t\n]*\{/ " {" .
109 ( (opt_eol . entry_noeol) |
113 del /[ \t\n]*\};?/ "\n};" ]
114 | [ key name_re . Util.del_str "::" . entry_noeol ]
116 let entry = indent . entry_noeol . eol
121 /!\ The manpage is not clear on the syntax *)
123 [ indent . key "#include" . Sep.space
124 . store Rx.fspath . eol ]
128 A list of variables to clear
129 /!\ The manpage is not clear on the syntax *)
131 let name = [ label "name" . store name_re_colons ] in
132 [ indent . key "#clear" . Sep.space
133 . Build.opt_list name Sep.space
137 (************************************************************************
138 * Group: LENS AND FILTER
139 *************************************************************************)
143 let lns = (empty|comment|entry|include|clear)*
147 let filter = incl "/etc/apt/apt.conf"
148 . incl "/etc/apt/apt.conf.d/*"
151 let xfm = transform lns filter