blob: 0391aebdc8408e607a377211fd3c0ecbaa808166 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#
2# Copyright (c) 2014, Intel Corporation.
Patrick Williamsc124f4f2015-09-15 14:41:29 -05003#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: GPL-2.0-only
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005#
6# DESCRIPTION
7# This implements the 'bootimg-efi' source plugin class for 'wic'
8#
9# AUTHORS
10# Tom Zanussi <tom.zanussi (at] linux.intel.com>
11#
12
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013import logging
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014import os
Patrick Williams93c203f2021-10-06 16:15:23 -050015import tempfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016import shutil
Andrew Geissler635e0e42020-08-21 15:58:33 -050017import re
18
19from glob import glob
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021from wic import WicError
22from wic.engine import get_custom_config
Patrick Williamsc124f4f2015-09-15 14:41:29 -050023from wic.pluginbase import SourcePlugin
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024from wic.misc import (exec_cmd, exec_native_cmd,
25 get_bitbake_var, BOOTDD_EXTRA_SPACE)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050026
27logger = logging.getLogger('wic')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028
29class BootimgEFIPlugin(SourcePlugin):
30 """
31 Create EFI boot partition.
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 This plugin supports GRUB 2 and systemd-boot bootloaders.
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 """
34
35 name = 'bootimg-efi'
36
37 @classmethod
Brad Bishopd5ae7d92018-06-14 09:52:03 -070038 def do_configure_grubefi(cls, hdddir, creator, cr_workdir, source_params):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039 """
40 Create loader-specific (grub-efi) config
41 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042 configfile = creator.ks.bootloader.configfile
43 custom_cfg = None
44 if configfile:
45 custom_cfg = get_custom_config(configfile)
46 if custom_cfg:
47 # Use a custom configuration for grub
48 grubefi_conf = custom_cfg
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049 logger.debug("Using custom configuration file "
50 "%s for grub.cfg", configfile)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050051 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052 raise WicError("configfile is specified but failed to "
53 "get it from %s." % configfile)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054
Brad Bishopd5ae7d92018-06-14 09:52:03 -070055 initrd = source_params.get('initrd')
56
57 if initrd:
58 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
59 if not bootimg_dir:
60 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
61
Brad Bishopf3fd2882019-06-21 08:06:37 -040062 initrds = initrd.split(';')
63 for rd in initrds:
64 cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir)
65 exec_cmd(cp_cmd, True)
Brad Bishopd5ae7d92018-06-14 09:52:03 -070066 else:
67 logger.debug("Ignoring missing initrd")
68
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050069 if not custom_cfg:
70 # Create grub configuration using parameters from wks file
71 bootloader = creator.ks.bootloader
Brad Bishop19323692019-04-05 15:28:33 -040072 title = source_params.get('title')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050074 grubefi_conf = ""
75 grubefi_conf += "serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1\n"
76 grubefi_conf += "default=boot\n"
77 grubefi_conf += "timeout=%s\n" % bootloader.timeout
Brad Bishop19323692019-04-05 15:28:33 -040078 grubefi_conf += "menuentry '%s'{\n" % (title if title else "boot")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079
Brad Bishop15ae2502019-06-18 21:44:24 -040080 kernel = get_bitbake_var("KERNEL_IMAGETYPE")
Brad Bishop96ff1982019-08-19 13:50:42 -040081 if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
82 if get_bitbake_var("INITRAMFS_IMAGE"):
83 kernel = "%s-%s.bin" % \
84 (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050085
Brad Bishop15ae2502019-06-18 21:44:24 -040086 label = source_params.get('label')
87 label_conf = "root=%s" % creator.rootdev
88 if label:
89 label_conf = "LABEL=%s" % label
90
91 grubefi_conf += "linux /%s %s rootwait %s\n" \
92 % (kernel, label_conf, bootloader.append)
Brad Bishopd5ae7d92018-06-14 09:52:03 -070093
94 if initrd:
Brad Bishopf3fd2882019-06-21 08:06:37 -040095 initrds = initrd.split(';')
96 grubefi_conf += "initrd"
97 for rd in initrds:
98 grubefi_conf += " /%s" % rd
99 grubefi_conf += "\n"
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700100
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500101 grubefi_conf += "}\n"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500103 logger.debug("Writing grubefi config %s/hdd/boot/EFI/BOOT/grub.cfg",
104 cr_workdir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105 cfg = open("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir, "w")
106 cfg.write(grubefi_conf)
107 cfg.close()
108
109 @classmethod
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500110 def do_configure_systemdboot(cls, hdddir, creator, cr_workdir, source_params):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111 """
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600112 Create loader-specific systemd-boot/gummiboot config
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113 """
114 install_cmd = "install -d %s/loader" % hdddir
115 exec_cmd(install_cmd)
116
117 install_cmd = "install -d %s/loader/entries" % hdddir
118 exec_cmd(install_cmd)
119
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500120 bootloader = creator.ks.bootloader
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121
122 loader_conf = ""
Patrick Williams93c203f2021-10-06 16:15:23 -0500123 if source_params.get('create-unified-kernel-image') != "true":
124 loader_conf += "default boot\n"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500125 loader_conf += "timeout %d\n" % bootloader.timeout
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127 initrd = source_params.get('initrd')
128
Patrick Williams93c203f2021-10-06 16:15:23 -0500129 if initrd and source_params.get('create-unified-kernel-image') != "true":
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500130 # obviously we need to have a common common deploy var
131 bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
132 if not bootimg_dir:
133 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
134
Brad Bishopf3fd2882019-06-21 08:06:37 -0400135 initrds = initrd.split(';')
136 for rd in initrds:
137 cp_cmd = "cp %s/%s %s" % (bootimg_dir, rd, hdddir)
138 exec_cmd(cp_cmd, True)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500139 else:
140 logger.debug("Ignoring missing initrd")
141
142 logger.debug("Writing systemd-boot config "
143 "%s/hdd/boot/loader/loader.conf", cr_workdir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 cfg = open("%s/hdd/boot/loader/loader.conf" % cr_workdir, "w")
145 cfg.write(loader_conf)
146 cfg.close()
147
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500148 configfile = creator.ks.bootloader.configfile
149 custom_cfg = None
150 if configfile:
151 custom_cfg = get_custom_config(configfile)
152 if custom_cfg:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500153 # Use a custom configuration for systemd-boot
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500154 boot_conf = custom_cfg
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500155 logger.debug("Using custom configuration file "
156 "%s for systemd-boots's boot.conf", configfile)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500157 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 raise WicError("configfile is specified but failed to "
159 "get it from %s.", configfile)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500161 if not custom_cfg:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500162 # Create systemd-boot configuration using parameters from wks file
Brad Bishop15ae2502019-06-18 21:44:24 -0400163 kernel = get_bitbake_var("KERNEL_IMAGETYPE")
Brad Bishop96ff1982019-08-19 13:50:42 -0400164 if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
165 if get_bitbake_var("INITRAMFS_IMAGE"):
166 kernel = "%s-%s.bin" % \
167 (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
Brad Bishop15ae2502019-06-18 21:44:24 -0400168
Brad Bishop19323692019-04-05 15:28:33 -0400169 title = source_params.get('title')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500170
171 boot_conf = ""
Brad Bishop19323692019-04-05 15:28:33 -0400172 boot_conf += "title %s\n" % (title if title else "boot")
Brad Bishop15ae2502019-06-18 21:44:24 -0400173 boot_conf += "linux /%s\n" % kernel
174
175 label = source_params.get('label')
176 label_conf = "LABEL=Boot root=%s" % creator.rootdev
177 if label:
178 label_conf = "LABEL=%s" % label
179
180 boot_conf += "options %s %s\n" % \
181 (label_conf, bootloader.append)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500183 if initrd:
Brad Bishopf3fd2882019-06-21 08:06:37 -0400184 initrds = initrd.split(';')
185 for rd in initrds:
186 boot_conf += "initrd /%s\n" % rd
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500187
Patrick Williams93c203f2021-10-06 16:15:23 -0500188 if source_params.get('create-unified-kernel-image') != "true":
189 logger.debug("Writing systemd-boot config "
190 "%s/hdd/boot/loader/entries/boot.conf", cr_workdir)
191 cfg = open("%s/hdd/boot/loader/entries/boot.conf" % cr_workdir, "w")
192 cfg.write(boot_conf)
193 cfg.close()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194
195
196 @classmethod
197 def do_configure_partition(cls, part, source_params, creator, cr_workdir,
198 oe_builddir, bootimg_dir, kernel_dir,
199 native_sysroot):
200 """
201 Called before do_prepare_partition(), creates loader-specific config
202 """
203 hdddir = "%s/hdd/boot" % cr_workdir
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500204
205 install_cmd = "install -d %s/EFI/BOOT" % hdddir
206 exec_cmd(install_cmd)
207
208 try:
209 if source_params['loader'] == 'grub-efi':
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700210 cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500211 elif source_params['loader'] == 'systemd-boot':
212 cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500213 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500214 raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader'])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500215 except KeyError:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500216 raise WicError("bootimg-efi requires a loader, none specified")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500217
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500218 if get_bitbake_var("IMAGE_EFI_BOOT_FILES") is None:
219 logger.debug('No boot files defined in IMAGE_EFI_BOOT_FILES')
Andrew Geissler635e0e42020-08-21 15:58:33 -0500220 else:
221 boot_files = None
222 for (fmt, id) in (("_uuid-%s", part.uuid), ("_label-%s", part.label), (None, None)):
223 if fmt:
224 var = fmt % id
225 else:
226 var = ""
227
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500228 boot_files = get_bitbake_var("IMAGE_EFI_BOOT_FILES" + var)
Andrew Geissler635e0e42020-08-21 15:58:33 -0500229 if boot_files:
230 break
231
232 logger.debug('Boot files: %s', boot_files)
233
234 # list of tuples (src_name, dst_name)
235 deploy_files = []
236 for src_entry in re.findall(r'[\w;\-\./\*]+', boot_files):
237 if ';' in src_entry:
238 dst_entry = tuple(src_entry.split(';'))
239 if not dst_entry[0] or not dst_entry[1]:
240 raise WicError('Malformed boot file entry: %s' % src_entry)
241 else:
242 dst_entry = (src_entry, src_entry)
243
244 logger.debug('Destination entry: %r', dst_entry)
245 deploy_files.append(dst_entry)
246
247 cls.install_task = [];
248 for deploy_entry in deploy_files:
249 src, dst = deploy_entry
250 if '*' in src:
251 # by default install files under their basename
252 entry_name_fn = os.path.basename
253 if dst != src:
254 # unless a target name was given, then treat name
255 # as a directory and append a basename
256 entry_name_fn = lambda name: \
257 os.path.join(dst,
258 os.path.basename(name))
259
260 srcs = glob(os.path.join(kernel_dir, src))
261
262 logger.debug('Globbed sources: %s', ', '.join(srcs))
263 for entry in srcs:
264 src = os.path.relpath(entry, kernel_dir)
265 entry_dst_name = entry_name_fn(entry)
266 cls.install_task.append((src, entry_dst_name))
267 else:
268 cls.install_task.append((src, dst))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500269
270 @classmethod
271 def do_prepare_partition(cls, part, source_params, creator, cr_workdir,
272 oe_builddir, bootimg_dir, kernel_dir,
273 rootfs_dir, native_sysroot):
274 """
275 Called to do the actual content population for a partition i.e. it
276 'prepares' the partition to be incorporated into the image.
277 In this case, prepare content for an EFI (grub) boot partition.
278 """
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500279 if not kernel_dir:
280 kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
281 if not kernel_dir:
282 raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500283
284 staging_kernel_dir = kernel_dir
285
286 hdddir = "%s/hdd/boot" % cr_workdir
287
Brad Bishop15ae2502019-06-18 21:44:24 -0400288 kernel = get_bitbake_var("KERNEL_IMAGETYPE")
Brad Bishop96ff1982019-08-19 13:50:42 -0400289 if get_bitbake_var("INITRAMFS_IMAGE_BUNDLE") == "1":
290 if get_bitbake_var("INITRAMFS_IMAGE"):
291 kernel = "%s-%s.bin" % \
292 (get_bitbake_var("KERNEL_IMAGETYPE"), get_bitbake_var("INITRAMFS_LINK_NAME"))
Brad Bishop15ae2502019-06-18 21:44:24 -0400293
Patrick Williams93c203f2021-10-06 16:15:23 -0500294 if source_params.get('create-unified-kernel-image') == "true":
295 initrd = source_params.get('initrd')
296 if not initrd:
297 raise WicError("initrd= must be specified when create-unified-kernel-image=true, exiting")
298
299 deploy_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
300 efi_stub = glob("%s/%s" % (deploy_dir, "linux*.efi.stub"))
301 if len(efi_stub) == 0:
302 raise WicError("Unified Kernel Image EFI stub not found, exiting")
303 efi_stub = efi_stub[0]
304
305 with tempfile.TemporaryDirectory() as tmp_dir:
306 label = source_params.get('label')
307 label_conf = "root=%s" % creator.rootdev
308 if label:
309 label_conf = "LABEL=%s" % label
310
311 bootloader = creator.ks.bootloader
312 cmdline = open("%s/cmdline" % tmp_dir, "w")
313 cmdline.write("%s %s" % (label_conf, bootloader.append))
314 cmdline.close()
315
316 initrds = initrd.split(';')
317 initrd = open("%s/initrd" % tmp_dir, "wb")
318 for f in initrds:
319 with open("%s/%s" % (deploy_dir, f), 'rb') as in_file:
320 shutil.copyfileobj(in_file, initrd)
321 initrd.close()
322
323 # Searched by systemd-boot:
324 # https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images
325 install_cmd = "install -d %s/EFI/Linux" % hdddir
326 exec_cmd(install_cmd)
327
328 staging_dir_host = get_bitbake_var("STAGING_DIR_HOST")
329
330 # https://www.freedesktop.org/software/systemd/man/systemd-stub.html
331 objcopy_cmd = "objcopy \
332 --add-section .osrel=%s --change-section-vma .osrel=0x20000 \
333 --add-section .cmdline=%s --change-section-vma .cmdline=0x30000 \
334 --add-section .linux=%s --change-section-vma .linux=0x2000000 \
335 --add-section .initrd=%s --change-section-vma .initrd=0x3000000 \
336 %s %s" % \
337 ("%s/usr/lib/os-release" % staging_dir_host,
338 cmdline.name,
339 "%s/%s" % (staging_kernel_dir, kernel),
340 initrd.name,
341 efi_stub,
342 "%s/EFI/Linux/linux.efi" % hdddir)
343 exec_cmd(objcopy_cmd)
344 else:
345 install_cmd = "install -m 0644 %s/%s %s/%s" % \
346 (staging_kernel_dir, kernel, hdddir, kernel)
347 exec_cmd(install_cmd)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500348
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500349 if get_bitbake_var("IMAGE_EFI_BOOT_FILES"):
Andrew Geissler635e0e42020-08-21 15:58:33 -0500350 for src_path, dst_path in cls.install_task:
351 install_cmd = "install -m 0644 -D %s %s" \
352 % (os.path.join(kernel_dir, src_path),
353 os.path.join(hdddir, dst_path))
354 exec_cmd(install_cmd)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500355
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500356 try:
357 if source_params['loader'] == 'grub-efi':
358 shutil.copyfile("%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir,
359 "%s/grub.cfg" % cr_workdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500360 for mod in [x for x in os.listdir(kernel_dir) if x.startswith("grub-efi-")]:
361 cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[9:])
362 exec_cmd(cp_cmd, True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500363 shutil.move("%s/grub.cfg" % cr_workdir,
364 "%s/hdd/boot/EFI/BOOT/grub.cfg" % cr_workdir)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500365 elif source_params['loader'] == 'systemd-boot':
366 for mod in [x for x in os.listdir(kernel_dir) if x.startswith("systemd-")]:
367 cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[8:])
368 exec_cmd(cp_cmd, True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500369 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500370 raise WicError("unrecognized bootimg-efi loader: %s" %
371 source_params['loader'])
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500372 except KeyError:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500373 raise WicError("bootimg-efi requires a loader, none specified")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500374
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500375 startup = os.path.join(kernel_dir, "startup.nsh")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600376 if os.path.exists(startup):
377 cp_cmd = "cp %s %s/" % (startup, hdddir)
378 exec_cmd(cp_cmd, True)
379
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500380 du_cmd = "du -bks %s" % hdddir
381 out = exec_cmd(du_cmd)
382 blocks = int(out.split()[0])
383
384 extra_blocks = part.get_extra_block_count(blocks)
385
386 if extra_blocks < BOOTDD_EXTRA_SPACE:
387 extra_blocks = BOOTDD_EXTRA_SPACE
388
389 blocks += extra_blocks
390
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500391 logger.debug("Added %d extra blocks to %s to get to %d total blocks",
392 extra_blocks, part.mountpoint, blocks)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500393
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500394 # dosfs image, created by mkdosfs
395 bootimg = "%s/boot.img" % cr_workdir
396
Brad Bishopc342db32019-05-15 21:57:59 -0400397 label = part.label if part.label else "ESP"
398
399 dosfs_cmd = "mkdosfs -n %s -i %s -C %s %d" % \
400 (label, part.fsuuid, bootimg, blocks)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500401 exec_native_cmd(dosfs_cmd, native_sysroot)
402
403 mcopy_cmd = "mcopy -i %s -s %s/* ::/" % (bootimg, hdddir)
404 exec_native_cmd(mcopy_cmd, native_sysroot)
405
406 chmod_cmd = "chmod 644 %s" % bootimg
407 exec_cmd(chmod_cmd)
408
409 du_cmd = "du -Lbks %s" % bootimg
410 out = exec_cmd(du_cmd)
411 bootimg_size = out.split()[0]
412
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500413 part.size = int(bootimg_size)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500414 part.source_file = bootimg