3 Parses (Open)BSD-stype /etc/boot.conf
5 Author: Jasper Lievisse Adriaanse <jasper@jasper.la>
8 This lens is used to parse the second-stage bootstrap configuration
9 file, /etc/boot.conf as found on OpenBSD. The format is largely MI,
10 with MD parts included:
11 http://www.openbsd.org/cgi-bin/man.cgi?query=boot.conf&arch=i386
17 This file is licensed under the LGPL v2+, like the rest of Augeas.
19 About: Configuration files
20 This lens applies to /etc/boot.conf.
27 (************************************************************************
28 * Utility variables/functions
29 ************************************************************************)
32 let comment = Util.comment
34 let empty = Util.empty
38 let fspath = Rx.fspath
44 (************************************************************************
45 * View: key_opt_value_line
46 * A subnode with a keyword, an optional part consisting of a separator
47 * and a storing lens, and an end of line
50 * kw:regexp - the pattern to match as key
51 * sto:lens - the storing lens
52 ************************************************************************)
53 let key_opt_value_line (kw:regexp) (sto:lens) =
54 [ key kw . (space . sto)? . eol ]
56 (************************************************************************
58 ************************************************************************)
60 (* View: single_command
61 single command such as 'help' or 'time' *)
63 let line_re = /help|time|reboot/
64 in [ Util.indent . key line_re . eol ]
68 let ls = Build.key_value_line
69 "ls" space (store fspath)
80 set [varname [value]] *)
81 let set = Build.key_value
83 (key_opt_value_line set_cmd (store Rx.space_in))
86 stty [device [speed]] *)
88 let device = [ label "device" . store fspath ]
89 in let speed = [ label "speed" . store Rx.integer ]
90 in key_opt_value_line "stty" (device . (space . speed)?)
94 let echo = Build.key_value_line
95 "echo" space (store word)
99 XXX: the last arguments are not always needed, so make them optional *)
101 let image = [ label "image" . store fspath ]
102 in let arg = [ label "arg" . store word ]
103 in Build.key_value_line "boot" space (image . space . arg)
108 let machine_entry = Build.key_value ("comaddr"|"memory")
110 | Build.flag ("diskinfo"|"regs")
111 in Build.key_value_line
117 (************************************************************************
119 ************************************************************************)
122 let command = boot | echo | ls | machine | set | stty
125 let lns = ( empty | comment | command | single_command )*
127 (* Variable: filter *)
128 let filter = (incl "/etc/boot.conf")
130 let xfm = transform lns filter