From 93be2cdf492e1ec3d3c13f9c2ce82346be323da6 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 4 Jan 2023 13:05:33 +0000 Subject: package: Move get_conffiles/files_from_filevars functions to lib To avoid reparsing the bbclass code all the time, move the functions to the python function library code which is more efficient. (From OE-Core rev: 424e65627c018b3119050f515b0c7cfb43be5573) Signed-off-by: Richard Purdie --- meta/classes-global/package.bbclass | 78 +------------------------------------ 1 file changed, 1 insertion(+), 77 deletions(-) (limited to 'meta/classes-global/package.bbclass') diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass index 29f0c80abd..a31224f243 100644 --- a/meta/classes-global/package.bbclass +++ b/meta/classes-global/package.bbclass @@ -257,82 +257,6 @@ python () { d.appendVarFlag('do_package', 'deptask', " do_packagedata") } -# Get a list of files from file vars by searching files under current working directory -# The list contains symlinks, directories and normal files. -def files_from_filevars(filevars): - import os,glob - cpath = oe.cachedpath.CachedPath() - files = [] - for f in filevars: - if os.path.isabs(f): - f = '.' + f - if not f.startswith("./"): - f = './' + f - globbed = glob.glob(f) - if globbed: - if [ f ] != globbed: - files += globbed - continue - files.append(f) - - symlink_paths = [] - for ind, f in enumerate(files): - # Handle directory symlinks. Truncate path to the lowest level symlink - parent = '' - for dirname in f.split('/')[:-1]: - parent = os.path.join(parent, dirname) - if dirname == '.': - continue - if cpath.islink(parent): - bb.warn("FILES contains file '%s' which resides under a " - "directory symlink. Please fix the recipe and use the " - "real path for the file." % f[1:]) - symlink_paths.append(f) - files[ind] = parent - f = parent - break - - if not cpath.islink(f): - if cpath.isdir(f): - newfiles = [ os.path.join(f,x) for x in os.listdir(f) ] - if newfiles: - files += newfiles - - return files, symlink_paths - -# Called in package_.bbclass to get the correct list of configuration files -def get_conffiles(pkg, d): - pkgdest = d.getVar('PKGDEST') - root = os.path.join(pkgdest, pkg) - cwd = os.getcwd() - os.chdir(root) - - conffiles = d.getVar('CONFFILES:%s' % pkg); - if conffiles == None: - conffiles = d.getVar('CONFFILES') - if conffiles == None: - conffiles = "" - conffiles = conffiles.split() - conf_orig_list = files_from_filevars(conffiles)[0] - - # Remove links and directories from conf_orig_list to get conf_list which only contains normal files - conf_list = [] - for f in conf_orig_list: - if os.path.isdir(f): - continue - if os.path.islink(f): - continue - if not os.path.exists(f): - continue - conf_list.append(f) - - # Remove the leading './' - for i in range(0, len(conf_list)): - conf_list[i] = conf_list[i][1:] - - os.chdir(cwd) - return conf_list - def checkbuildpath(file, d): tmpdir = d.getVar('TMPDIR') with open(file) as f: @@ -1209,7 +1133,7 @@ python populate_packages () { filesvar.replace("//", "/") origfiles = filesvar.split() - files, symlink_paths = files_from_filevars(origfiles) + files, symlink_paths = oe.package.files_from_filevars(origfiles) if autodebug and pkg.endswith("-dbg"): files.extend(debug) -- cgit v1.2.3-54-g00ecf