Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / modprobe.aug
1 (*
2 Module: Modprobe
3   Parses /etc/modprobe.conf and /etc/modprobe.d/*
4
5 Original Author: David Lutterkort <lutter@redhat.com>
6
7 Author: Raphael Pinson <raphink@gmail.com>
8
9 About: Reference
10   This lens tries to keep as close as possible to `man 5 modprobe.conf` where possible.
11
12 About: License
13    This file is licenced under the LGPL v2+, like the rest of Augeas.
14
15 About: Lens Usage
16    To be documented
17
18 About: Configuration files
19    This lens applies to /etc/modprobe.conf and /etc/modprobe.d/*. See <filter>.
20 *)
21
22 module Modprobe =
23 autoload xfm
24
25 (************************************************************************
26  * Group:                 USEFUL PRIMITIVES
27  *************************************************************************)
28
29 (* View: comment *)
30 let comment = Util.comment
31
32 (* View: empty *)
33 let empty = Util.empty
34
35 (* View: sep_space *)
36 let sep_space = del /([ \t]|(\\\\\n))+/ " "
37
38 (* View: sto_no_spaces *)
39 let sto_no_spaces = store /[^# \t\n\\\\]+/
40
41 (* View: sto_no_colons *)
42 let sto_no_colons = store /[^:# \t\n\\\\]+/
43
44 (* View: sto_to_eol *)
45 let sto_to_eol = store /(([^# \t\n\\\\][^#\n\\\\]*[ \t]*\\\\[ \t]*\n[ \t]*)*([^# \t\n\\\\][^#\n\\\\]*[^# \t\n\\\\]|[^# \t\n\\\\])|[^# \t\n\\\\])/
46
47 (* View: alias *)
48 let alias =
49   let modulename = [ label "modulename" . sto_no_spaces ] in
50   Build.key_value_line_comment "alias" sep_space
51                        (sto_no_spaces . sep_space . modulename)
52                        comment
53
54 (************************************************************************
55  * Group:                 ENTRY TYPES
56  *************************************************************************)
57
58 (* View: options *)
59 let options =
60   let opt_value = /[^#" \t\n\\\\]+|"[^#"\n\\\\]*"/ in
61   let option = [ key Rx.word . (del /[ \t]*=[ \t]*/ "=" . store opt_value)? ] in
62   [ key "options" . sep_space . sto_no_spaces
63                   . (sep_space . option)* . Util.comment_or_eol ]
64
65 (* View: install_remove *)
66 let kv_line_command (kw:regexp) =
67   let command = [ label "command" . sto_to_eol ] in
68   [ key kw . sep_space . sto_no_spaces
69                          . sep_space . command . Util.comment_or_eol ]
70
71 (* View: blacklist *)
72 let blacklist = Build.key_value_line_comment "blacklist" sep_space
73                        sto_no_spaces
74                        comment
75
76 (* View: config *)
77 let config = Build.key_value_line_comment "config" sep_space
78                        (store /binary_indexes|yes|no/)
79                        comment
80
81 (* View: softdep *)
82 let softdep =
83   let premod  = [ label "pre" . sep_space . sto_no_colons ] in
84     let pre   = sep_space . Util.del_str "pre:" . premod+ in
85   let postmod = [ label "post" . sep_space . sto_no_colons ] in
86     let post  = sep_space . Util.del_str "post:" . postmod+ in
87   [ key "softdep" . sep_space . sto_no_colons . pre? . post?
88     . Util.comment_or_eol ]
89
90 (* View: entry *)
91 let entry = alias
92           | options
93           | kv_line_command /install|remove/
94           | blacklist
95           | config
96           | softdep
97
98 (************************************************************************
99  * Group:                 LENS AND FILTER
100  *************************************************************************)
101
102 (* View: lns *)
103 let lns = (comment|empty|entry)*
104
105 (* View: filter *)
106 let filter = (incl "/etc/modprobe.conf") .
107   (incl "/etc/modprobe.d/*").
108   (incl "/etc/modprobe.conf.local").
109   Util.stdexcl
110
111 let xfm = transform lns filter