Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / dpkg.aug
1 (*
2 Module: Dpkg
3     Parses /etc/dpkg/dpkg.cfg
4
5 Author: Robin Lee Powell <rlpowell@digitalkingdom.org>
6
7 About: License
8     This file, and the attendant test_dpgk.aug, are explicitly
9     placed in the public domain.
10
11 About: Description
12     dpkg.cfg is a simple list of options, the same ones as the
13     command line options, with or without a value.
14
15     The tree is a list of either comments or option/value pairs by
16     name. Use "set" to set an option with a value, and "clear" for a
17     bare option.
18
19 About: Usage Example
20
21 (start code)
22     $ augtool -n
23     augtool> ls /files/etc/dpkg/dpkg.cfg
24     #comment[1] = dpkg configuration file
25     #comment[2] = This file can contain default options for dpkg.  All command-line
26     #comment[3] = options are allowed.  Values can be specified by putting them after
27     #comment[4] = the option, separated by whitespace and/or an `=' sign.
28     #comment[5] = Do not enable debsig-verify by default; since the distribution is not using
29     #comment[6] = embedded signatures, debsig-verify would reject all packages.
30     no-debsig = (none)
31     #comment[7] = Log status changes and actions to a file.
32     log = /var/log/dpkg.log
33     augtool> get /files/etc/dpkg/dpkg.cfg/no-debsig
34     /files/etc/dpkg/dpkg.cfg/no-debsig (none)
35     augtool> get /files/etc/dpkg/dpkg.cfg/log
36     /files/etc/dpkg/dpkg.cfg/log = /var/log/dpkg.log
37     augtool> clear /files/etc/dpkg/dpkg.cfg/testopt
38     augtool> set /files/etc/dpkg/dpkg.cfg/testopt2 test
39     augtool> save
40     Saved 1 file(s)
41     augtool>
42     $ cat /etc/dpkg/dpkg.cfg.augnew
43     # dpkg configuration file
44     #
45     # This file can contain default options for dpkg.  All command-line
46     # options are allowed.  Values can be specified by putting them after
47     # the option, separated by whitespace and/or an `=' sign.
48     #
49
50     # Do not enable debsig-verify by default; since the distribution is not using
51     # embedded signatures, debsig-verify would reject all packages.
52     no-debsig
53
54     # Log status changes and actions to a file.
55     log /var/log/dpkg.log
56     testopt
57     testopt2 test
58 (end code)
59
60 *)
61
62 module Dpkg =
63   autoload xfm
64
65   let sep_tab = Util.del_ws_tab
66   let sep_spc = Util.del_ws_spc
67   let eol = del /[ \t]*\n/ "\n"
68
69   let comment = Util.comment
70   let empty   = Util.empty
71
72   let word = /[^,# \n\t]+/
73   let keyword = /[^,# \n\t\/]+/
74
75   (* View: record
76       Keyword, followed by optional whitespace and value, followed
77       by EOL.
78
79       The actual file specification doesn't require EOL, but the
80       likelihood of the file not having one is pretty slim, and
81       this way things we add have EOL.
82   *)
83
84   let record = [ key keyword . (sep_spc . store word)? . eol ]
85
86   (* View: lns
87       Any number of empty lines, comments, and records.
88   *)
89   let lns = ( empty | comment | record ) *
90
91   let xfm = transform lns (incl "/etc/dpkg/dpkg.cfg")