diff options
| author | Maciej Borzecki <maciej.borzecki@open-rnd.pl> | 2014-09-22 13:35:19 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-09-23 20:35:56 +0100 |
| commit | 6b03fc214f8d5cd9a811b611fe680b7f762582d3 (patch) | |
| tree | 50385faa8b10e3c2dfb8e521d9f02b15028aba7f /scripts/lib/wic/plugins/source/bootimg-partition.py | |
| parent | f24abaa9b344822d7527a03535b331d448c43e4c (diff) | |
| download | poky-6b03fc214f8d5cd9a811b611fe680b7f762582d3.tar.gz | |
wic: add new bootimg-partition plugin
This patch implements 'bootimg-partition source plugin class for 'wic'. The
plugin creates an image of boot partition, copying over files listed in
IMAGE_BOOT_FILES bitbake variable.
(From OE-Core rev: 4a3200d710d953956064c28188577fbd461d093d)
Signed-off-by: Maciej Borzecki <maciej.borzecki@open-rnd.pl>
Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugins/source/bootimg-partition.py')
| -rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-partition.py | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py new file mode 100644 index 0000000000..cc72b2f7cb --- /dev/null +++ b/scripts/lib/wic/plugins/source/bootimg-partition.py | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | # ex:ts=4:sw=4:sts=4:et | ||
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
| 3 | # | ||
| 4 | # This program is free software; you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License version 2 as | ||
| 6 | # published by the Free Software Foundation. | ||
| 7 | # | ||
| 8 | # This program is distributed in the hope that it will be useful, | ||
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | # GNU General Public License for more details. | ||
| 12 | # | ||
| 13 | # You should have received a copy of the GNU General Public License along | ||
| 14 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 16 | # | ||
| 17 | # DESCRIPTION | ||
| 18 | # This implements the 'bootimg-partition' source plugin class for | ||
| 19 | # 'wic'. The plugin creates an image of boot partition, copying over | ||
| 20 | # files listed in IMAGE_BOOT_FILES bitbake variable. | ||
| 21 | # | ||
| 22 | # AUTHORS | ||
| 23 | # Maciej Borzecki <maciej.borzecki (at] open-rnd.pl> | ||
| 24 | # | ||
| 25 | |||
| 26 | import os | ||
| 27 | import re | ||
| 28 | |||
| 29 | from wic import msger | ||
| 30 | from wic.pluginbase import SourcePlugin | ||
| 31 | from wic.utils.oe.misc import * | ||
| 32 | |||
| 33 | class BootimgPartitionPlugin(SourcePlugin): | ||
| 34 | name = 'bootimg-partition' | ||
| 35 | |||
| 36 | @classmethod | ||
| 37 | def do_install_disk(self, disk, disk_name, cr, workdir, oe_builddir, | ||
| 38 | bootimg_dir, kernel_dir, native_sysroot): | ||
| 39 | """ | ||
| 40 | Called after all partitions have been prepared and assembled into a | ||
| 41 | disk image. Do nothing. | ||
| 42 | """ | ||
| 43 | pass | ||
| 44 | |||
| 45 | @classmethod | ||
| 46 | def do_configure_partition(self, part, source_params, cr, cr_workdir, | ||
| 47 | oe_builddir, bootimg_dir, kernel_dir, | ||
| 48 | native_sysroot): | ||
| 49 | """ | ||
| 50 | Called before do_prepare_partition(). Possibly prepare | ||
| 51 | configuration files of some sort. | ||
| 52 | |||
| 53 | """ | ||
| 54 | pass | ||
| 55 | |||
| 56 | @classmethod | ||
| 57 | def do_prepare_partition(self, part, source_params, cr, cr_workdir, | ||
| 58 | oe_builddir, bootimg_dir, kernel_dir, | ||
| 59 | rootfs_dir, native_sysroot): | ||
| 60 | """ | ||
| 61 | Called to do the actual content population for a partition i.e. it | ||
| 62 | 'prepares' the partition to be incorporated into the image. | ||
| 63 | In this case, does the following: | ||
| 64 | - sets up a vfat partition | ||
| 65 | - copies all files listed in IMAGE_BOOT_FILES variable | ||
| 66 | """ | ||
| 67 | hdddir = "%s/boot" % cr_workdir | ||
| 68 | rm_cmd = "rm -rf %s" % cr_workdir | ||
| 69 | exec_cmd(rm_cmd) | ||
| 70 | |||
| 71 | install_cmd = "install -d %s" % hdddir | ||
| 72 | exec_cmd(install_cmd) | ||
| 73 | |||
| 74 | msger.debug('Bootimg dir: %s' % bootimg_dir) | ||
| 75 | img_deploy_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
| 76 | boot_files = get_bitbake_var("IMAGE_BOOT_FILES") | ||
| 77 | |||
| 78 | if not boot_files: | ||
| 79 | msger.error('No boot files defined, IMAGE_BOOT_FILES unset') | ||
| 80 | |||
| 81 | msger.debug('Boot files: %s' % boot_files) | ||
| 82 | |||
| 83 | # list of tuples (src_name, dst_name) | ||
| 84 | deploy_files = [] | ||
| 85 | for src_entry in re.findall(r'[\w;\-\./]+', boot_files): | ||
| 86 | if ';' in src_entry: | ||
| 87 | dst_entry = tuple(src_entry.split(';')) | ||
| 88 | else: | ||
| 89 | dst_entry = (src_entry, src_entry) | ||
| 90 | |||
| 91 | msger.debug('Destination entry: %r' % (dst_entry,)) | ||
| 92 | deploy_files.append(dst_entry) | ||
| 93 | |||
| 94 | for deploy_entry in deploy_files: | ||
| 95 | src, dst = deploy_entry | ||
| 96 | src_path = os.path.join(img_deploy_dir, src) | ||
| 97 | dst_path = os.path.join(hdddir, dst) | ||
| 98 | |||
| 99 | msger.debug('Install %s as %s' % (os.path.basename(src_path), | ||
| 100 | dst_path)) | ||
| 101 | install_cmd = "install -m 0644 -D %s %s" \ | ||
| 102 | % (src_path, dst_path) | ||
| 103 | exec_cmd(install_cmd) | ||
| 104 | |||
| 105 | msger.debug('Prepare boot partition using rootfs in %s' % (hdddir)) | ||
| 106 | part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, | ||
| 107 | native_sysroot) | ||
| 108 | |||
