diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/lib/devtool/ide_sdk.py | 2 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/extra_partition.py | 134 |
2 files changed, 1 insertions, 135 deletions
diff --git a/scripts/lib/devtool/ide_sdk.py b/scripts/lib/devtool/ide_sdk.py index 931408fa74..4d33479e20 100755 --- a/scripts/lib/devtool/ide_sdk.py +++ b/scripts/lib/devtool/ide_sdk.py | |||
@@ -268,7 +268,7 @@ class RecipeNotModified: | |||
268 | 268 | ||
269 | class RecipeModified: | 269 | class RecipeModified: |
270 | """Handling of recipes in the workspace created by devtool modify""" | 270 | """Handling of recipes in the workspace created by devtool modify""" |
271 | OE_INIT_BUILD_ENV = 'oe-init-build-env' | 271 | OE_INIT_BUILD_ENV = 'init-build-env' |
272 | 272 | ||
273 | VALID_BASH_ENV_NAME_CHARS = re.compile(r"^[a-zA-Z0-9_]*$") | 273 | VALID_BASH_ENV_NAME_CHARS = re.compile(r"^[a-zA-Z0-9_]*$") |
274 | 274 | ||
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 | |||