diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-04 13:05:33 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-05 11:52:50 +0000 |
commit | 93be2cdf492e1ec3d3c13f9c2ce82346be323da6 (patch) | |
tree | 2678b4740c7ff1c1b4a0fa32d9b5bdb74e6b1241 /meta/classes-global/package.bbclass | |
parent | ed07d52b476a22959cdd1c61d1c396345f996bbf (diff) | |
download | poky-93be2cdf492e1ec3d3c13f9c2ce82346be323da6.tar.gz |
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 <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-global/package.bbclass')
-rw-r--r-- | meta/classes-global/package.bbclass | 78 |
1 files changed, 1 insertions, 77 deletions
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 () { | |||
257 | d.appendVarFlag('do_package', 'deptask', " do_packagedata") | 257 | d.appendVarFlag('do_package', 'deptask', " do_packagedata") |
258 | } | 258 | } |
259 | 259 | ||
260 | # Get a list of files from file vars by searching files under current working directory | ||
261 | # The list contains symlinks, directories and normal files. | ||
262 | def files_from_filevars(filevars): | ||
263 | import os,glob | ||
264 | cpath = oe.cachedpath.CachedPath() | ||
265 | files = [] | ||
266 | for f in filevars: | ||
267 | if os.path.isabs(f): | ||
268 | f = '.' + f | ||
269 | if not f.startswith("./"): | ||
270 | f = './' + f | ||
271 | globbed = glob.glob(f) | ||
272 | if globbed: | ||
273 | if [ f ] != globbed: | ||
274 | files += globbed | ||
275 | continue | ||
276 | files.append(f) | ||
277 | |||
278 | symlink_paths = [] | ||
279 | for ind, f in enumerate(files): | ||
280 | # Handle directory symlinks. Truncate path to the lowest level symlink | ||
281 | parent = '' | ||
282 | for dirname in f.split('/')[:-1]: | ||
283 | parent = os.path.join(parent, dirname) | ||
284 | if dirname == '.': | ||
285 | continue | ||
286 | if cpath.islink(parent): | ||
287 | bb.warn("FILES contains file '%s' which resides under a " | ||
288 | "directory symlink. Please fix the recipe and use the " | ||
289 | "real path for the file." % f[1:]) | ||
290 | symlink_paths.append(f) | ||
291 | files[ind] = parent | ||
292 | f = parent | ||
293 | break | ||
294 | |||
295 | if not cpath.islink(f): | ||
296 | if cpath.isdir(f): | ||
297 | newfiles = [ os.path.join(f,x) for x in os.listdir(f) ] | ||
298 | if newfiles: | ||
299 | files += newfiles | ||
300 | |||
301 | return files, symlink_paths | ||
302 | |||
303 | # Called in package_<rpm,ipk,deb>.bbclass to get the correct list of configuration files | ||
304 | def get_conffiles(pkg, d): | ||
305 | pkgdest = d.getVar('PKGDEST') | ||
306 | root = os.path.join(pkgdest, pkg) | ||
307 | cwd = os.getcwd() | ||
308 | os.chdir(root) | ||
309 | |||
310 | conffiles = d.getVar('CONFFILES:%s' % pkg); | ||
311 | if conffiles == None: | ||
312 | conffiles = d.getVar('CONFFILES') | ||
313 | if conffiles == None: | ||
314 | conffiles = "" | ||
315 | conffiles = conffiles.split() | ||
316 | conf_orig_list = files_from_filevars(conffiles)[0] | ||
317 | |||
318 | # Remove links and directories from conf_orig_list to get conf_list which only contains normal files | ||
319 | conf_list = [] | ||
320 | for f in conf_orig_list: | ||
321 | if os.path.isdir(f): | ||
322 | continue | ||
323 | if os.path.islink(f): | ||
324 | continue | ||
325 | if not os.path.exists(f): | ||
326 | continue | ||
327 | conf_list.append(f) | ||
328 | |||
329 | # Remove the leading './' | ||
330 | for i in range(0, len(conf_list)): | ||
331 | conf_list[i] = conf_list[i][1:] | ||
332 | |||
333 | os.chdir(cwd) | ||
334 | return conf_list | ||
335 | |||
336 | def checkbuildpath(file, d): | 260 | def checkbuildpath(file, d): |
337 | tmpdir = d.getVar('TMPDIR') | 261 | tmpdir = d.getVar('TMPDIR') |
338 | with open(file) as f: | 262 | with open(file) as f: |
@@ -1209,7 +1133,7 @@ python populate_packages () { | |||
1209 | filesvar.replace("//", "/") | 1133 | filesvar.replace("//", "/") |
1210 | 1134 | ||
1211 | origfiles = filesvar.split() | 1135 | origfiles = filesvar.split() |
1212 | files, symlink_paths = files_from_filevars(origfiles) | 1136 | files, symlink_paths = oe.package.files_from_filevars(origfiles) |
1213 | 1137 | ||
1214 | if autodebug and pkg.endswith("-dbg"): | 1138 | if autodebug and pkg.endswith("-dbg"): |
1215 | files.extend(debug) | 1139 | files.extend(debug) |