diff options
Diffstat (limited to 'scripts/lib/wic/plugins/source')
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-efi.py | 2 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-partition.py | 45 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/bootimg-pcbios.py | 2 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/fsimage.py | 70 | ||||
-rw-r--r-- | scripts/lib/wic/plugins/source/rawcopy.py | 84 |
5 files changed, 191 insertions, 12 deletions
diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py index e4067b6dbf..ee57881e90 100644 --- a/scripts/lib/wic/plugins/source/bootimg-efi.py +++ b/scripts/lib/wic/plugins/source/bootimg-efi.py @@ -228,7 +228,7 @@ class BootimgEFIPlugin(SourcePlugin): chmod_cmd = "chmod 644 %s" % bootimg exec_cmd(chmod_cmd) - du_cmd = "du -Lbms %s" % bootimg + du_cmd = "du -Lbks %s" % bootimg out = exec_cmd(du_cmd) bootimg_size = out.split()[0] diff --git a/scripts/lib/wic/plugins/source/bootimg-partition.py b/scripts/lib/wic/plugins/source/bootimg-partition.py index abf24942e8..c5eb7b8b80 100644 --- a/scripts/lib/wic/plugins/source/bootimg-partition.py +++ b/scripts/lib/wic/plugins/source/bootimg-partition.py @@ -29,6 +29,7 @@ import re from wic import msger from wic.pluginbase import SourcePlugin from wic.utils.oe.misc import * +from glob import glob class BootimgPartitionPlugin(SourcePlugin): name = 'bootimg-partition' @@ -65,7 +66,7 @@ class BootimgPartitionPlugin(SourcePlugin): - copies all files listed in IMAGE_BOOT_FILES variable """ hdddir = "%s/boot" % cr_workdir - rm_cmd = "rm -rf %s" % cr_workdir + rm_cmd = "rm -rf %s/boot" % cr_workdir exec_cmd(rm_cmd) install_cmd = "install -d %s" % hdddir @@ -87,9 +88,11 @@ class BootimgPartitionPlugin(SourcePlugin): # list of tuples (src_name, dst_name) deploy_files = [] - for src_entry in re.findall(r'[\w;\-\./]+', boot_files): + for src_entry in re.findall(r'[\w;\-\./\*]+', boot_files): if ';' in src_entry: dst_entry = tuple(src_entry.split(';')) + if not dst_entry[0] or not dst_entry[1]: + msger.error('Malformed boot file entry: %s' % (src_entry)) else: dst_entry = (src_entry, src_entry) @@ -98,14 +101,36 @@ class BootimgPartitionPlugin(SourcePlugin): for deploy_entry in deploy_files: src, dst = deploy_entry - src_path = os.path.join(bootimg_dir, src) - dst_path = os.path.join(hdddir, dst) - - msger.debug('Install %s as %s' % (os.path.basename(src_path), - dst_path)) - install_cmd = "install -m 0644 -D %s %s" \ - % (src_path, dst_path) - exec_cmd(install_cmd) + install_task = [] + if '*' in src: + # by default install files under their basename + entry_name_fn = os.path.basename + if dst != src: + # unless a target name was given, then treat name + # as a directory and append a basename + entry_name_fn = lambda name: \ + os.path.join(dst, + os.path.basename(name)) + + srcs = glob(os.path.join(bootimg_dir, src)) + + msger.debug('Globbed sources: %s' % (', '.join(srcs))) + for entry in srcs: + entry_dst_name = entry_name_fn(entry) + install_task.append((entry, + os.path.join(hdddir, + entry_dst_name))) + else: + install_task = [(os.path.join(bootimg_dir, src), + os.path.join(hdddir, dst))] + + for task in install_task: + src_path, dst_path = task + msger.debug('Install %s as %s' % (os.path.basename(src_path), + dst_path)) + install_cmd = "install -m 0644 -D %s %s" \ + % (src_path, dst_path) + exec_cmd(install_cmd) msger.debug('Prepare boot partition using rootfs in %s' % (hdddir)) part.prepare_rootfs(cr_workdir, oe_builddir, hdddir, diff --git a/scripts/lib/wic/plugins/source/bootimg-pcbios.py b/scripts/lib/wic/plugins/source/bootimg-pcbios.py index 8a1aca1ad1..c4786a6e0e 100644 --- a/scripts/lib/wic/plugins/source/bootimg-pcbios.py +++ b/scripts/lib/wic/plugins/source/bootimg-pcbios.py @@ -190,7 +190,7 @@ class BootimgPcbiosPlugin(SourcePlugin): chmod_cmd = "chmod 644 %s" % bootimg exec_cmd(chmod_cmd) - du_cmd = "du -Lbms %s" % bootimg + du_cmd = "du -Lbks %s" % bootimg out = exec_cmd(du_cmd) bootimg_size = out.split()[0] diff --git a/scripts/lib/wic/plugins/source/fsimage.py b/scripts/lib/wic/plugins/source/fsimage.py new file mode 100644 index 0000000000..0967883afa --- /dev/null +++ b/scripts/lib/wic/plugins/source/fsimage.py @@ -0,0 +1,70 @@ +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +import os +import re + +from wic import msger +from wic.pluginbase import SourcePlugin +from wic.utils.oe.misc import * + +class FSImagePlugin(SourcePlugin): + name = 'fsimage' + + @classmethod + def do_install_disk(self, disk, disk_name, cr, workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): + """ + Called after all partitions have been prepared and assembled into a + disk image. Do nothing. + """ + pass + + @classmethod + def do_configure_partition(self, part, source_params, cr, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): + """ + Called before do_prepare_partition(). Possibly prepare + configuration files of some sort. + """ + pass + + @classmethod + def do_prepare_partition(self, part, source_params, cr, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): + """ + Called to do the actual content population for a partition i.e. it + 'prepares' the partition to be incorporated into the image. + """ + if not bootimg_dir: + bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + if not bootimg_dir: + msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") + + msger.debug('Bootimg dir: %s' % bootimg_dir) + + if ('file' not in source_params): + msger.error("No file specified\n") + return + + src = os.path.join(bootimg_dir, source_params['file']) + + + msger.debug('Preparing partition using image %s' % (src)) + part.prepare_rootfs_from_fs_image(cr_workdir, src, "") diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py new file mode 100644 index 0000000000..cf6236a04f --- /dev/null +++ b/scripts/lib/wic/plugins/source/rawcopy.py @@ -0,0 +1,84 @@ +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +import os +import re + +from wic import msger +from wic.pluginbase import SourcePlugin +from wic.utils.oe.misc import * + +class RawCopyPlugin(SourcePlugin): + name = 'rawcopy' + + @classmethod + def do_install_disk(self, disk, disk_name, cr, workdir, oe_builddir, + bootimg_dir, kernel_dir, native_sysroot): + """ + Called after all partitions have been prepared and assembled into a + disk image. Do nothing. + """ + pass + + @classmethod + def do_configure_partition(self, part, source_params, cr, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + native_sysroot): + """ + Called before do_prepare_partition(). Possibly prepare + configuration files of some sort. + """ + pass + + @classmethod + def do_prepare_partition(self, part, source_params, cr, cr_workdir, + oe_builddir, bootimg_dir, kernel_dir, + rootfs_dir, native_sysroot): + """ + Called to do the actual content population for a partition i.e. it + 'prepares' the partition to be incorporated into the image. + """ + if not bootimg_dir: + bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") + if not bootimg_dir: + msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") + + msger.debug('Bootimg dir: %s' % bootimg_dir) + + if ('file' not in source_params): + msger.error("No file specified\n") + return + + src = os.path.join(bootimg_dir, source_params['file']) + dst = src + + if ('skip' in source_params): + dst = os.path.join(cr_workdir, source_params['file']) + dd_cmd = "dd if=%s of=%s ibs=%s skip=1 conv=notrunc" % \ + (src, dst, source_params['skip']) + exec_cmd(dd_cmd) + + # get the size in the right units for kickstart (kB) + du_cmd = "du -Lbks %s" % dst + out = exec_cmd(du_cmd) + filesize = out.split()[0] + + if filesize > part.size: + part.size = filesize + + part.source_file = dst + |