1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-30 12:29:55 +00:00

classes/package: handle filenames containing wildcards

It is uncommon, but it is possible for upstream sources to contain files
that have wildcard characters in their names (Webmin is an example).
Because we were running glob.glob() on every entry in the list of
entries in FILES and then adding the result to the files list to be
processed, the process would loop infinitely if files whose names
contained wildcard characters were present. Fix this by avoiding
re-processing the output of glob.glob() with itself, and also "escape"
wildcard characters in FILES entries added automatically from
do_split_packages().

Fixes [YOCTO #1676].

(From OE-Core rev: 1aa3fbb547b0e21455f0dcc9b72ded08dc0efd67)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton
2013-10-03 17:02:48 +01:00
committed by Richard Purdie
parent 029b0fef50
commit 567754acb8
+19 -9
View File
@@ -183,8 +183,13 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
else: else:
packages.append(pkg) packages.append(pkg)
oldfiles = d.getVar('FILES_' + pkg, True) oldfiles = d.getVar('FILES_' + pkg, True)
newfile = os.path.join(root, o)
# These names will be passed through glob() so if the filename actually
# contains * or ? (rare, but possible) we need to handle that specially
newfile = newfile.replace('*', '[*]')
newfile = newfile.replace('?', '[?]')
if not oldfiles: if not oldfiles:
the_files = [os.path.join(root, o)] the_files = [newfile]
if aux_files_pattern: if aux_files_pattern:
if type(aux_files_pattern) is list: if type(aux_files_pattern) is list:
for fp in aux_files_pattern: for fp in aux_files_pattern:
@@ -206,7 +211,7 @@ def do_split_packages(d, root, file_regex, output_pattern, description, postinst
if postrm: if postrm:
d.setVar('pkg_postrm_' + pkg, postrm) d.setVar('pkg_postrm_' + pkg, postrm)
else: else:
d.setVar('FILES_' + pkg, oldfiles + " " + os.path.join(root, o)) d.setVar('FILES_' + pkg, oldfiles + " " + newfile)
if callable(hook): if callable(hook):
hook(f, pkg, file_regex, output_pattern, m.group(1)) hook(f, pkg, file_regex, output_pattern, m.group(1))
@@ -965,23 +970,28 @@ python populate_packages () {
msg = "FILES variable for package %s contains '//' which is invalid. Attempting to fix this but you should correct the metadata.\n" % pkg msg = "FILES variable for package %s contains '//' which is invalid. Attempting to fix this but you should correct the metadata.\n" % pkg
package_qa_handle_error("files-invalid", msg, d) package_qa_handle_error("files-invalid", msg, d)
filesvar.replace("//", "/") filesvar.replace("//", "/")
files = filesvar.split()
for file in files: origfiles = filesvar.split()
files = []
for file in origfiles:
if os.path.isabs(file): if os.path.isabs(file):
file = '.' + file file = '.' + file
if not file.startswith("./"): if not file.startswith("./"):
file = './' + file file = './' + file
globbed = glob.glob(file)
if globbed:
if [ file ] != globbed:
files += globbed
continue
files.append(file)
for file in files:
if not cpath.islink(file): if not cpath.islink(file):
if cpath.isdir(file): if cpath.isdir(file):
newfiles = [ os.path.join(file,x) for x in os.listdir(file) ] newfiles = [ os.path.join(file,x) for x in os.listdir(file) ]
if newfiles: if newfiles:
files += newfiles files += newfiles
continue continue
globbed = glob.glob(file)
if globbed:
if [ file ] != globbed:
files += globbed
continue
if (not cpath.islink(file)) and (not cpath.exists(file)): if (not cpath.islink(file)) and (not cpath.exists(file)):
continue continue
if file in seen: if file in seen: