diff options
Diffstat (limited to 'scripts/lib')
-rwxr-xr-x | scripts/lib/devtool/ide_sdk.py | 15 | ||||
-rw-r--r-- | scripts/lib/wic/engine.py | 63 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/extra_partition.py | 20 |
3 files changed, 68 insertions, 30 deletions
diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py index 931408fa74..d9b54f7991 100755 --- a/scripts/lib/devtool/ide_sdk.py +++ b/scripts/lib/devtool/ide_sdk.py | |||
@@ -286,6 +286,7 @@ class RecipeModified: | |||
286 | self.b = None | 286 | self.b = None |
287 | self.base_libdir = None | 287 | self.base_libdir = None |
288 | self.bblayers = None | 288 | self.bblayers = None |
289 | self.bitbakepath = None | ||
289 | self.bpn = None | 290 | self.bpn = None |
290 | self.d = None | 291 | self.d = None |
291 | self.debug_build = None | 292 | self.debug_build = None |
@@ -297,6 +298,7 @@ class RecipeModified: | |||
297 | self.package_debug_split_style = None | 298 | self.package_debug_split_style = None |
298 | self.path = None | 299 | self.path = None |
299 | self.pn = None | 300 | self.pn = None |
301 | self.recipe_id = None | ||
300 | self.recipe_sysroot = None | 302 | self.recipe_sysroot = None |
301 | self.recipe_sysroot_native = None | 303 | self.recipe_sysroot_native = None |
302 | self.staging_incdir = None | 304 | self.staging_incdir = None |
@@ -305,7 +307,6 @@ class RecipeModified: | |||
305 | self.target_dbgsrc_dir = None | 307 | self.target_dbgsrc_dir = None |
306 | self.topdir = None | 308 | self.topdir = None |
307 | self.workdir = None | 309 | self.workdir = None |
308 | self.recipe_id = None | ||
309 | # replicate bitbake build environment | 310 | # replicate bitbake build environment |
310 | self.exported_vars = None | 311 | self.exported_vars = None |
311 | self.cmd_compile = None | 312 | self.cmd_compile = None |
@@ -346,6 +347,7 @@ class RecipeModified: | |||
346 | self.b = recipe_d.getVar('B') | 347 | self.b = recipe_d.getVar('B') |
347 | self.base_libdir = recipe_d.getVar('base_libdir') | 348 | self.base_libdir = recipe_d.getVar('base_libdir') |
348 | self.bblayers = recipe_d.getVar('BBLAYERS').split() | 349 | self.bblayers = recipe_d.getVar('BBLAYERS').split() |
350 | self.bitbakepath = recipe_d.getVar('BITBAKEPATH') | ||
349 | self.bpn = recipe_d.getVar('BPN') | 351 | self.bpn = recipe_d.getVar('BPN') |
350 | self.cxx = recipe_d.getVar('CXX') | 352 | self.cxx = recipe_d.getVar('CXX') |
351 | self.d = recipe_d.getVar('D') | 353 | self.d = recipe_d.getVar('D') |
@@ -710,14 +712,15 @@ class RecipeModified: | |||
710 | 712 | ||
711 | def gen_install_deploy_script(self, args): | 713 | def gen_install_deploy_script(self, args): |
712 | """Generate a script which does install and deploy""" | 714 | """Generate a script which does install and deploy""" |
713 | cmd_lines = ['#!/bin/bash'] | 715 | cmd_lines = ['#!/bin/sh'] |
714 | 716 | ||
715 | # . oe-init-build-env $BUILDDIR | 717 | # . oe-init-build-env $BUILDDIR $BITBAKEDIR |
716 | # Note: Sourcing scripts with arguments requires bash | 718 | # Using 'set' to pass the build directory to oe-init-build-env in sh syntax |
717 | cmd_lines.append('cd "%s" || { echo "cd %s failed"; exit 1; }' % ( | 719 | cmd_lines.append('cd "%s" || { echo "cd %s failed"; exit 1; }' % ( |
718 | self.oe_init_dir, self.oe_init_dir)) | 720 | self.oe_init_dir, self.oe_init_dir)) |
719 | cmd_lines.append('. "%s" "%s" || { echo ". %s %s failed"; exit 1; }' % ( | 721 | cmd_lines.append('set %s %s' % (self.topdir, self.bitbakepath.rstrip('/bin'))) |
720 | self.oe_init_build_env, self.topdir, self.oe_init_build_env, self.topdir)) | 722 | cmd_lines.append('. "%s" || { echo ". %s %s failed"; exit 1; }' % ( |
723 | self.oe_init_build_env, self.oe_init_build_env, self.topdir)) | ||
721 | 724 | ||
722 | # bitbake -c install | 725 | # bitbake -c install |
723 | cmd_lines.append( | 726 | cmd_lines.append( |
diff --git a/scripts/lib/wic/engine.py b/scripts/lib/wic/engine.py index b9e60cbe4e..9d596be3a7 100644 --- a/scripts/lib/wic/engine.py +++ b/scripts/lib/wic/engine.py | |||
@@ -345,29 +345,64 @@ class Disk: | |||
345 | path)) | 345 | path)) |
346 | 346 | ||
347 | def copy(self, src, dest): | 347 | def copy(self, src, dest): |
348 | """Copy partition image into wic image.""" | 348 | """Copy files or directories to/from the vfat or ext* partition.""" |
349 | pnum = dest.part if isinstance(src, str) else src.part | 349 | pnum = dest.part if isinstance(src, str) else src.part |
350 | partimg = self._get_part_image(pnum) | ||
350 | 351 | ||
351 | if self.partitions[pnum].fstype.startswith('ext'): | 352 | if self.partitions[pnum].fstype.startswith('ext'): |
352 | if isinstance(src, str): | 353 | if isinstance(src, str): # host to image case |
353 | cmd = "printf 'cd {}\nwrite {} {}\n' | {} -w {}".\ | 354 | if os.path.isdir(src): |
354 | format(os.path.dirname(dest.path), src, os.path.basename(src), | 355 | base = os.path.abspath(src) |
355 | self.debugfs, self._get_part_image(pnum)) | 356 | base_parent = os.path.dirname(base) |
356 | else: # copy from wic | 357 | cmds = [] |
357 | # run both dump and rdump to support both files and directory | 358 | made = set() |
359 | |||
360 | for root, dirs, files in os.walk(base): | ||
361 | for fname in files: | ||
362 | host_file = os.path.join(root, fname) | ||
363 | rel = os.path.relpath(host_file, base_parent) | ||
364 | dest_file = os.path.join(dest.path, rel) | ||
365 | dest_dir = os.path.dirname(dest_file) | ||
366 | |||
367 | # create dir structure (mkdir -p) | ||
368 | parts = dest_dir.strip('/').split('/') | ||
369 | cur = '' | ||
370 | for p in parts: | ||
371 | cur = cur + '/' + p | ||
372 | if cur not in made: | ||
373 | cmds.append(f'mkdir "{cur}"') | ||
374 | made.add(cur) | ||
375 | |||
376 | cmds.append(f'write "{host_file}" "{dest_file}"') | ||
377 | |||
378 | # write script to a temp file | ||
379 | with tempfile.NamedTemporaryFile(mode='w', delete=False, | ||
380 | prefix='wic-debugfs-') as tf: | ||
381 | for line in cmds: | ||
382 | tf.write(line + '\n') | ||
383 | scriptname = tf.name | ||
384 | |||
385 | cmd = f"{self.debugfs} -w -f {scriptname} {partimg}" | ||
386 | |||
387 | else: # single file | ||
388 | cmd = "printf 'cd {}\nwrite {} {}\n' | {} -w {}".\ | ||
389 | format(os.path.dirname(dest.path), src, | ||
390 | os.path.basename(src), self.debugfs, partimg) | ||
391 | |||
392 | else: # image to host case | ||
358 | cmd = "printf 'cd {}\ndump /{} {}\nrdump /{} {}\n' | {} {}".\ | 393 | cmd = "printf 'cd {}\ndump /{} {}\nrdump /{} {}\n' | {} {}".\ |
359 | format(os.path.dirname(src.path), src.path, | 394 | format(os.path.dirname(src.path), src.path, |
360 | dest, src.path, dest, self.debugfs, | 395 | dest, src.path, dest, self.debugfs, partimg) |
361 | self._get_part_image(pnum)) | 396 | |
362 | else: # fat | 397 | else: # fat |
363 | if isinstance(src, str): | 398 | if isinstance(src, str): |
364 | cmd = "{} -i {} -snop {} ::{}".format(self.mcopy, | 399 | cmd = "{} -i {} -snop {} ::{}".format(self.mcopy, |
365 | self._get_part_image(pnum), | 400 | partimg, |
366 | src, dest.path) | 401 | src, dest.path) |
367 | else: | 402 | else: |
368 | cmd = "{} -i {} -snop ::{} {}".format(self.mcopy, | 403 | cmd = "{} -i {} -snop ::{} {}".format(self.mcopy, |
369 | self._get_part_image(pnum), | 404 | partimg, |
370 | src.path, dest) | 405 | src.path, dest) |
371 | 406 | ||
372 | exec_cmd(cmd, as_shell=True) | 407 | exec_cmd(cmd, as_shell=True) |
373 | self._put_part_image(pnum) | 408 | self._put_part_image(pnum) |
diff --git a/scripts/lib/wic/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py index 499bede280..d370b0107e 100644 --- a/scripts/lib/wic/plugins/source/extra_partition.py +++ b/scripts/lib/wic/plugins/source/extra_partition.py | |||
@@ -12,7 +12,7 @@ logger = logging.getLogger('wic') | |||
12 | 12 | ||
13 | class ExtraPartitionPlugin(SourcePlugin): | 13 | class ExtraPartitionPlugin(SourcePlugin): |
14 | """ | 14 | """ |
15 | Populates an extra partition with files listed in the IMAGE_EXTRA_FILES | 15 | Populates an extra partition with files listed in the IMAGE_EXTRA_PARTITION_FILES |
16 | BitBake variable. Files should be deployed to the DEPLOY_DIR_IMAGE directory. | 16 | BitBake variable. Files should be deployed to the DEPLOY_DIR_IMAGE directory. |
17 | 17 | ||
18 | The plugin supports: | 18 | The plugin supports: |
@@ -23,18 +23,18 @@ class ExtraPartitionPlugin(SourcePlugin): | |||
23 | 23 | ||
24 | For example: | 24 | For example: |
25 | 25 | ||
26 | IMAGE_EXTRA_FILES_label-foo = "bar.conf;foo.conf" | 26 | IMAGE_EXTRA_PARTITION_FILES_label-foo = "bar.conf;foo.conf" |
27 | IMAGE_EXTRA_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "bar.conf;foobar.conf" | 27 | IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "bar.conf;foobar.conf" |
28 | IMAGE_EXTRA_FILES = "foo/*" | 28 | IMAGE_EXTRA_PARTITION_FILES = "foo/*" |
29 | WICVARS:append = "\ | 29 | WICVARS:append = "\ |
30 | IMAGE_EXTRA_FILES_label-foo \ | 30 | IMAGE_EXTRA_PARTITION_FILES_label-foo \ |
31 | IMAGE_EXTRA_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \ | 31 | IMAGE_EXTRA_PARTITION_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \ |
32 | " | 32 | " |
33 | 33 | ||
34 | """ | 34 | """ |
35 | 35 | ||
36 | name = 'extra_partition' | 36 | name = 'extra_partition' |
37 | image_extra_files_var_name = 'IMAGE_EXTRA_FILES' | 37 | image_extra_partition_files_var_name = 'IMAGE_EXTRA_PARTITION_FILES' |
38 | 38 | ||
39 | @classmethod | 39 | @classmethod |
40 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, | 40 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, |
@@ -58,12 +58,12 @@ class ExtraPartitionPlugin(SourcePlugin): | |||
58 | var = fmt % id | 58 | var = fmt % id |
59 | else: | 59 | else: |
60 | var = "" | 60 | var = "" |
61 | extra_files = get_bitbake_var(cls.image_extra_files_var_name + var) | 61 | extra_files = get_bitbake_var(cls.image_extra_partition_files_var_name + var) |
62 | if extra_files is not None: | 62 | if extra_files is not None: |
63 | break | 63 | break |
64 | 64 | ||
65 | if extra_files is None: | 65 | if extra_files is None: |
66 | raise WicError('No extra files defined, %s unset for entry #%d' % (cls.image_extra_files_var_name, part.lineno)) | 66 | raise WicError('No extra files defined, %s unset for entry #%d' % (cls.image_extra_partition_files_var_name, part.lineno)) |
67 | 67 | ||
68 | logger.info('Extra files: %s', extra_files) | 68 | logger.info('Extra files: %s', extra_files) |
69 | 69 | ||
@@ -111,7 +111,7 @@ class ExtraPartitionPlugin(SourcePlugin): | |||
111 | """ | 111 | """ |
112 | Called to do the actual content population for a partition i.e. it | 112 | Called to do the actual content population for a partition i.e. it |
113 | 'prepares' the partition to be incorporated into the image. | 113 | 'prepares' the partition to be incorporated into the image. |
114 | In this case, we copies all files listed in IMAGE_EXTRA_FILES variable. | 114 | In this case, we copies all files listed in IMAGE_EXTRA_PARTITION_FILES variable. |
115 | """ | 115 | """ |
116 | extradir = "%s/extra.%d" % (cr_workdir, part.lineno) | 116 | extradir = "%s/extra.%d" % (cr_workdir, part.lineno) |
117 | 117 | ||