[augeas-devel] Bash-like configs (for Arch Linux)

David Lutterkort lutter at redhat.com
Wed Dec 2 19:44:21 UTC 2009


On Wed, 2009-12-02 at 11:23 -0800, David Lutterkort wrote:
> On Mon, 2009-11-30 at 21:06 +0100, Jon Nordby wrote:
> > I want to make some Arch Linux system configuration files accessible
> > from augeas. They are essentially bash shell-scripts, but can have
> > arrays span over several lines. So some new code is needed.
> 
> They are still legal shell scripts, right ? I assume they look like
>         A=(x y
>         z)
> 
> >  At this time its very unlikely that they are interested in
> > distributing the files. Will you accept a patch for this and include
> > it in your tree?
> 
> Yes, absolutely.
> 
> > I'm thinking a new file under lenses/dist called arch_scripts.aug or
> > similar (and tests ofc), using the lenses I can from the Shellvars
> > module.
> > 
> > 
> > I also want to implement the files used for building packages. Same
> > system as above, but also has bash functions. These files can exist
> > anywhere in the system, but are always named "PKGBUILD" or
> > "*.install". Often there are hundreds of these, so I don't want them
> > to be parsed on start-up. How do I achieve this?
> 
> Augeas only parses files at startup that are mentioned in an 'autoload'
> directive in some *.aug file - if you don't have one, you can always
> load them later on with something like
> 
>         > augtool --noautoload  # the --noautoload isn't strictly
>         necessary
>         augtool> rm /augeas/load/*
>         augtool> set /augeas/load/Arch/lens ArchVars.lns
>         augtool> set /augeas/load/Arch/incl /some/dir/*/PKBUILD
>         augtool> load
> 
> As for allowing arrays that span multiple lines, how about this patch ?
> 
> >From 0f0ce37f96bfa8651b9e4cab107a4dcc7dcc6aa1 Mon Sep 17 00:00:00 2001
> From: David Lutterkort <lutter at redhat.com>
> Date: Wed, 2 Dec 2009 11:19:09 -0800
> Subject: [PATCH] Shellvars: allow arrays that span multiple lines
> 
> ---
>  lenses/shellvars.aug            |    2 +-
>  lenses/tests/test_shellvars.aug |    6 ++++++
>  2 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/lenses/shellvars.aug b/lenses/shellvars.aug
> index ec8518c..b407bac 100644
> --- a/lenses/shellvars.aug
> +++ b/lenses/shellvars.aug
> @@ -22,7 +22,7 @@ module Shellvars =
>      let array_value = store (char+ | dquot) in
>      del "(" "(" . counter "values" .
>        [ seq "values" . array_value ] .
> -      [ del /[ \t]+/ " " . seq "values" . array_value ] *
> +      [ del /[ \t\n]+/ " " . seq "values" . array_value ] *
>        . del ")" ")"
>  
>    (* Treat an empty list () as a value '()'; that's not quite correct
> *)
> diff --git a/lenses/tests/test_shellvars.aug
> b/lenses/tests/test_shellvars.aug
> index d161b4f..94fb747 100644
> --- a/lenses/tests/test_shellvars.aug
> +++ b/lenses/tests/test_shellvars.aug
> @@ -100,6 +100,12 @@ unset ONBOOT
>      set "var/3" "v3"
>    = "var=(v1 v2 v3)\n"
>  
> +  test Shellvars.lns get "var=(v1 v2   \n    \t v3)\n" =
> +  { "var"
> +    { "1" = "v1" }
> +    { "2" = "v2" }
> +    { "3" = "v3" } }
> +
>  (* Local Variables: *)
>  (* mode: caml       *)
>  (* End:             *)




More information about the augeas-devel mailing list