wic: using indirect string to connect images
cover wic: using indirect string to connect images
Now is possible to pass a image OE name or a rootfs directory.
The command-line param and .wks remains the some.
wic create ... --rootfs-dir rootfs1=core-image-minimal \
--rootfs-dir rootfs2=core-image-minimal-dev
.wks:
part / --source rootfs --rootfs-dir="rootfs1" --ondisk sda --fstype=ext3 \
--label primary --align 1024
part /standby --source rootfs --rootfs-dir="rootfs2" \
--ondisk sda --fstype=ext3 --label secondary --align 1024João Henrique Ferreira de Freitas (3):
wic: Move find_bitbake_env_line() to oe.misc
wic: add find_artifact() to get a specific bitbake variable
wic: Extend indirect string connection to support image names and
rootfs
scripts/lib/image/engine.py | 17 ----------------- scripts/lib/mic/plugins/source/rootfs.py | 27 ++++++++++++++++++++++++--- scripts/lib/mic/utils/oe/misc.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 20 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/3 wic: Move find_bitbake_env_line() to oe.misc
Move find_bitbake_env_line() since they're going to need to be accessible from source plugins.
--- scripts/lib/image/engine.py | 17 ----------------- scripts/lib/mic/utils/oe/misc.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 17 deletions(-)
scripts/lib/image/engine.py +0 -17
@@ -60,23 +60,6 @@ def verify_build_env(): return True -def find_bitbake_env_lines(image_name): - """ - If image_name is empty, plugins might still be able to use the - environment, so set it regardless. - """ - if image_name: - bitbake_env_cmd = "bitbake -e %s" % image_name - else: - bitbake_env_cmd = "bitbake -e" - rc, bitbake_env_lines = exec_cmd(bitbake_env_cmd) - if rc != 0: - print "Couldn't get '%s' output." % bitbake_env_cmd - return None - - return bitbake_env_lines - - def find_artifacts(image_name): """ Gather the build artifacts for the current image (the image_name
scripts/lib/mic/utils/oe/misc.py +16 -0
@@ -126,6 +126,22 @@ def set_bitbake_env_lines(bitbake_env_lines): def get_bitbake_env_lines(): return __bitbake_env_lines +def find_bitbake_env_lines(image_name): + """ + If image_name is empty, plugins might still be able to use the + environment, so set it regardless. + """ + if image_name: + bitbake_env_cmd = "bitbake -e %s" % image_name + else: + bitbake_env_cmd = "bitbake -e" + rc, bitbake_env_lines = exec_cmd(bitbake_env_cmd) + if rc != 0: + print "Couldn't get '%s' output." % bitbake_env_cmd + return None + + return bitbake_env_lines + def get_line_val(line, key): """ Extract the value from the VAR="val" string
Signature · 1 line
1.8.3.2
PATCH 2/3 wic: add find_artifact() to get a specific bitbake variable
In reply to João Henrique Ferreira de FreitasThis helper is used by source plugins to get specific bitbake variable.
--- scripts/lib/mic/utils/oe/misc.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
scripts/lib/mic/utils/oe/misc.py +14 -0
@@ -142,6 +142,20 @@ def find_bitbake_env_lines(image_name): return bitbake_env_lines +def find_artifact(bitbake_env_lines, variable): + """ + Gather the build artifact for the current image (the image_name + e.g. core-image-minimal) for the current MACHINE set in local.conf + """ + retval = "" + + for line in bitbake_env_lines.split('\n'): + if (get_line_val(line, variable)): + retval = get_line_val(line, variable) + break + + return retval + def get_line_val(line, key): """ Extract the value from the VAR="val" string
Signature · 1 line
1.8.3.2
PATCH 3/3 wic: Extend indirect string connection to support image names and rootfs
In reply to João Henrique Ferreira de FreitasThe wic command-line param --rootfs-dir gets extended to support multiple directories and image names. Each '--rootfs-dir' could be connected using a special string. This special string is a image name which gets expanded by bitbake to get 'IMAGE_ROOTFS' or a rootfs-dir path pointing to rootfs directory. Like this:
wic create ... --rootfs-dir rootfs1=core-image-minimal \
--rootfs-dir rootfs2=core-image-minimal-dev.wks:
part / --source rootfs --rootfs-dir="rootfs1" --ondisk sda --fstype=ext3 \
--label primary --align 1024
part /standby --source rootfs --rootfs-dir="rootfs2" \
--ondisk sda --fstype=ext3 --label secondary --align 1024--- scripts/lib/mic/plugins/source/rootfs.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
scripts/lib/mic/plugins/source/rootfs.py +24 -3
@@ -43,6 +43,25 @@ from mic.imager.direct import DirectImageCreator class RootfsPlugin(SourcePlugin): name = 'rootfs' + @staticmethod + def __get_rootfs_dir(rootfs_dir): + 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") + 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" % \ + (rootfs_dir, image_rootfs_dir) + msger.error(msg) + + return image_rootfs_dir + @classmethod def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir, kernel_dir, krootfs_dir, native_sysroot):
@@ -59,13 +78,15 @@ class RootfsPlugin(SourcePlugin): else: if part.rootfs in krootfs_dir: rootfs_dir = krootfs_dir[part.rootfs] - elif os.path.isdir(part.rootfs): + elif part.rootfs: rootfs_dir = part.rootfs else: msg = "Couldn't find --rootfs-dir=%s connection" msg += " or it is not a valid path, exiting" msger.error(msg % part.rootfs) - part.set_rootfs(rootfs_dir) - part.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir, native_sysroot) + real_rootfs_dir = self.__get_rootfs_dir(rootfs_dir) + + part.set_rootfs(real_rootfs_dir) + part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot)
Signature · 1 line
1.8.3.2
Sorry for the delay on this.
Quoted 26 lines · João Henrique Ferreira de Freitas
Now is possible to pass a image OE name or a rootfs directory.
The command-line param and .wks remains the some.
wic create ... --rootfs-dir rootfs1=core-image-minimal \ --rootfs-dir rootfs2=core-image-minimal-dev .wks: part / --source rootfs --rootfs-dir="rootfs1" --ondisk sda --fstype=ext3 \ --label primary --align 1024 part /standby --source rootfs --rootfs-dir="rootfs2" \ --ondisk sda --fstype=ext3 --label secondary --align 1024João Henrique Ferreira de Freitas (3):
wic: Movefind_bitbake_env_line()to oe.misc
wic: addfind_artifact()to get a specific bitbake variable
wic: Extend indirect string connection to support image names and
rootfsscripts/lib/image/engine.py | 17 ----------------- scripts/lib/mic/plugins/source/rootfs.py | 27 ++++++++++++++++++++++++--- scripts/lib/mic/utils/oe/misc.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 20 deletions(-)