Imported Upstream version 1.7.0
[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 a "!".
53
54 Not all letters are valid.
55 *)
56   let type     = /([fFwdDvpLcbCxXrRzZtThHaAm]|[AabcLp]\+)!?/
57
58   (* View: mode
59 "-", or 4 bytes. Optionally starts with a "~". *)
60   let mode     = /(-|~?[0-7]{4})/
61
62   (* View: age
63 "-", or one of the formats seen in the manpage: 10d, 5seconds, 1y5days.
64 optionally starts with a "~'. *)
65   let age      = /(-|(~?[0-9]+(s|m|min|h|d|w|ms|us|((second|minute|hour|day|week|millisecond|microsecond)s?))?)+)/
66
67   (* View: argument
68 The last field. It can contain spaces. *)
69   let argument = /([^# \t\n][^#\n]+)?[^# \t\n]/
70
71   (* View: field
72 Applies to the other fields: path, gid and uid fields *)
73   let field    = /[^# \t\n]+/
74
75   (* View: record
76 A valid record, one line in the file.
77 Only the two first fields are mandatory. *)
78   let record = [ seq "record" . sep_opt_spc .
79                    [ label "type" . store type ] . sep_spc .
80                    [ label "path" . store field ] . ( sep_spc .
81                    [ label "mode" . store mode ] . ( sep_spc .
82                    [ label "uid" . store field ] . ( sep_spc .
83                    [ label "gid" . store field ] . ( sep_spc .
84                    [ label "age" . store age ] . ( sep_spc .
85                    [ label "argument" . store argument ] )? )? )? )? )? .
86                      Util.comment_or_eol ]
87
88 (************************************************************************
89  * Group:                 THE TMPFILES LENSE
90  *************************************************************************)
91
92   (* View: lns
93 The tmpfiles lens.
94 Each line can be a comment, a record or empty. *)
95   let lns = ( empty | comment | record ) *
96
97   (* View: filter *)
98   let filter = incl "/etc/tmpfiles.d/*.conf"
99              . incl "/usr/lib/tmpfiles.d/*.conf"
100              . incl "/run/tmpfiles.d/*.conf"
101
102   let xfm = transform lns filter
103
104 (* Local Variables: *)
105 (* mode: caml *)
106 (* End: *)