diff options
Diffstat (limited to 'scripts/lib')
-rwxr-xr-x | scripts/lib/devtool/ide_sdk.py | 15 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/extra_partition.py | 134 |
2 files changed, 9 insertions, 140 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/plugins/source/extra_partition.py b/scripts/lib/wic/plugins/source/extra_partition.py deleted file mode 100644 index 499bede280..0000000000 --- a/scripts/lib/wic/plugins/source/extra_partition.py +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | import logging | ||
2 | import os | ||
3 | import re | ||
4 | |||
5 | from glob import glob | ||
6 | |||
7 | from wic import WicError | ||
8 | from wic.pluginbase import SourcePlugin | ||
9 | from wic.misc import exec_cmd, get_bitbake_var | ||
10 | |||
11 | logger = logging.getLogger('wic') | ||
12 | |||
13 | class ExtraPartitionPlugin(SourcePlugin): | ||
14 | """ | ||
15 | Populates an extra partition with files listed in the IMAGE_EXTRA_FILES | ||
16 | BitBake variable. Files should be deployed to the DEPLOY_DIR_IMAGE directory. | ||
17 | |||
18 | The plugin supports: | ||
19 | - Glob pattern matching for file selection. | ||
20 | - File renaming. | ||
21 | - Suffixes to specify the target partition (by label, UUID, or partname), | ||
22 | enabling multiple extra partitions to coexist. | ||
23 | |||
24 | For example: | ||
25 | |||
26 | IMAGE_EXTRA_FILES_label-foo = "bar.conf;foo.conf" | ||
27 | IMAGE_EXTRA_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d = "bar.conf;foobar.conf" | ||
28 | IMAGE_EXTRA_FILES = "foo/*" | ||
29 | WICVARS:append = "\ | ||
30 | IMAGE_EXTRA_FILES_label-foo \ | ||
31 | IMAGE_EXTRA_FILES_uuid-e7d0824e-cda3-4bed-9f54-9ef5312d105d \ | ||
32 | " | ||
33 | |||
34 | """ | ||
35 | |||
36 | name = 'extra_partition' | ||
37 | image_extra_files_var_name = 'IMAGE_EXTRA_FILES' | ||
38 | |||
39 | @classmethod | ||
40 | def do_configure_partition(cls, part, source_params, cr, cr_workdir, | ||
41 | oe_builddir, bootimg_dir, kernel_dir, | ||
42 | native_sysroot): | ||
43 | """ | ||
44 | Called before do_prepare_partition(), list the files to copy | ||
45 | """ | ||
46 | extradir = "%s/extra.%d" % (cr_workdir, part.lineno) | ||
47 | install_cmd = "install -d %s" % extradir | ||
48 | exec_cmd(install_cmd) | ||
49 | |||
50 | if not kernel_dir: | ||
51 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
52 | if not kernel_dir: | ||
53 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") | ||
54 | |||
55 | extra_files = None | ||
56 | for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), ("_part-name-%s", part.part_name), (None, None)): | ||
57 | if fmt: | ||
58 | var = fmt % id | ||
59 | else: | ||
60 | var = "" | ||
61 | extra_files = get_bitbake_var(cls.image_extra_files_var_name + var) | ||
62 | if extra_files is not None: | ||
63 | break | ||
64 | |||
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)) | ||
67 | |||
68 | logger.info('Extra files: %s', extra_files) | ||
69 | |||
70 | # list of tuples (src_name, dst_name) | ||
71 | deploy_files = [] | ||
72 | for src_entry in re.findall(r'[\w;\-\./\*]+', extra_files): | ||
73 | if ';' in src_entry: | ||
74 | dst_entry = tuple(src_entry.split(';')) | ||
75 | if not dst_entry[0] or not dst_entry[1]: | ||
76 | raise WicError('Malformed extra file entry: %s' % src_entry) | ||
77 | else: | ||
78 | dst_entry = (src_entry, src_entry) | ||
79 | |||
80 | logger.debug('Destination entry: %r', dst_entry) | ||
81 | deploy_files.append(dst_entry) | ||
82 | |||
83 | cls.install_task = []; | ||
84 | for deploy_entry in deploy_files: | ||
85 | src, dst = deploy_entry | ||
86 | if '*' in src: | ||
87 | # by default install files under their basename | ||
88 | entry_name_fn = os.path.basename | ||
89 | if dst != src: | ||
90 | # unless a target name was given, then treat name | ||
91 | # as a directory and append a basename | ||
92 | entry_name_fn = lambda name: \ | ||
93 | os.path.join(dst, | ||
94 | os.path.basename(name)) | ||
95 | |||
96 | srcs = glob(os.path.join(kernel_dir, src)) | ||
97 | |||
98 | logger.debug('Globbed sources: %s', ', '.join(srcs)) | ||
99 | for entry in srcs: | ||
100 | src = os.path.relpath(entry, kernel_dir) | ||
101 | entry_dst_name = entry_name_fn(entry) | ||
102 | cls.install_task.append((src, entry_dst_name)) | ||
103 | else: | ||
104 | cls.install_task.append((src, dst)) | ||
105 | |||
106 | |||
107 | @classmethod | ||
108 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, | ||
109 | oe_builddir, bootimg_dir, kernel_dir, | ||
110 | rootfs_dir, native_sysroot): | ||
111 | """ | ||
112 | Called to do the actual content population for a partition i.e. it | ||
113 | 'prepares' the partition to be incorporated into the image. | ||
114 | In this case, we copies all files listed in IMAGE_EXTRA_FILES variable. | ||
115 | """ | ||
116 | extradir = "%s/extra.%d" % (cr_workdir, part.lineno) | ||
117 | |||
118 | if not kernel_dir: | ||
119 | kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
120 | if not kernel_dir: | ||
121 | raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting") | ||
122 | |||
123 | for task in cls.install_task: | ||
124 | src_path, dst_path = task | ||
125 | logger.debug('Install %s as %s', src_path, dst_path) | ||
126 | install_cmd = "install -m 0644 -D %s %s" \ | ||
127 | % (os.path.join(kernel_dir, src_path), | ||
128 | os.path.join(extradir, dst_path)) | ||
129 | exec_cmd(install_cmd) | ||
130 | |||
131 | logger.debug('Prepare extra partition using rootfs in %s', extradir) | ||
132 | part.prepare_rootfs(cr_workdir, oe_builddir, extradir, | ||
133 | native_sysroot, False) | ||
134 | |||