1
2
3 """
4 Central repository of regexes for dak
5
6 @contact: Debian FTP Master <ftpmaster@debian.org>
7 @copyright: 2001, 2002, 2003, 2004, 2005, 2006 James Troup <james@nocrew.org>
8 @copyright: 2009 Mark Hymers <mhy@debian.org>
9 @copyright: 2009, 2010 Joerg Jaspert <joerg@debian.org>
10 @license: GNU General Public License version 2 or later
11 """
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 import re
30
31
32 re_isanum = re.compile(r"^\d+$")
33
34
35 re_default_answer = re.compile(r"\[(.*)\]")
36
37 re_bin_only_nmu = re.compile(r"\+b\d+$")
38
39
40 re_comments = re.compile(r"\#.*")
41
42 re_whitespace_comment = re.compile(r"^\s*(#|$)")
43 re_no_epoch = re.compile(r"^\d+\:")
44 re_extract_src_version = re.compile(r"(\S+)\s*\((.*)\)")
45 re_isadeb = re.compile(r"(.+?)_(.+?)_(.+)\.u?deb$")
46
47 orig_source_ext_re = r"orig(?:-[a-zA-Z0-9-]+)?\.tar\.(?:gz|bz2|xz)(?:\.asc)?"
48 file_source_ext_re = "(" + orig_source_ext_re + r"|(?:debian\.)?tar\.(?:gz|bz2|xz)|diff\.gz)"
49 re_source_ext = re.compile("(" + file_source_ext_re + r"|dsc)$")
50 re_issource = re.compile(r"(.+)_(.+?)\." + re_source_ext.pattern)
51
52 re_single_line_field = re.compile(r"^(\S*?)\s*:\s*(.*)")
53 re_multi_line_field = re.compile(r"^\s(.*)")
54 re_taint_free = re.compile(r"^[-+~/\.\w]+$")
55
56 re_parse_maintainer = re.compile(r"^\s*(\S.*\S)\s*\<([^\>]+)\>")
57
58 re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
59 re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$")
60
61
62 re_isdeb = re.compile(r"^(.+)_(.+?)_(.+?).u?deb$")
63
64
65 re_package = re.compile(r"^(.+?)_.*")
66 re_doc_directory = re.compile(r".*/doc/([^/]*).*")
67
68 re_contrib = re.compile('^contrib/')
69 re_nonfree = re.compile('^(?:non-free-firmware|non-free)/')
70
71 re_localhost = re.compile(r"localhost\.localdomain")
72 re_version = re.compile(r'^(.*)\((.*)\)')
73
74 re_newlinespace = re.compile('\n')
75 re_spacestrip = re.compile(r'(\s)')
76
77
78 re_taint_free = re.compile(r"^['/;\-\+\.~\s\w]+$")
79
80
81 re_changelog_versions = re.compile(r"^\w[-+0-9a-z.]+ \([^\(\) \t]+\)")
82
83
84 re_strip_source_version = re.compile(r'\s+.*$')
85 re_build_dep_arch = re.compile(r"\[[^]]+\]")
86
87
88 re_broken_package = re.compile(r"[a-zA-Z]\w+\s+\-.*")
89
90
91 re_gpg_fingerprint_colon = re.compile(r"^fpr:+(.*):$", re.MULTILINE)
92
93 re_user_address = re.compile(r"^pub:.*<(.*)@.*>.*$", re.MULTILINE)
94 re_user_mails = re.compile(r"^(pub|uid):[^rdin].*<(.*@.*)>.*$", re.MULTILINE)
95 re_user_name = re.compile(r"^pub:.*:(.*)<.*$", re.MULTILINE)
96 re_re_mark = re.compile(r'^RE:')
97
98 re_parse_lintian = re.compile(r"^(?P<level>W|E|O): (?P<package>.*?): (?P<tag>[^ ]*) ?(?P<description>.*)$")
99
100
101 re_gensubrelease = re.compile(r".*/(binary-[0-9a-z-]+|source)$")
102 re_includeinrelease_byhash = re.compile(r"(Translation-[a-zA-Z_]+\.(?:bz2|xz|zst)|Contents-[0-9a-z-]+.gz|Index|Packages(.gz|.bz2|.xz|.zst)?|Sources(.gz|.bz2|.xz|.zst)?|Components-[0-9a-z-]+.yml(.gz|.xz)|icons-[0-9x-]+.tar(.gz|.xz)|Release)$")
103 re_includeinrelease_plain = re.compile(r"(MD5SUMS|SHA256SUMS)$")
104
105
106 re_includeinpdiff = re.compile(r"(Translation-[a-zA-Z_]+\.(?:bz2|xz|zst))")
107
108
109
110
111
112
113
114 re_file_safe = re.compile(r'^[a-zA-Z0-9][a-zA-Z0-9_.~+-]*$')
115
116
117 re_file_safe_slash = re.compile(r'^[a-zA-Z0-9][/a-zA-Z0-9_.~+-]*$')
118
119
120 _re_file_prefix = r'^(?P<package>[a-z0-9][a-z0-9.+-]+)_(?P<version>[A-Za-z0-9.~+-]+?)'
121
122
123
124 re_file_binary = re.compile(_re_file_prefix + r'_(?P<architecture>[a-z0-9-]+)\.(?P<type>u?deb)$')
125
126
127
128 re_file_changes = re.compile(_re_file_prefix + r'_(?P<suffix>[a-zA-Z0-9+-]+)\.changes$')
129
130
131
132 re_file_dsc = re.compile(_re_file_prefix + r'\.dsc$')
133
134
135
136 re_file_source = re.compile(_re_file_prefix + r'\.' + file_source_ext_re)
137
138
139
140 re_file_orig = re.compile(_re_file_prefix + r'\.' + orig_source_ext_re)
141
142
143
144 re_file_buildinfo = re.compile(_re_file_prefix + r'_(?P<suffix>[a-zA-Z0-9+-]+)\.buildinfo$')
145
146
147
148
149
150
151 re_field_package = re.compile(r'^[a-z0-9][a-z0-9.+-]+$')
152
153
154
155 re_field_version = re.compile(r'^(?:[0-9]+:)?(?P<without_epoch>[A-Za-z0-9.:~+-]+)$')
156
157
158
159 re_field_version_upstream = re.compile(r'^(?:[0-9]+:)?(?P<upstream>.*)-[^-]*$')
160
161
162
163 re_field_source = re.compile(r'^(?P<package>[a-z0-9][a-z0-9.+-]+)(?:\s*\((?P<version>[A-Za-z0-9.:~+-]+)\))?$')
164