mirror of
https://git.yoctoproject.org/poky
synced 2026-07-15 15:37:03 +00:00
meta: Fix Deprecated warnings from regexs
Fix handling of escape characters in regexs and hence fix python Deprecation warnings which will be problematic in python 3.8. Note that some show up as: """ meta/classes/package.bbclass:1293: DeprecationWarning: invalid escape sequence \. """ where the problem isn't on 1293 in package.bbclass but in some _prepend to a package.bbclass function in a different file like mesa.inc, often from do_package_split() calls. (From OE-Core rev: 4b1c0c7d5525fc4cea9e0f02ec54e92a6fbc6199) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -29,11 +29,11 @@ python debian_package_name_hook () {
|
||||
|
||||
pkgdest = d.getVar("PKGDEST")
|
||||
packages = d.getVar('PACKAGES')
|
||||
so_re = re.compile("lib.*\.so")
|
||||
so_re = re.compile(r"lib.*\.so")
|
||||
|
||||
def socrunch(s):
|
||||
s = s.lower().replace('_', '-')
|
||||
m = re.match("^(.*)(.)\.so\.(.*)$", s)
|
||||
m = re.match(r"^(.*)(.)\.so\.(.*)$", s)
|
||||
if m is None:
|
||||
return None
|
||||
if m.group(2) in '0123456789':
|
||||
@@ -79,7 +79,7 @@ python debian_package_name_hook () {
|
||||
try:
|
||||
cmd = [d.expand("${TARGET_PREFIX}objdump"), "-p", f]
|
||||
output = subprocess.check_output(cmd).decode("utf-8")
|
||||
for m in re.finditer("\s+SONAME\s+([^\s]+)", output):
|
||||
for m in re.finditer(r"\s+SONAME\s+([^\s]+)", output):
|
||||
if m.group(1) not in sonames:
|
||||
sonames.append(m.group(1))
|
||||
except subprocess.CalledProcessError:
|
||||
|
||||
@@ -49,7 +49,7 @@ python populate_packages_append () {
|
||||
for pkg in packages:
|
||||
schema_dir = '%s/%s/etc/gconf/schemas' % (pkgdest, pkg)
|
||||
schemas = []
|
||||
schema_re = re.compile(".*\.schemas$")
|
||||
schema_re = re.compile(r".*\.schemas$")
|
||||
if os.path.exists(schema_dir):
|
||||
for f in os.listdir(schema_dir):
|
||||
if schema_re.match(f):
|
||||
|
||||
@@ -133,7 +133,7 @@ python split_kernel_module_packages () {
|
||||
kernel_package_name = d.getVar("KERNEL_PACKAGE_NAME") or "kernel"
|
||||
kernel_version = d.getVar("KERNEL_VERSION")
|
||||
|
||||
module_regex = '^(.*)\.k?o$'
|
||||
module_regex = r'^(.*)\.k?o$'
|
||||
|
||||
module_pattern_prefix = d.getVar('KERNEL_MODULE_PACKAGE_PREFIX')
|
||||
module_pattern_suffix = d.getVar('KERNEL_MODULE_PACKAGE_SUFFIX')
|
||||
|
||||
@@ -578,7 +578,7 @@ pkg_postinst_${KERNEL_PACKAGE_NAME}-base () {
|
||||
PACKAGESPLITFUNCS_prepend = "split_kernel_packages "
|
||||
|
||||
python split_kernel_packages () {
|
||||
do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex='^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
|
||||
do_split_packages(d, root='${nonarch_base_libdir}/firmware', file_regex=r'^(.*)\.(bin|fw|cis|csp|dsp)$', output_pattern='${KERNEL_PACKAGE_NAME}-firmware-%s', description='Firmware for %s', recursive=True, extra_depends='')
|
||||
}
|
||||
|
||||
# Many scripts want to look in arch/$arch/boot for the bootable
|
||||
|
||||
@@ -113,8 +113,8 @@ python package_do_split_gconvs () {
|
||||
def calc_gconv_deps(fn, pkg, file_regex, output_pattern, group):
|
||||
deps = []
|
||||
f = open(fn, "rb")
|
||||
c_re = re.compile('^copy "(.*)"')
|
||||
i_re = re.compile('^include "(\w+)".*')
|
||||
c_re = re.compile(r'^copy "(.*)"')
|
||||
i_re = re.compile(r'^include "(\w+)".*')
|
||||
for l in f.readlines():
|
||||
l = l.decode("latin-1")
|
||||
m = c_re.match(l) or i_re.match(l)
|
||||
@@ -128,15 +128,15 @@ python package_do_split_gconvs () {
|
||||
if bpn != 'glibc':
|
||||
d.setVar('RPROVIDES_%s' % pkg, pkg.replace(bpn, 'glibc'))
|
||||
|
||||
do_split_packages(d, gconv_libdir, file_regex='^(.*)\.so$', output_pattern=bpn+'-gconv-%s', \
|
||||
do_split_packages(d, gconv_libdir, file_regex=r'^(.*)\.so$', output_pattern=bpn+'-gconv-%s', \
|
||||
description='gconv module for character set %s', hook=calc_gconv_deps, \
|
||||
extra_depends=bpn+'-gconv')
|
||||
|
||||
def calc_charmap_deps(fn, pkg, file_regex, output_pattern, group):
|
||||
deps = []
|
||||
f = open(fn, "rb")
|
||||
c_re = re.compile('^copy "(.*)"')
|
||||
i_re = re.compile('^include "(\w+)".*')
|
||||
c_re = re.compile(r'^copy "(.*)"')
|
||||
i_re = re.compile(r'^include "(\w+)".*')
|
||||
for l in f.readlines():
|
||||
l = l.decode("latin-1")
|
||||
m = c_re.match(l) or i_re.match(l)
|
||||
@@ -150,14 +150,14 @@ python package_do_split_gconvs () {
|
||||
if bpn != 'glibc':
|
||||
d.setVar('RPROVIDES_%s' % pkg, pkg.replace(bpn, 'glibc'))
|
||||
|
||||
do_split_packages(d, charmap_dir, file_regex='^(.*)\.gz$', output_pattern=bpn+'-charmap-%s', \
|
||||
do_split_packages(d, charmap_dir, file_regex=r'^(.*)\.gz$', output_pattern=bpn+'-charmap-%s', \
|
||||
description='character map for %s encoding', hook=calc_charmap_deps, extra_depends='')
|
||||
|
||||
def calc_locale_deps(fn, pkg, file_regex, output_pattern, group):
|
||||
deps = []
|
||||
f = open(fn, "rb")
|
||||
c_re = re.compile('^copy "(.*)"')
|
||||
i_re = re.compile('^include "(\w+)".*')
|
||||
c_re = re.compile(r'^copy "(.*)"')
|
||||
i_re = re.compile(r'^include "(\w+)".*')
|
||||
for l in f.readlines():
|
||||
l = l.decode("latin-1")
|
||||
m = c_re.match(l) or i_re.match(l)
|
||||
@@ -171,13 +171,13 @@ python package_do_split_gconvs () {
|
||||
if bpn != 'glibc':
|
||||
d.setVar('RPROVIDES_%s' % pkg, pkg.replace(bpn, 'glibc'))
|
||||
|
||||
do_split_packages(d, locales_dir, file_regex='(.*)', output_pattern=bpn+'-localedata-%s', \
|
||||
do_split_packages(d, locales_dir, file_regex=r'(.*)', output_pattern=bpn+'-localedata-%s', \
|
||||
description='locale definition for %s', hook=calc_locale_deps, extra_depends='')
|
||||
d.setVar('PACKAGES', d.getVar('PACKAGES', False) + ' ' + d.getVar('MLPREFIX', False) + bpn + '-gconv')
|
||||
|
||||
use_bin = d.getVar("GLIBC_INTERNAL_USE_BINARY_LOCALE")
|
||||
|
||||
dot_re = re.compile("(.*)\.(.*)")
|
||||
dot_re = re.compile(r"(.*)\.(.*)")
|
||||
|
||||
# Read in supported locales and associated encodings
|
||||
supported = {}
|
||||
@@ -290,7 +290,7 @@ python package_do_split_gconvs () {
|
||||
d.setVar('ALLOW_EMPTY_%s' % pkgname, '1')
|
||||
d.setVar('PACKAGES', '%s %s' % (pkgname, d.getVar('PACKAGES')))
|
||||
rprovides = ' %svirtual-locale-%s' % (mlprefix, legitimize_package_name(name))
|
||||
m = re.match("(.*)_(.*)", name)
|
||||
m = re.match(r"(.*)_(.*)", name)
|
||||
if m:
|
||||
rprovides += ' %svirtual-locale-%s' % (mlprefix, m.group(1))
|
||||
d.setVar('RPROVIDES_%s' % pkgname, rprovides)
|
||||
@@ -356,12 +356,12 @@ python package_do_split_gconvs () {
|
||||
if use_bin in ('compile', 'precompiled'):
|
||||
lcsplit = d.getVar('GLIBC_SPLIT_LC_PACKAGES')
|
||||
if lcsplit and int(lcsplit):
|
||||
do_split_packages(d, binary_locales_dir, file_regex='^(.*/LC_\w+)', \
|
||||
do_split_packages(d, binary_locales_dir, file_regex=r'^(.*/LC_\w+)', \
|
||||
output_pattern=bpn+'-binary-localedata-%s', \
|
||||
description='binary locale definition for %s', recursive=True,
|
||||
hook=metapkg_hook, extra_depends='', allow_dirs=True, match_path=True)
|
||||
else:
|
||||
do_split_packages(d, binary_locales_dir, file_regex='(.*)', \
|
||||
do_split_packages(d, binary_locales_dir, file_regex=r'(.*)', \
|
||||
output_pattern=bpn+'-binary-localedata-%s', \
|
||||
description='binary locale definition for %s', extra_depends='', allow_dirs=True)
|
||||
else:
|
||||
|
||||
@@ -75,7 +75,7 @@ def legitimize_package_name(s):
|
||||
return ('\\u%s' % cp).encode('latin-1').decode('unicode_escape')
|
||||
|
||||
# Handle unicode codepoints encoded as <U0123>, as in glibc locale files.
|
||||
s = re.sub('<U([0-9A-Fa-f]{1,4})>', fixutf, s)
|
||||
s = re.sub(r'<U([0-9A-Fa-f]{1,4})>', fixutf, s)
|
||||
|
||||
# Remaining package name validity fixes
|
||||
return s.lower().replace('_', '-').replace('@', '+').replace(',', '+').replace('/', '-')
|
||||
@@ -1590,8 +1590,8 @@ python package_do_shlibs() {
|
||||
bb.note("not generating shlibs")
|
||||
return
|
||||
|
||||
lib_re = re.compile("^.*\.so")
|
||||
libdir_re = re.compile(".*/%s$" % d.getVar('baselib'))
|
||||
lib_re = re.compile(r"^.*\.so")
|
||||
libdir_re = re.compile(r".*/%s$" % d.getVar('baselib'))
|
||||
|
||||
packages = d.getVar('PACKAGES')
|
||||
|
||||
@@ -1632,17 +1632,17 @@ python package_do_shlibs() {
|
||||
fd.close()
|
||||
rpath = tuple()
|
||||
for l in lines:
|
||||
m = re.match("\s+RPATH\s+([^\s]*)", l)
|
||||
m = re.match(r"\s+RPATH\s+([^\s]*)", l)
|
||||
if m:
|
||||
rpaths = m.group(1).replace("$ORIGIN", ldir).split(":")
|
||||
rpath = tuple(map(os.path.normpath, rpaths))
|
||||
for l in lines:
|
||||
m = re.match("\s+NEEDED\s+([^\s]*)", l)
|
||||
m = re.match(r"\s+NEEDED\s+([^\s]*)", l)
|
||||
if m:
|
||||
dep = m.group(1)
|
||||
if dep not in needed:
|
||||
needed.add((dep, file, rpath))
|
||||
m = re.match("\s+SONAME\s+([^\s]*)", l)
|
||||
m = re.match(r"\s+SONAME\s+([^\s]*)", l)
|
||||
if m:
|
||||
this_soname = m.group(1)
|
||||
prov = (this_soname, ldir, pkgver)
|
||||
@@ -1722,7 +1722,7 @@ python package_do_shlibs() {
|
||||
out, err = p.communicate()
|
||||
# process the output, grabbing all .dll names
|
||||
if p.returncode == 0:
|
||||
for m in re.finditer("DLL Name: (.*?\.dll)$", out.decode(), re.MULTILINE | re.IGNORECASE):
|
||||
for m in re.finditer(r"DLL Name: (.*?\.dll)$", out.decode(), re.MULTILINE | re.IGNORECASE):
|
||||
dllname = m.group(1)
|
||||
if dllname:
|
||||
needed[pkg].add((dllname, file, tuple()))
|
||||
@@ -1883,9 +1883,9 @@ python package_do_pkgconfig () {
|
||||
shlibs_dirs = d.getVar('SHLIBSDIRS').split()
|
||||
shlibswork_dir = d.getVar('SHLIBSWORKDIR')
|
||||
|
||||
pc_re = re.compile('(.*)\.pc$')
|
||||
var_re = re.compile('(.*)=(.*)')
|
||||
field_re = re.compile('(.*): (.*)')
|
||||
pc_re = re.compile(r'(.*)\.pc$')
|
||||
var_re = re.compile(r'(.*)=(.*)')
|
||||
field_re = re.compile(r'(.*): (.*)')
|
||||
|
||||
pkgconfig_provided = {}
|
||||
pkgconfig_needed = {}
|
||||
@@ -1933,7 +1933,7 @@ python package_do_pkgconfig () {
|
||||
if not os.path.exists(dir):
|
||||
continue
|
||||
for file in os.listdir(dir):
|
||||
m = re.match('^(.*)\.pclist$', file)
|
||||
m = re.match(r'^(.*)\.pclist$', file)
|
||||
if m:
|
||||
pkg = m.group(1)
|
||||
fd = open(os.path.join(dir, file))
|
||||
|
||||
Reference in New Issue
Block a user