diff options
author | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2015-10-09 22:59:03 +0200 |
commit | 972dcfcdbfe75dcfeb777150c136576cf1a71e99 (patch) | |
tree | 97a61cd7e293d7ae9d56ef7ed0f81253365bb026 /scripts/lib/wic/pluginbase.py | |
download | poky-972dcfcdbfe75dcfeb777150c136576cf1a71e99.tar.gz |
initial commit for Enea Linux 5.0 arm
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'scripts/lib/wic/pluginbase.py')
-rw-r--r-- | scripts/lib/wic/pluginbase.py | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/scripts/lib/wic/pluginbase.py b/scripts/lib/wic/pluginbase.py new file mode 100644 index 0000000000..d63e34e089 --- /dev/null +++ b/scripts/lib/wic/pluginbase.py | |||
@@ -0,0 +1,120 @@ | |||
1 | #!/usr/bin/env python -tt | ||
2 | # | ||
3 | # Copyright (c) 2011 Intel, Inc. | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify it | ||
6 | # under the terms of the GNU General Public License as published by the Free | ||
7 | # Software Foundation; version 2 of the License | ||
8 | # | ||
9 | # This program is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
11 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
12 | # for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License along | ||
15 | # with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
16 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | |||
18 | import os | ||
19 | import shutil | ||
20 | from wic import msger | ||
21 | from wic.utils import errors | ||
22 | |||
23 | class _Plugin(object): | ||
24 | class __metaclass__(type): | ||
25 | def __init__(cls, name, bases, attrs): | ||
26 | if not hasattr(cls, 'plugins'): | ||
27 | cls.plugins = {} | ||
28 | |||
29 | elif 'wic_plugin_type' in attrs: | ||
30 | if attrs['wic_plugin_type'] not in cls.plugins: | ||
31 | cls.plugins[attrs['wic_plugin_type']] = {} | ||
32 | |||
33 | elif hasattr(cls, 'wic_plugin_type') and 'name' in attrs: | ||
34 | cls.plugins[cls.wic_plugin_type][attrs['name']] = cls | ||
35 | |||
36 | def show_plugins(cls): | ||
37 | for cls in cls.plugins[cls.wic_plugin_type]: | ||
38 | print cls | ||
39 | |||
40 | def get_plugins(cls): | ||
41 | return cls.plugins | ||
42 | |||
43 | |||
44 | class ImagerPlugin(_Plugin): | ||
45 | wic_plugin_type = "imager" | ||
46 | |||
47 | |||
48 | class SourcePlugin(_Plugin): | ||
49 | wic_plugin_type = "source" | ||
50 | """ | ||
51 | The methods that can be implemented by --source plugins. | ||
52 | |||
53 | Any methods not implemented in a subclass inherit these. | ||
54 | """ | ||
55 | |||
56 | @classmethod | ||
57 | def do_install_pkgs(self, part, creator, cr_workdir, oe_builddir, rootfs_dir, | ||
58 | bootimg_dir, kernel_dir, native_sysroot): | ||
59 | """ | ||
60 | Called before partitions have been prepared and assembled into a | ||
61 | disk image. Install packages into rootfs | ||
62 | """ | ||
63 | msger.debug("SourcePlugin: do_install_pkgs: part %s" % part) | ||
64 | |||
65 | @classmethod | ||
66 | def do_install_disk(self, disk, disk_name, cr, workdir, oe_builddir, | ||
67 | bootimg_dir, kernel_dir, native_sysroot): | ||
68 | """ | ||
69 | Called after all partitions have been prepared and assembled into a | ||
70 | disk image. This provides a hook to allow finalization of a | ||
71 | disk image e.g. to write an MBR to it. | ||
72 | """ | ||
73 | msger.debug("SourcePlugin: do_install_disk: disk: %s" % disk_name) | ||
74 | |||
75 | @classmethod | ||
76 | def do_stage_partition(self, part, source_params, cr, cr_workdir, | ||
77 | oe_builddir, bootimg_dir, kernel_dir, | ||
78 | native_sysroot): | ||
79 | """ | ||
80 | Special content staging hook called before do_prepare_partition(), | ||
81 | normally empty. | ||
82 | |||
83 | Typically, a partition will just use the passed-in parame e.g | ||
84 | straight bootimg_dir, etc, but in some cases, things need to | ||
85 | be more tailored e.g. to use a deploy dir + /boot, etc. This | ||
86 | hook allows those files to be staged in a customized fashion. | ||
87 | Not that get_bitbake_var() allows you to acces non-standard | ||
88 | variables that you might want to use for this. | ||
89 | """ | ||
90 | msger.debug("SourcePlugin: do_stage_partition: part: %s" % part) | ||
91 | |||
92 | @classmethod | ||
93 | def do_configure_partition(self, part, source_params, cr, cr_workdir, | ||
94 | oe_builddir, bootimg_dir, kernel_dir, | ||
95 | native_sysroot): | ||
96 | """ | ||
97 | Called before do_prepare_partition(), typically used to create | ||
98 | custom configuration files for a partition, for example | ||
99 | syslinux or grub config files. | ||
100 | """ | ||
101 | msger.debug("SourcePlugin: do_configure_partition: part: %s" % part) | ||
102 | |||
103 | @classmethod | ||
104 | def do_prepare_partition(self, part, source_params, cr, cr_workdir, | ||
105 | oe_builddir, bootimg_dir, kernel_dir, rootfs_dir, | ||
106 | native_sysroot): | ||
107 | """ | ||
108 | Called to do the actual content population for a partition i.e. it | ||
109 | 'prepares' the partition to be incorporated into the image. | ||
110 | """ | ||
111 | msger.debug("SourcePlugin: do_prepare_partition: part: %s" % part) | ||
112 | |||
113 | def get_plugins(typen): | ||
114 | ps = ImagerPlugin.get_plugins() | ||
115 | if typen in ps: | ||
116 | return ps[typen] | ||
117 | else: | ||
118 | return None | ||
119 | |||
120 | __all__ = ['ImagerPlugin', 'SourcePlugin', 'get_plugins'] | ||