[augeas-devel] Support for comments in aptsources.aug
Raphaël Pinson
raphink at gmail.com
Tue Apr 27 15:11:36 UTC 2010
Hi there,
This is a patch to support mapping comments in aptsources.aug:
diff --git a/lenses/aptsources.aug b/lenses/aptsources.aug
index d1fc423..ab47802 100644
--- a/lenses/aptsources.aug
+++ b/lenses/aptsources.aug
@@ -7,18 +7,19 @@ module Aptsources =
let eol = Util.del_str "\n"
- let comment = [ del /([ \t]*\n)|(#.*\n)/ "#\n" ]
+ let comment = Util.comment
+ let empty = Util.empty
let word = /[^# \n\t]+/
- let record = [ seq "source" . [ label "type" . store word ] . sep_ws .
+ let record = [ label "entry" . [ label "type" . store word ] . sep_ws .
[ label "uri" . store word ] . sep_ws .
[ label "distribution" . store word ] .
[ label "component" . sep_ws . store word
]* .
del /[ \t]*(#.*)?/ ""
. eol ]
- let lns = ( comment | record ) *
+ let lns = ( comment | empty | record ) *
let filter = (incl "/etc/apt/sources.list")
. (incl "/etc/apt/sources.list.d/*")
diff --git a/lenses/tests/test_aptsource.aug
b/lenses/tests/test_aptsource.aug
index e1ca9c0..fafa320 100644
--- a/lenses/tests/test_aptsource.aug
+++ b/lenses/tests/test_aptsource.aug
@@ -4,7 +4,7 @@ module Test_aptsource =
let multi_components = "deb http://security.debian.org/ etch/updates main
contrib non-free\n"
test Aptsources.lns get simple_source =
- { "1"
+ { "entry"
{ "type" = "deb" }
{ "uri" = "ftp://mirror.bytemark.co.uk/debian/" }
{ "distribution" = "etch" }
@@ -12,7 +12,7 @@ module Test_aptsource =
}
test Aptsources.lns get multi_components =
- { "1"
+ { "entry"
{ "type" = "deb" }
{ "uri" = "http://security.debian.org/" }
{ "distribution" = "etch/updates" }
@@ -30,8 +30,10 @@ deb http://security.debian.org/ etch/updates main contrib
non-free # security li
deb-src http://mirror.bytemark.co.uk/debian etch main contrib non-free\n"
test Aptsources.lns get multi_line =
- {} {} {}
- { "1"
+ { "#comment" = "deb http://www.backports.org/debian/ sarge postfix" }
+ { "#comment" = "deb http://people.debian.org/~adconrad sarge
subversion" }
+ {}
+ { "entry"
{ "type" = "deb" }
{ "uri" = "ftp://mirror.bytemark.co.uk/debian/" }
{ "distribution" = "etch" }
@@ -39,7 +41,7 @@ deb-src http://mirror.bytemark.co.uk/debian etch main
contrib non-free\n"
{ "component" = "non-free" }
{ "component" = "contrib" }
}
- { "2"
+ { "entry"
{ "type" = "deb" }
{ "uri" = "http://security.debian.org/" }
{ "distribution" = "etch/updates" }
@@ -47,7 +49,7 @@ deb-src http://mirror.bytemark.co.uk/debian etch main
contrib non-free\n"
{ "component" = "contrib" }
{ "component" = "non-free" }
}
- { "3"
+ { "entry"
{ "type" = "deb-src" }
{ "uri" = "http://mirror.bytemark.co.uk/debian" }
{ "distribution" = "etch" }
@@ -60,7 +62,7 @@ deb-src http://mirror.bytemark.co.uk/debian etch main
contrib non-free\n"
(* Should be a noop; makes sure that we preserve the trailing comment
*)
test Aptsources.lns put trailing_comment after
- set "/1/type" "deb"
+ set "/entry/type" "deb"
= trailing_comment
(* Local Variables: *)
Regards,
Raphaël Pinson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20100427/d02fca29/attachment.htm>
More information about the augeas-devel
mailing list