Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / aptsources.aug
1 (*
2 Module: Aptsources
3   Parsing /etc/apt/sources.list
4 *)
5
6 module Aptsources =
7   autoload xfm
8
9 (************************************************************************
10  * Group: Utility variables/functions
11  ************************************************************************)
12   (* View:  sep_ws *)
13   let sep_ws = Sep.space
14
15   (* View: eol *)
16   let eol = Util.del_str "\n"
17
18   (* View: comment *)
19   let comment = Util.comment
20   (* View: empty *)
21   let empty = Util.empty
22
23   (* View: word *)
24   let word = /[^][# \n\t]+/
25
26   (* View: uri *)
27   let uri =
28        let protocol = /[a-z+]+:/
29     in let path = /\/[^] \t]*/
30     in let path_brack = /\[[^]]+\]\/?/
31     in protocol? . path
32      | protocol . path_brack
33
34 (************************************************************************
35  * Group: Keywords
36  ************************************************************************)
37   (* View: record *)
38   let record =
39        let option_sep = [ label "operation" . store /[+-]/]? . Sep.equal
40     in let option = Build.key_value /arch|trusted/ option_sep (store Rx.word)
41     in let options = [ label "options"
42                 . Util.del_str "[" . Sep.opt_space
43                 . Build.opt_list option Sep.space
44                 . Sep.opt_space . Util.del_str "]"
45                 . sep_ws ]
46     in [ Util.indent . seq "source"
47        . [ label "type" . store word ] . sep_ws
48        . options?
49        . [ label "uri"  . store uri ] . sep_ws
50        . [ label "distribution" . store word ]
51        . [ label "component" . sep_ws . store word ]*
52        . del /[ \t]*(#.*)?/ ""
53        . eol ]
54
55 (************************************************************************
56  * Group: Lens
57  ************************************************************************)
58   (* View: lns *)
59   let lns = ( comment | empty | record ) *
60
61   (* View: filter *)
62   let filter = (incl "/etc/apt/sources.list")
63       . (incl "/etc/apt/sources.list.d/*")
64       . Util.stdexcl
65
66   let xfm = transform lns filter
67
68 (* Local Variables: *)
69 (* mode: caml *)
70 (* End: *)