summaryrefslogtreecommitdiff
path: root/scripts/lib/wic/plugins/source/rawcopy.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/plugins/source/rawcopy.py')
-rw-r--r--scripts/lib/wic/plugins/source/rawcopy.py65
1 files changed, 25 insertions, 40 deletions
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py
index cf6236a04f..e1c4f5e7db 100644
--- a/scripts/lib/wic/plugins/source/rawcopy.py
+++ b/scripts/lib/wic/plugins/source/rawcopy.py
@@ -15,70 +15,55 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
+import logging
import os
-import re
-from wic import msger
+from wic import WicError
from wic.pluginbase import SourcePlugin
-from wic.utils.oe.misc import *
+from wic.utils.misc import exec_cmd, get_bitbake_var
+from wic.filemap import sparse_copy
-class RawCopyPlugin(SourcePlugin):
- name = 'rawcopy'
+logger = logging.getLogger('wic')
- @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
+class RawCopyPlugin(SourcePlugin):
+ """
+ Populate partition content from raw image file.
+ """
- @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
+ name = 'rawcopy'
@classmethod
- def do_prepare_partition(self, part, source_params, cr, cr_workdir,
+ def do_prepare_partition(cls, 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")
+ if not kernel_dir:
+ kernel_dir = get_bitbake_var("DEPLOY_DIR_IMAGE")
+ if not kernel_dir:
+ raise WicError("Couldn't find DEPLOY_DIR_IMAGE, exiting")
- msger.debug('Bootimg dir: %s' % bootimg_dir)
+ logger.debug('Kernel dir: %s', kernel_dir)
- if ('file' not in source_params):
- msger.error("No file specified\n")
- return
+ if 'file' not in source_params:
+ raise WicError("No file specified")
- src = os.path.join(bootimg_dir, source_params['file'])
- dst = src
+ src = os.path.join(kernel_dir, source_params['file'])
+ dst = os.path.join(cr_workdir, "%s.%s" % (source_params['file'], part.lineno))
- 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)
+ if 'skip' in source_params:
+ sparse_copy(src, dst, skip=int(source_params['skip']))
+ else:
+ sparse_copy(src, dst)
# 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]
+ filesize = int(out.split()[0])
if filesize > part.size:
part.size = filesize
part.source_file = dst
-