package/scripts: Fix FILES_INFO handling

There is a long standing bug where FILES_INFO isn't written into pkgdata
with a package suffix. This means if the files are read into the datastore
as intended, the last one "wins".

Fix this to work as intended. Most of the call sites using the data need
to be updated to handle this and the overrides change correctly.

Also fix some other problematic references noticed along the way.

(From OE-Core rev: a1190903e0a61a12c9854c96af918ae8d12c6327)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2021-08-16 16:01:06 +01:00
parent 12e1f9815d
commit dd6b55d70c
8 changed files with 16 additions and 15 deletions

View File

@ -808,11 +808,11 @@ def package_qa_check_rdepends(pkg, pkgdest, skip, taskdeps, packages, d):
# For Saving the FILERPROVIDES, RPROVIDES and FILES_INFO # For Saving the FILERPROVIDES, RPROVIDES and FILES_INFO
rdep_data = oe.packagedata.read_subpkgdata(rdep, d) rdep_data = oe.packagedata.read_subpkgdata(rdep, d)
for key in rdep_data: for key in rdep_data:
if key.startswith("FILERPROVIDES_") or key.startswith("RPROVIDES:"): if key.startswith("FILERPROVIDES:") or key.startswith("RPROVIDES:"):
for subkey in bb.utils.explode_deps(rdep_data[key]): for subkey in bb.utils.explode_deps(rdep_data[key]):
filerdepends.pop(subkey,None) filerdepends.pop(subkey,None)
# Add the files list to the rprovides # Add the files list to the rprovides
if key == "FILES_INFO": if key.startswith("FILES_INFO:"):
# Use eval() to make it as a dict # Use eval() to make it as a dict
for subkey in eval(rdep_data[key]): for subkey in eval(rdep_data[key]):
filerdepends.pop(subkey,None) filerdepends.pop(subkey,None)

View File

@ -1652,7 +1652,7 @@ fi
if fstat.st_ino not in seen: if fstat.st_ino not in seen:
seen.add(fstat.st_ino) seen.add(fstat.st_ino)
total_size += fstat.st_size total_size += fstat.st_size
d.setVar('FILES_INFO', json.dumps(files, sort_keys=True)) d.setVar('FILES_INFO:' + pkg , json.dumps(files, sort_keys=True))
process_postinst_on_target(pkg, d.getVar("MLPREFIX")) process_postinst_on_target(pkg, d.getVar("MLPREFIX"))
add_set_e_to_scriptlets(pkg) add_set_e_to_scriptlets(pkg)

View File

@ -106,7 +106,7 @@ def _toaster_load_pkgdatafile(dirpath, filepath):
pkgdata['OPKGN'] = m.group(1) pkgdata['OPKGN'] = m.group(1)
kn = "_".join([x for x in kn.split("_") if x.isupper()]) kn = "_".join([x for x in kn.split("_") if x.isupper()])
pkgdata[kn] = kv.strip() pkgdata[kn] = kv.strip()
if kn == 'FILES_INFO': if kn.startswith('FILES_INFO'):
pkgdata[kn] = json.loads(kv) pkgdata[kn] = json.loads(kv)
except ValueError: except ValueError:

View File

@ -62,10 +62,11 @@ def search(args, config, basepath, workspace):
with open(os.path.join(pkgdata_dir, 'runtime', pkg), 'r') as f: with open(os.path.join(pkgdata_dir, 'runtime', pkg), 'r') as f:
for line in f: for line in f:
if ': ' in line: if ': ' in line:
splitline = line.split(':', 1) splitline = line.split(': ', 1)
key = splitline[0] key = splitline[0]
value = splitline[1].strip() value = splitline[1].strip()
if key in ['PKG:%s' % pkg, 'DESCRIPTION', 'FILES_INFO'] or key.startswith('FILERPROVIDES_'): key = key.replace(":" + pkg, "")
if key in ['PKG', 'DESCRIPTION', 'FILES_INFO', 'FILERPROVIDES']:
if keyword_rc.search(value): if keyword_rc.search(value):
match = True match = True
break break

View File

@ -72,15 +72,15 @@ def find_target_file(targetpath, d, pkglist=None):
# This does assume that PN comes before other values, but that's a fairly safe assumption # This does assume that PN comes before other values, but that's a fairly safe assumption
for line in f: for line in f:
if line.startswith('PN:'): if line.startswith('PN:'):
pn = line.split(':', 1)[1].strip() pn = line.split(': ', 1)[1].strip()
elif line.startswith('FILES_INFO:'): elif line.startswith('FILES_INFO'):
val = line.split(':', 1)[1].strip() val = line.split(': ', 1)[1].strip()
dictval = json.loads(val) dictval = json.loads(val)
for fullpth in dictval.keys(): for fullpth in dictval.keys():
if fnmatch.fnmatchcase(fullpth, targetpath): if fnmatch.fnmatchcase(fullpth, targetpath):
recipes[targetpath].append(pn) recipes[targetpath].append(pn)
elif line.startswith('pkg_preinst:') or line.startswith('pkg_postinst:'): elif line.startswith('pkg_preinst:') or line.startswith('pkg_postinst:'):
scriptval = line.split(':', 1)[1].strip().encode('utf-8').decode('unicode_escape') scriptval = line.split(': ', 1)[1].strip().encode('utf-8').decode('unicode_escape')
if 'update-alternatives --install %s ' % targetpath in scriptval: if 'update-alternatives --install %s ' % targetpath in scriptval:
recipes[targetpath].append('?%s' % pn) recipes[targetpath].append('?%s' % pn)
elif targetpath_re.search(scriptval): elif targetpath_re.search(scriptval):

View File

@ -115,8 +115,8 @@ class RecipeHandler(object):
for line in f: for line in f:
if line.startswith('PN:'): if line.startswith('PN:'):
pn = line.split(':', 1)[-1].strip() pn = line.split(':', 1)[-1].strip()
elif line.startswith('FILES_INFO:'): elif line.startswith('FILES_INFO:%s:' % pkg):
val = line.split(':', 1)[1].strip() val = line.split(': ', 1)[1].strip()
dictval = json.loads(val) dictval = json.loads(val)
for fullpth in sorted(dictval): for fullpth in sorted(dictval):
if fullpth.startswith(includedir) and fullpth.endswith('.h'): if fullpth.startswith(includedir) and fullpth.endswith('.h'):

View File

@ -545,7 +545,7 @@ class PythonRecipeHandler(RecipeHandler):
with open(pkgdatafile, 'r') as f: with open(pkgdatafile, 'r') as f:
for line in f.readlines(): for line in f.readlines():
field, value = line.split(': ', 1) field, value = line.split(': ', 1)
if field == 'FILES_INFO': if field.startswith('FILES_INFO'):
files_info = ast.literal_eval(value) files_info = ast.literal_eval(value)
break break
else: else:

View File

@ -431,7 +431,7 @@ def list_pkg_files(args):
for line in f: for line in f:
if line.startswith('FILES_INFO:'): if line.startswith('FILES_INFO:'):
found = True found = True
val = line.split(':', 1)[1].strip() val = line.split(': ', 1)[1].strip()
dictval = json.loads(val) dictval = json.loads(val)
if long: if long:
width = max(map(len, dictval), default=0) width = max(map(len, dictval), default=0)
@ -500,7 +500,7 @@ def find_path(args):
with open(os.path.join(root,fn)) as f: with open(os.path.join(root,fn)) as f:
for line in f: for line in f:
if line.startswith('FILES_INFO:'): if line.startswith('FILES_INFO:'):
val = line.split(':', 1)[1].strip() val = line.split(': ', 1)[1].strip()
dictval = json.loads(val) dictval = json.loads(val)
for fullpth in dictval.keys(): for fullpth in dictval.keys():
if fnmatch.fnmatchcase(fullpth, args.targetpath): if fnmatch.fnmatchcase(fullpth, args.targetpath):