diff options
Diffstat (limited to 'scripts/lib/wic/plugins/imager')
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct_plugin.py | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct_plugin.py b/scripts/lib/wic/plugins/imager/direct_plugin.py new file mode 100644 index 0000000000..dabd6fc3e0 --- /dev/null +++ b/scripts/lib/wic/plugins/imager/direct_plugin.py | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | # ex:ts=4:sw=4:sts=4:et | ||
| 2 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- | ||
| 3 | # | ||
| 4 | # Copyright (c) 2013, Intel Corporation. | ||
| 5 | # All rights reserved. | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License version 2 as | ||
| 9 | # published by the Free Software Foundation. | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, | ||
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | # GNU General Public License for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License along | ||
| 17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 19 | # | ||
| 20 | # DESCRIPTION | ||
| 21 | # This implements the 'direct' imager plugin class for 'wic' | ||
| 22 | # | ||
| 23 | # AUTHORS | ||
| 24 | # Tom Zanussi <tom.zanussi (at] linux.intel.com> | ||
| 25 | # | ||
| 26 | |||
| 27 | import os | ||
| 28 | import shutil | ||
| 29 | import re | ||
| 30 | import tempfile | ||
| 31 | |||
| 32 | from wic import msger | ||
| 33 | from wic.utils import misc, fs_related, errors, runner, cmdln | ||
| 34 | from wic.conf import configmgr | ||
| 35 | from wic.plugin import pluginmgr | ||
| 36 | |||
| 37 | import wic.imager.direct as direct | ||
| 38 | from wic.pluginbase import ImagerPlugin | ||
| 39 | |||
| 40 | class DirectPlugin(ImagerPlugin): | ||
| 41 | name = 'direct' | ||
| 42 | |||
| 43 | @classmethod | ||
| 44 | def __rootfs_dir_to_dict(self, rootfs_dirs): | ||
| 45 | """ | ||
| 46 | Gets a string that contain 'connection=dir' splitted by | ||
| 47 | space and return a dict | ||
| 48 | """ | ||
| 49 | krootfs_dir = {} | ||
| 50 | for rootfs_dir in rootfs_dirs.split(' '): | ||
| 51 | k, v = rootfs_dir.split('=') | ||
| 52 | krootfs_dir[k] = v | ||
| 53 | |||
| 54 | return krootfs_dir | ||
| 55 | |||
| 56 | @classmethod | ||
| 57 | def do_create(self, subcmd, opts, *args): | ||
| 58 | """ | ||
| 59 | Create direct image, called from creator as 'direct' cmd | ||
| 60 | """ | ||
| 61 | if len(args) != 9: | ||
| 62 | raise errors.Usage("Extra arguments given") | ||
| 63 | |||
| 64 | staging_data_dir = args[0] | ||
| 65 | hdddir = args[1] | ||
| 66 | native_sysroot = args[2] | ||
| 67 | kernel_dir = args[3] | ||
| 68 | bootimg_dir = args[4] | ||
| 69 | rootfs_dir = args[5] | ||
| 70 | |||
| 71 | creatoropts = configmgr.create | ||
| 72 | ksconf = args[6] | ||
| 73 | |||
| 74 | image_output_dir = args[7] | ||
| 75 | oe_builddir = args[8] | ||
| 76 | |||
| 77 | krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir) | ||
| 78 | |||
| 79 | configmgr._ksconf = ksconf | ||
| 80 | |||
| 81 | creator = direct.DirectImageCreator(oe_builddir, | ||
| 82 | image_output_dir, | ||
| 83 | krootfs_dir, | ||
| 84 | bootimg_dir, | ||
| 85 | kernel_dir, | ||
| 86 | native_sysroot, | ||
| 87 | hdddir, | ||
| 88 | staging_data_dir, | ||
| 89 | creatoropts) | ||
| 90 | |||
| 91 | try: | ||
| 92 | creator.create() | ||
| 93 | creator.assemble() | ||
| 94 | creator.finalize() | ||
| 95 | creator.print_outimage_info() | ||
| 96 | |||
| 97 | except errors.CreatorError: | ||
| 98 | raise | ||
| 99 | finally: | ||
| 100 | creator.cleanup() | ||
| 101 | |||
| 102 | return 0 | ||
