module ZYpper = autoload xfm (* These are taken from the official util.aug *) (* Variable: eol Delete end of line, including optional trailing whitespace *) let eol = del /[ \t]*\n/ "\n" (* Variable: del_str Delete a string and default to it Parameters: s:string - the string to delete and default to *) let del_str (s:string) = del s s (* Variable: del_opt_ws Delete optional whitespace *) let del_opt_ws = del /[ \t]*/ let empty = [ eol ] let store_to_eol = del_opt_ws " " . store /([^ \t\n].*[^ \t\n])/ let kw_re = /[a-zA-Z][a-zA-Z0-9\._]*[a-zA-Z0-9]/ let description = [ label "description" . del /##/ "##" . store_to_eol? . eol ] let commented = [ label "commented" . del /#[ \t]*/ "# " ] let option = [ seq "option" . description* . commented? . [ key kw_re . del /[ \t]*=[ \t]*/ " = " . store /[^# \t\n][^#\n]*/ ] . del_str "\n" ] let section_title = del_str "[" . key /[^] \t\n\/]+/ . del_str "]" . eol let section = [ section_title . (option | empty)* ] let section_anon = [ label "anon" . ( description | empty )+ ] let lns = section_anon . section+ let filter = (incl "/etc/zypp/zypper.conf") let xfm = transform lns filter