3 Parses ./debian/control
6 Dominique Dumont domi.dumont@free.fr or dominique.dumont@hp.com
9 http://augeas.net/page/Create_a_lens_from_bottom_to_top
10 http://www.debian.org/doc/debian-policy/ch-controlfields.html
13 This file is licensed under the LGPL v2+.
16 Since control file is not a system configuration file, you will have
17 to use augtool -r option to point to 'debian' directory.
22 Sample usage of this lens in augtool:
24 * Get the value stored in control file
25 > print /files/control
39 let del_ws_spc = del /[\t ]*/ " "
40 let hardeol = del /\n/ "\n"
41 let del_opt_ws = del /[\t ]*/ ""
42 let colon = del /:[ \t]*/ ": "
44 let simple_entry (k:regexp) =
45 let value = store /[^ \t][^\n]+/ in
46 [ key k . colon . value . hardeol ]
48 let cont_line = del /\n[ \t]+/ "\n "
49 let comma = del /,[ \t]*/ ", "
51 let sep_comma_with_nl = del /[ \t\n]*,[ \t\n]*/ ",\n "
52 (*= del_opt_ws . cont_line* . comma . cont_line**)
54 let email = store ( /([A-Za-z]+ )+<[^\n>]+>/ | /[^\n,\t<> ]+/ )
56 let multi_line_array_entry (k:regexp) (v:lens) =
57 [ key k . colon . [ counter "array" . seq "array" . v ] .
58 [ seq "array" . sep_comma_with_nl . v ]* . hardeol ]
60 (* dependency stuff *)
64 . [ del / *\( */ " ( " . label "relation" . store /[<>=]+/ ]
65 . [ del_ws_spc . label "number"
66 . store ( /[a-zA-Z0-9_.-]+/ | /\$\{[a-zA-Z0-9:]+\}/ )
72 . [ del / *\[ */ " [ " . label "prefix" . store /!?/ ]
73 . [ label "name" . store /[a-zA-Z0-9_.-]+/ . del / *\]/ " ]" ] ]
77 = [ key ( /[a-zA-Z0-9_-]+/ | /\$\{[a-zA-Z0-9:]+\}/ )
78 . ( version_depends | arch_depends ) * ]
81 let dependency = [ label "or" . package_depends ]
82 . [ label "or" . del / *\| */ " | "
85 let dependency_list (field:regexp) =
86 [ key field . colon . [ label "and" . dependency ]
87 . [ label "and" . sep_comma_with_nl . dependency ]*
92 multi_line_array_entry /Uploaders/ email
94 let simple_src_keyword = "Source" | "Section" | "Priority"
95 | "Standards\-Version" | "Homepage" | /Vcs\-Svn/ | /Vcs\-Browser/
96 | "Maintainer" | "DM-Upload-Allowed" | /XS?-Python-Version/
97 let depend_src_keywords = /Build\-Depends/ | /Build\-Depends\-Indep/
99 let src_entries = ( simple_entry simple_src_keyword
101 | dependency_list depend_src_keywords ) *
104 (* package paragraph *)
105 let multi_line_entry (k:string) =
106 let line = /.*[^ \t\n].*/ in
107 [ label k . del / / " " . store line . hardeol ] *
111 = [ key "Description" . colon
112 . [ label "summary" . store /[a-zA-Z][^\n]+/ . hardeol ]
113 . multi_line_entry "text" ]
117 let simple_bin_keywords = "Package" | "Architecture" | "Section"
118 | "Priority" | "Essential" | "Homepage" | "XB-Python-Version"
119 let depend_bin_keywords = "Depends" | "Recommends" | "Suggests" | "Provides"
121 let bin_entries = ( simple_entry simple_bin_keywords
122 | dependency_list depend_bin_keywords
125 (* The whole stuff *)
126 let lns = [ label "srcpkg" . src_entries ]
127 . [ label "binpkg" . hardeol+ . bin_entries ]+
130 (* lens must be used with AUG_ROOT set to debian package source directory *)
131 let xfm = transform lns (incl "/control")