Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / tmpfiles.aug
1 (*
2 Module: Tmpfiles
3   Parses systemd tmpfiles.d files
4
5 Author: Julien Pivotto <roidelapluie@inuits.eu>
6
7 About: Reference
8   This lens tries to keep as close as possible to `man 5 tmpfiles.d` 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    To be documented
15
16 About: Configuration files
17    This lens applies to /etc/tmpfiles.d/*.conf /usr/lib/tmpfiles.d/*.conf and
18    /run/tmpfiles.d/*.conf. See <filter>.
19
20 About: Examples
21    The <Test_Tmpfiles> file contains various examples and tests.
22 *)
23
24 module Tmpfiles =
25   autoload xfm
26
27 (************************************************************************
28  * Group:                 USEFUL PRIMITIVES
29  *************************************************************************)
30
31 (* Group: Comments and empty lines *)
32
33   (* View: sep_spc
34 Space *)
35   let sep_spc = Sep.space
36
37   (* View: sep_opt_spc
38 Optional space (for the beginning of the lines) *)
39   let sep_opt_spc = Sep.opt_space
40
41   (* View: comment
42 Comments *)
43   let comment = Util.comment
44
45   (* View: empty
46 Empty lines *)
47   let empty   = Util.empty
48
49 (* Group: Lense-specific primitives *)
50
51   (* View: type
52 One letter. Some of them can have a "+" and all can have an
53 exclamation mark ("!"), a minus sign ("-"), an equal sign ("="),
54 a tilde character ("~") and/or a caret ("^").
55
56 Not all letters are valid.
57 *)
58   let type     = /([fFwdDevqQpLcbCxXrRzZtThHaAm]|[fFwpLcbaA]\+)[-!=~^]*/
59
60   (* View: mode
61 "-", or 3-4 bytes. Optionally starts with a "~" or a ":". *)
62   let mode     = /(-|(~|:)?[0-7]{3,4})/
63
64   (* View: age
65 "-", or one of the formats seen in the manpage: 10d, 5seconds, 1y5days.
66 optionally starts with a "~'. *)
67   let age      = /(-|(~?[0-9]+(s|m|min|h|d|w|ms|us|((second|minute|hour|day|week|millisecond|microsecond)s?))?)+)/
68
69   (* View: argument
70 The last field. It can contain spaces. *)
71   let argument = /([^# \t\n][^#\n]*[^# \t\n]|[^# \t\n])/
72
73   (* View: field
74 Applies to the other fields: path, gid and uid fields *)
75   let field    = /[^# \t\n]+/
76
77   (* View: record
78 A valid record, one line in the file.
79 Only the two first fields are mandatory. *)
80   let record = [ seq "record" . sep_opt_spc .
81                    [ label "type" . store type ] . sep_spc .
82                    [ label "path" . store field ] . ( sep_spc .
83                    [ label "mode" . store mode ] . ( sep_spc .
84                    [ label "uid" . store field ] . ( sep_spc .
85                    [ label "gid" . store field ] . ( sep_spc .
86                    [ label "age" . store age ] . ( sep_spc .
87                    [ label "argument" . store argument ] )? )? )? )? )? .
88                      Util.comment_or_eol ]
89
90 (************************************************************************
91  * Group:                 THE TMPFILES LENSE
92  *************************************************************************)
93
94   (* View: lns
95 The tmpfiles lens.
96 Each line can be a comment, a record or empty. *)
97   let lns = ( empty | comment | record ) *
98
99   (* View: filter *)
100   let filter = incl "/etc/tmpfiles.d/*.conf"
101              . incl "/usr/lib/tmpfiles.d/*.conf"
102              . incl "/run/tmpfiles.d/*.conf"
103
104   let xfm = transform lns filter
105
106 (* Local Variables: *)
107 (* mode: caml *)
108 (* End: *)