Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 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 | |
| 30 | from wic import msger |
| 31 | from wic.pluginbase import SourcePlugin |
| 32 | from wic.utils.oe.misc import get_bitbake_var |
| 33 | |
| 34 | class RootfsPlugin(SourcePlugin): |
| 35 | """ |
| 36 | Populate partition content from a rootfs directory. |
| 37 | """ |
| 38 | |
| 39 | name = 'rootfs' |
| 40 | |
| 41 | @staticmethod |
| 42 | def __get_rootfs_dir(rootfs_dir): |
| 43 | if os.path.isdir(rootfs_dir): |
| 44 | return rootfs_dir |
| 45 | |
| 46 | image_rootfs_dir = get_bitbake_var("IMAGE_ROOTFS", rootfs_dir) |
| 47 | if not os.path.isdir(image_rootfs_dir): |
| 48 | msg = "No valid artifact IMAGE_ROOTFS from image named" |
| 49 | msg += " %s has been found at %s, exiting.\n" % \ |
| 50 | (rootfs_dir, image_rootfs_dir) |
| 51 | msger.error(msg) |
| 52 | |
| 53 | return image_rootfs_dir |
| 54 | |
| 55 | @classmethod |
| 56 | def do_prepare_partition(cls, part, source_params, cr, cr_workdir, |
| 57 | oe_builddir, bootimg_dir, kernel_dir, |
| 58 | krootfs_dir, native_sysroot): |
| 59 | """ |
| 60 | Called to do the actual content population for a partition i.e. it |
| 61 | 'prepares' the partition to be incorporated into the image. |
| 62 | In this case, prepare content for legacy bios boot partition. |
| 63 | """ |
| 64 | if part.rootfs is None: |
| 65 | if not 'ROOTFS_DIR' in krootfs_dir: |
| 66 | msg = "Couldn't find --rootfs-dir, exiting" |
| 67 | msger.error(msg) |
| 68 | rootfs_dir = krootfs_dir['ROOTFS_DIR'] |
| 69 | else: |
| 70 | if part.rootfs in krootfs_dir: |
| 71 | rootfs_dir = krootfs_dir[part.rootfs] |
| 72 | elif part.rootfs: |
| 73 | rootfs_dir = part.rootfs |
| 74 | else: |
| 75 | msg = "Couldn't find --rootfs-dir=%s connection" |
| 76 | msg += " or it is not a valid path, exiting" |
| 77 | msger.error(msg % part.rootfs) |
| 78 | |
| 79 | real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir) |
| 80 | |
| 81 | part.set_rootfs(real_rootfs_dir) |
| 82 | part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot) |
| 83 | |