From 3abe23bd217315246ec2d98dc9c390b85cfe6a92 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Fri, 26 Jun 2015 21:27:31 +0300 Subject: wic: Refactor getting bitbake variables Wic gets bitbake variables by parsing output of 'bitbake -e' command. This implementation improves this procedure as it runs 'bitbake -e' only when API is called and does it only once, i.e. in a "lazy" way. As parsing results are cached 'bitbake -e' is run only once and results are parsed only once per requested set of variables. get_bitbake_var became the only API call. It replaces find_artifacts, find_artifact, find_bitbake_env_lines, get_bitbake_env_lines, set_bitbake_env_lines and get_line_val calls making API much more clear. Signed-off-by: Ed Bartosh --- scripts/lib/wic/plugins/source/rootfs.py | 9 ++------- scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py | 6 +----- 2 files changed, 3 insertions(+), 12 deletions(-) (limited to 'scripts/lib/wic/plugins/source') diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py index 12fbf67a6e..a90712b247 100644 --- a/scripts/lib/wic/plugins/source/rootfs.py +++ b/scripts/lib/wic/plugins/source/rootfs.py @@ -29,7 +29,7 @@ import os from wic import msger from wic.pluginbase import SourcePlugin -from wic.utils.oe.misc import find_bitbake_env_lines, find_artifact +from wic.utils.oe.misc import get_bitbake_var class RootfsPlugin(SourcePlugin): """ @@ -43,12 +43,7 @@ class RootfsPlugin(SourcePlugin): if os.path.isdir(rootfs_dir): return rootfs_dir - bitbake_env_lines = find_bitbake_env_lines(rootfs_dir) - if not bitbake_env_lines: - msg = "Couldn't get bitbake environment, exiting." - msger.error(msg) - - image_rootfs_dir = find_artifact(bitbake_env_lines, "IMAGE_ROOTFS") + image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) if not os.path.isdir(image_rootfs_dir): msg = "No valid artifact IMAGE_ROOTFS from image named" msg += " %s has been found at %s, exiting.\n" % \ diff --git a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py index 533eaa7bd1..76e7b033fb 100644 --- a/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py +++ b/scripts/lib/wic/plugins/source/rootfs_pcbios_ext.py @@ -59,11 +59,7 @@ class RootfsPlugin(SourcePlugin): if os.path.isdir(rootfs_dir): return rootfs_dir - bitbake_env_lines = misc.find_bitbake_env_lines(rootfs_dir) - if not bitbake_env_lines: - msger.error("Couldn't get bitbake environment, exiting.") - - image_rootfs_dir = misc.find_artifact(bitbake_env_lines, "IMAGE_ROOTFS") + image_rootfs_dir = misc.get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) if not os.path.isdir(image_rootfs_dir): msg = "No valid artifact IMAGE_ROOTFS from image named" msg += " %s has been found at %s, exiting.\n" % \ -- cgit v1.2.3