5 Central repository of regexes for dak
7 @contact: Debian FTP Master <ftpmaster@debian.org>
8 @copyright: 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
9 @copyright: 2009 Mark Hymers <mhy@debian.org>
10 @copyright: 2009, 2010 Joerg Jaspert <joerg@debian.org>
11 @license: GNU General Public License version 2 or later
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 ###############################################################################
33 re_isanum = re.compile (r"^\d+$")
35 #: Looking for the default reply
36 re_default_answer = re.compile(r"\[(.*)\]")
38 re_bin_only_nmu = re.compile(r"\+b\d+$")
40 #: To sort out comment lines
41 re_comments = re.compile(r"\#.*")
42 #: To ignore comment and whitespace lines.
43 re_whitespace_comment = re.compile(r"^\s*(#|$)")
44 re_no_epoch = re.compile(r"^\d+\:")
45 re_extract_src_version = re.compile (r"(\S+)\s*\((.*)\)")
46 re_isadeb = re.compile (r"(.+?)_(.+?)_(.+)\.u?deb$")
48 orig_source_ext_re = r"orig(?:-[a-zA-Z0-9-]+)?\.tar\.(?:gz|bz2|xz)(?:\.asc)?"
49 file_source_ext_re = "(" + orig_source_ext_re + r"|(?:debian\.)?tar\.(?:gz|bz2|xz)|diff\.gz)"
50 re_source_ext = re.compile("(" + file_source_ext_re + r"|dsc)$")
51 re_issource = re.compile(r"(.+)_(.+?)\." + re_source_ext.pattern)
53 re_single_line_field = re.compile(r"^(\S*?)\s*:\s*(.*)")
54 re_multi_line_field = re.compile(r"^\s(.*)")
55 re_taint_free = re.compile(r"^[-+~/\.\w]+$")
57 re_parse_maintainer = re.compile(r"^\s*(\S.*\S)\s*\<([^\>]+)\>")
59 re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
60 re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$")
62 html_escaping = {'"':'"', '&':'&', '<':'<', '>':'>'}
63 re_html_escaping = re.compile('|'.join(map(re.escape, html_escaping.keys())))
65 # From clean_proposed_updates.py
66 re_isdeb = re.compile (r"^(.+)_(.+?)_(.+?).u?deb$")
68 # From examine_package.py
69 re_package = re.compile(r"^(.+?)_.*")
70 re_doc_directory = re.compile(r".*/doc/([^/]*).*")
72 re_contrib = re.compile('^contrib/')
73 re_nonfree = re.compile('^non\-free/')
75 re_localhost = re.compile("localhost\.localdomain")
76 re_version = re.compile('^(.*)\((.*)\)')
78 re_newlinespace = re.compile('\n')
79 re_spacestrip = re.compile('(\s)')
81 # From new_security_install.py
82 re_taint_free = re.compile(r"^['/;\-\+\.~\s\w]+$")
84 # From process_unchecked.py
85 re_changelog_versions = re.compile(r"^\w[-+0-9a-z.]+ \([^\(\) \t]+\)")
88 re_strip_source_version = re.compile (r'\s+.*$')
89 re_build_dep_arch = re.compile(r"\[[^]]+\]")
91 # From dak/transitions.py
92 re_broken_package = re.compile(r"[a-zA-Z]\w+\s+\-.*")
94 # From dak/add_user.py
95 re_gpg_fingerprint_colon = re.compile(r"^fpr:+(.*):$", re.MULTILINE);
96 # The next one is dirty
97 re_user_address = re.compile(r"^pub:.*<(.*)@.*>.*$", re.MULTILINE);
98 re_user_mails = re.compile(r"^(pub|uid):[^rdin].*<(.*@.*)>.*$", re.MULTILINE);
99 re_user_name = re.compile(r"^pub:.*:(.*)<.*$", re.MULTILINE);
100 re_re_mark = re.compile(r'^RE:')
102 re_parse_lintian = re.compile(r"^(?P<level>W|E|O): (?P<package>.*?): (?P<tag>[^ ]*) ?(?P<description>.*)$")
104 # in generate-releases
105 re_gensubrelease = re.compile (r".*/(binary-[0-9a-z-]+|source)$")
106 re_includeinrelease = re.compile (r"(Translation-[a-zA-Z_]+\.(?:bz2|xz)|Contents-[0-9a-z-]+.gz|Index|Packages(.gz|.bz2|.xz)?|Sources(.gz|.bz2|.xz)?|Components-[0-9a-z-]+.yml(.gz|.xz)|icons-[0-9x-]+.tar(.gz|.xz)|MD5SUMS|SHA256SUMS|Release)$")
108 # in generate_index_diffs
109 re_includeinpdiff = re.compile(r"(Translation-[a-zA-Z_]+\.(?:bz2|xz))")
112 ######################################################################
113 # Patterns matching filenames #
114 ######################################################################
116 # Match safe filenames
117 re_file_safe = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9_.~+-]*$')
119 # Match safe filenames, including slashes
120 re_file_safe_slash = re.compile(r'^[a-zA-Z0-9][/a-zA-Z0-9_.~+-]*$')
122 # Prefix of binary and source filenames
123 _re_file_prefix = r'^(?P<package>[a-z0-9][a-z0-9.+-]+)_(?P<version>[A-Za-z0-9.~+-]+?)'
125 # Match binary packages
126 # Groups: package, version, architecture, type
127 re_file_binary = re.compile(_re_file_prefix + r'_(?P<architecture>[a-z0-9-]+)\.(?P<type>u?deb)$')
129 # Match changes files
130 # Groups: package, version, suffix
131 re_file_changes = re.compile(_re_file_prefix + r'_(?P<suffix>[a-zA-Z0-9+-]+)\.changes$')
134 # Groups: package, version
135 re_file_dsc = re.compile(_re_file_prefix + r'\.dsc$')
137 # Match other source files
138 # Groups: package, version
139 re_file_source = re.compile(_re_file_prefix + r'\.' + file_source_ext_re)
141 # Match upstream tarball
142 # Groups: package, version
143 re_file_orig = re.compile(_re_file_prefix + r'\.' + orig_source_ext_re)
145 # Match buildinfo file
146 # Groups: package, version, suffix
147 re_file_buildinfo = re.compile(_re_file_prefix + r'_(?P<suffix>[a-zA-Z0-9+-]+)\.buildinfo$')
149 ######################################################################
150 # Patterns matching fields #
151 ######################################################################
154 re_field_package = re.compile(r'^[a-z0-9][a-z0-9.+-]+$')
157 # Groups: without-epoch
158 re_field_version = re.compile(r'^(?:[0-9]+:)?(?P<without_epoch>[A-Za-z0-9.:~+-]+)$')
160 # Extract upstream version
162 re_field_version_upstream = re.compile(r'^(?:[0-9]+:)?(?P<upstream>.*)-[^-]*$')
165 # Groups: package, version
166 re_field_source = re.compile(r'^(?P<package>[a-z0-9][a-z0-9.+-]+)(?:\s*\((?P<version>[A-Za-z0-9.:~+-]+)\))?$')