diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2015-02-09 00:16:21 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-02-14 08:40:58 +0000 |
commit | 605627bc9d9fafc39caa6a802eee6203f520f6a8 (patch) | |
tree | 0e4b6bcdc0cb9b885b0ce83df05f262a58e03d36 /scripts/lib/wic/plugins/source/rawcopy.py | |
parent | 0b156dac83258a2789f21038216e43aacc91555a (diff) | |
download | poky-605627bc9d9fafc39caa6a802eee6203f520f6a8.tar.gz |
wic: add rawcopy source plugin
(From OE-Core rev: 5f237238a1fab87668068d042ac86b67d2c5224b)
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/wic/plugins/source/rawcopy.py')
-rw-r--r-- | scripts/lib/wic/plugins/source/rawcopy.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/scripts/lib/wic/plugins/source/rawcopy.py b/scripts/lib/wic/plugins/source/rawcopy.py new file mode 100644 index 0000000000..b3b55fa022 --- /dev/null +++ b/scripts/lib/wic/plugins/source/rawcopy.py | |||
@@ -0,0 +1,77 @@ | |||
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 | |||
18 | import os | ||
19 | import re | ||
20 | |||
21 | from wic import msger | ||
22 | from wic.pluginbase import SourcePlugin | ||
23 | from wic.utils.oe.misc import * | ||
24 | |||
25 | class RawCopyPlugin(SourcePlugin): | ||
26 | name = 'rawcopy' | ||
27 | |||
28 | @classmethod | ||
29 | def do_install_disk(self, disk, disk_name, cr, workdir, oe_builddir, | ||
30 | bootimg_dir, kernel_dir, native_sysroot): | ||
31 | """ | ||
32 | Called after all partitions have been prepared and assembled into a | ||
33 | disk image. Do nothing. | ||
34 | """ | ||
35 | pass | ||
36 | |||
37 | @classmethod | ||
38 | def do_configure_partition(self, part, source_params, cr, cr_workdir, | ||
39 | oe_builddir, bootimg_dir, kernel_dir, | ||
40 | native_sysroot): | ||
41 | """ | ||
42 | Called before do_prepare_partition(). Possibly prepare | ||
43 | configuration files of some sort. | ||
44 | """ | ||
45 | pass | ||
46 | |||
47 | @classmethod | ||
48 | def do_prepare_partition(self, part, source_params, cr, cr_workdir, | ||
49 | oe_builddir, bootimg_dir, kernel_dir, | ||
50 | rootfs_dir, native_sysroot): | ||
51 | """ | ||
52 | Called to do the actual content population for a partition i.e. it | ||
53 | 'prepares' the partition to be incorporated into the image. | ||
54 | """ | ||
55 | if not bootimg_dir: | ||
56 | bootimg_dir = get_bitbake_var("DEPLOY_DIR_IMAGE") | ||
57 | if not bootimg_dir: | ||
58 | msger.error("Couldn't find DEPLOY_DIR_IMAGE, exiting\n") | ||
59 | |||
60 | msger.debug('Bootimg dir: %s' % bootimg_dir) | ||
61 | |||
62 | if ('file' not in source_params): | ||
63 | msger.error("No file specified\n") | ||
64 | return | ||
65 | |||
66 | src = os.path.join(bootimg_dir, source_params['file']) | ||
67 | |||
68 | # get the size in the right units for kickstart (kB) | ||
69 | du_cmd = "du -Lbks %s" % src | ||
70 | out = exec_cmd(du_cmd) | ||
71 | filesize = out.split()[0] | ||
72 | |||
73 | if filesize > part.size: | ||
74 | part.size = filesize | ||
75 | |||
76 | part.source_file = src | ||
77 | |||