Imported Upstream version 1.3.0
[platform/upstream/augeas.git] / lenses / reprepro_uploaders.aug
1 (*
2 Module: Reprepro_Uploaders
3   Parses reprepro's uploaders files
4
5 Author: Raphael Pinson <raphink@gmail.com>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man 1 reprepro` where possible.
9
10 About: License
11    This file is licenced under the LGPL v2+, like the rest of Augeas.
12
13 About: Lens Usage
14    See <lns>.
15
16 About: Configuration files
17    This lens applies to reprepro's uploaders files.
18
19 About: Examples
20    The <Test_Reprepro_Uploaders> file contains various examples and tests.
21 *)
22
23 module Reprepro_Uploaders =
24
25 (* View: logic_construct_condition
26    A logical construction for <condition> and <condition_list> *)
27 let logic_construct_condition (kw:string) (lns:lens) =
28     [ label kw . lns ]
29   . [ Sep.space . key kw . Sep.space . lns ]*
30
31 (* View: logic_construct_field
32    A generic definition for <condition_field> *)
33 let logic_construct_field (kw:string) (sep:string) (lns:lens) =
34     [ label kw . lns ]
35   . [ Build.xchgs sep kw . lns ]*
36
37 (* View: condition_re
38    A condition can be of several types:
39
40    - source
41    - byhand
42    - sections
43    - sections contain
44    - binaries
45    - binaries contain
46    - architectures
47    - architectures contain
48
49    While the lens technically also accepts "source contain"
50    and "byhand contain", these are not understood by reprepro.
51
52    The "contain" types are built by adding a "contain" subnode.
53    See the <condition_field> definition.
54
55  *)
56 let condition_re =
57     "source"
58   | "byhand"
59   | "sections"
60   | "binaries"
61   | "architectures"
62
63 (* View: condition_field
64    A single condition field is an 'or' node.
65    It may contain several values, listed in 'or' subnodes:
66
67    > $reprepro/allow[1]/and/or = "architectures"
68    > $reprepro/allow[1]/and/or/or[1] = "i386"
69    > $reprepro/allow[1]/and/or/or[2] = "amd64"
70    > $reprepro/allow[1]/and/or/or[3] = "all"
71
72  *)
73 let condition_field =
74   let sto_condition = Util.del_str "'" . store /[^'\n]+/ . Util.del_str "'" in
75     [ key "not" . Sep.space ]? .
76     store condition_re
77   . [ Sep.space . key "contain" ]?
78   . Sep.space
79   . logic_construct_field "or" "|" sto_condition
80
81 (* View: condition
82    A condition is an 'and' node,
83    representing a union of <condition_fields>,
84    listed under 'or' subnodes:
85
86    > $reprepro/allow[1]/and
87    > $reprepro/allow[1]/and/or = "architectures"
88    > $reprepro/allow[1]/and/or/or[1] = "i386"
89    > $reprepro/allow[1]/and/or/or[2] = "amd64"
90    > $reprepro/allow[1]/and/or/or[3] = "all"
91
92  *)
93 let condition =
94     logic_construct_condition "or" condition_field
95
96 (* View: condition_list
97    A list of <conditions>, inspired by Debctrl.dependency_list
98    An upload condition list is either the wildcard '*', stored verbatim,
99    or an intersection of conditions listed under 'and' subnodes:
100
101    > $reprepro/allow[1]/and[1]
102    > $reprepro/allow[1]/and[1]/or = "architectures"
103    > $reprepro/allow[1]/and[1]/or/or[1] = "i386"
104    > $reprepro/allow[1]/and[1]/or/or[2] = "amd64"
105    > $reprepro/allow[1]/and[1]/or/or[3] = "all"
106    > $reprepro/allow[1]/and[2]
107    > $reprepro/allow[1]/and[2]/or = "sections"
108    > $reprepro/allow[1]/and[2]/or/contain
109    > $reprepro/allow[1]/and[2]/or/or = "main"
110
111  *)
112 let condition_list =
113     store "*"
114   | logic_construct_condition "and" condition
115
116 (* View: by_key
117    When a key is used to authenticate packages,
118    the value can either be a key ID or "any":
119
120    > $reprepro/allow[1]/by/key = "ABCD1234"
121    > $reprepro/allow[2]/by/key = "any"
122
123  *)
124 let by_key =
125   let any_key   = [ store "any" . Sep.space
126                   . key "key" ] in
127   let named_key = [ key "key" . Sep.space
128                   . store (Rx.word - "any") ] in
129     value "key" . (any_key | named_key)
130
131 (* View: by
132    <by> statements define who is allowed to upload.
133    It can be simple keywords, like "anybody" or "unsigned",
134    or a key ID, in which case a "key" subnode is added:
135
136    > $reprepro/allow[1]/by/key = "ABCD1234"
137    > $reprepro/allow[2]/by/key = "any"
138    > $reprepro/allow[3]/by = "anybody"
139    > $reprepro/allow[4]/by = "unsigned"
140
141  *)
142 let by =
143     [ key "by" . Sep.space
144          . ( store ("anybody"|"unsigned")
145            | by_key ) ]
146
147 (* View: entry
148    An entry is an allow statement, e.g.:
149
150    > $reprepro/allow[1]
151    > $reprepro/allow[1]/and[1]
152    > $reprepro/allow[1]/and[1]/or = "architectures"
153    > $reprepro/allow[1]/and[1]/or/or[1] = "i386"
154    > $reprepro/allow[1]/and[1]/or/or[2] = "amd64"
155    > $reprepro/allow[1]/and[1]/or/or[3] = "all"
156    > $reprepro/allow[1]/and[2]
157    > $reprepro/allow[1]/and[2]/or = "sections"
158    > $reprepro/allow[1]/and[2]/or/contain
159    > $reprepro/allow[1]/and[2]/or/or = "main"
160    > $reprepro/allow[1]/by = "key"
161    > $reprepro/allow[1]/by/key = "ABCD1234"
162
163  *)
164 let entry =
165     [ key "allow" . Sep.space
166   . condition_list . Sep.space
167   . by . Util.eol ]
168
169 (* View: lns
170    The lens is made of <Util.empty>, <Util.comment> and <entry> lines *)
171 let lns = (Util.empty|Util.comment|entry)*