diff options
Diffstat (limited to 'scripts/lib/wic/plugins/source/rootfs.py')
| -rw-r--r-- | scripts/lib/wic/plugins/source/rootfs.py | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/scripts/lib/wic/plugins/source/rootfs.py b/scripts/lib/wic/plugins/source/rootfs.py new file mode 100644 index 0000000000..919e97e6b6 --- /dev/null +++ b/scripts/lib/wic/plugins/source/rootfs.py | |||
| @@ -0,0 +1,91 @@ | |||
| 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) 2014, 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 'rootfs' source plugin class for 'wic' | ||
| 22 | # | ||
| 23 | # AUTHORS | ||
| 24 | # Tom Zanussi <tom.zanussi (at] linux.intel.com> | ||
| 25 | # Joao Henrique Ferreira de Freitas <joaohf (at] gmail.com> | ||
| 26 | # | ||
| 27 | |||
| 28 | import os | ||
| 29 | import shutil | ||
| 30 | import re | ||
| 31 | import tempfile | ||
| 32 | |||
| 33 | from wic import kickstart, msger | ||
| 34 | from wic.utils import misc, fs_related, errors, runner, cmdln | ||
| 35 | from wic.conf import configmgr | ||
| 36 | from wic.plugin import pluginmgr | ||
| 37 | import wic.imager.direct as direct | ||
| 38 | from wic.pluginbase import SourcePlugin | ||
| 39 | from wic.utils.oe.misc import * | ||
| 40 | from wic.imager.direct import DirectImageCreator | ||
| 41 | |||
| 42 | class RootfsPlugin(SourcePlugin): | ||
| 43 | name = 'rootfs' | ||
| 44 | |||
| 45 | @staticmethod | ||
| 46 | def __get_rootfs_dir(rootfs_dir): | ||
| 47 | if os.path.isdir(rootfs_dir): | ||
| 48 | return rootfs_dir | ||
| 49 | |||
| 50 | bitbake_env_lines = find_bitbake_env_lines(rootfs_dir) | ||
| 51 | if not bitbake_env_lines: | ||
| 52 | msg = "Couldn't get bitbake environment, exiting." | ||
| 53 | msger.error(msg) | ||
| 54 | |||
| 55 | image_rootfs_dir = find_artifact(bitbake_env_lines, "IMAGE_ROOTFS") | ||
| 56 | if not os.path.isdir(image_rootfs_dir): | ||
| 57 | msg = "No valid artifact IMAGE_ROOTFS from image named" | ||
| 58 | msg += " %s has been found at %s, exiting.\n" % \ | ||
| 59 | (rootfs_dir, image_rootfs_dir) | ||
| 60 | msger.error(msg) | ||
| 61 | |||
| 62 | return image_rootfs_dir | ||
| 63 | |||
| 64 | @classmethod | ||
| 65 | def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir, | ||
| 66 | kernel_dir, krootfs_dir, native_sysroot): | ||
| 67 | """ | ||
| 68 | Called to do the actual content population for a partition i.e. it | ||
| 69 | 'prepares' the partition to be incorporated into the image. | ||
| 70 | In this case, prepare content for legacy bios boot partition. | ||
| 71 | """ | ||
| 72 | if part.rootfs is None: | ||
| 73 | if not 'ROOTFS_DIR' in krootfs_dir: | ||
| 74 | msg = "Couldn't find --rootfs-dir, exiting" | ||
| 75 | msger.error(msg) | ||
| 76 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] | ||
| 77 | else: | ||
| 78 | if part.rootfs in krootfs_dir: | ||
| 79 | rootfs_dir = krootfs_dir[part.rootfs] | ||
| 80 | elif part.rootfs: | ||
| 81 | rootfs_dir = part.rootfs | ||
| 82 | else: | ||
| 83 | msg = "Couldn't find --rootfs-dir=%s connection" | ||
| 84 | msg += " or it is not a valid path, exiting" | ||
| 85 | msger.error(msg % part.rootfs) | ||
| 86 | |||
| 87 | real_rootfs_dir = self.__get_rootfs_dir(rootfs_dir) | ||
| 88 | |||
| 89 | part.set_rootfs(real_rootfs_dir) | ||
| 90 | part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot) | ||
| 91 | |||
