[augeas-devel] Avoiding wheel reinvention with dpkg.cfg, and setting empty things.

Robin Lee Powell rlpowell at digitalkingdom.org
Mon Dec 29 19:56:48 UTC 2008


On Sun, Dec 28, 2008 at 08:52:14PM -0800, Robin Lee Powell wrote:
> 
> So I'm trying to work with debian's /etc/dpkg/dpkg.cfg.  It's
> incredibly simple: # comments, real lines are command-line options
> names, possibly with a space-seperated single argument, i.e.:

Ended up writing it myself.  I'm pasting it below because I hit a
segfault in Augeas:

- ----------------

(* Parsing /etc/dpkg/dpkg.cfg *)

module Dpkg =
  autoload xfm

  let sep_tab = Util.del_ws_tab
  let sep_spc = Util.del_ws_spc
  let eol = del /[ \t]*\n/ "\n"

  let comment = Util.comment
  let empty   = Util.empty

  let word = /[^,# \n\t]+/

  let bare_option = [ label "bare_option" . store word ]

  let valued_option = [ label "value_option" . store word ] . sep_spc .
                        [ label "value" . store word ]

  let record = [ seq "option" . ( bare_option | valued_option ) . eol ]

  let lns = ( empty | comment | record ) *

  let xfm = transform lns (incl "/etc/dpkg/dpkg.cfg")

(* Local Variables: *)
(* mode: caml *)
(* End: *)

- ----------------

I'm sure I could have done things better, but the docs are a bit
lacking.  :)  I have no idea what the "seq" keyword actually *does*,
for example.

Anyways, if you replace the record line with:

  let record = [ seq "option" . bare_option | valued_option . eol ]

Then Augeas segfaults.

-Robin

-- 
They say:  "The first AIs will be built by the military as weapons."
And I'm thinking:  "Does it even occur to you to try for something
other than the default outcome?" -- http://shorl.com/tydruhedufogre
http://www.digitalkingdom.org/~rlpowell/ *** http://www.lojban.org/




More information about the augeas-devel mailing list