blob: 425da8b22a617dc1864f954df2d825909447fb86 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# 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
28import os
29
30from wic import msger
31from wic.pluginbase import SourcePlugin
32from wic.utils.oe.misc import get_bitbake_var
33
34class 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 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050064 if part.rootfs_dir is None:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 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:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050070 if part.rootfs_dir in krootfs_dir:
71 rootfs_dir = krootfs_dir[part.rootfs_dir]
72 elif part.rootfs_dir:
73 rootfs_dir = part.rootfs_dir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074 else:
75 msg = "Couldn't find --rootfs-dir=%s connection"
76 msg += " or it is not a valid path, exiting"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050077 msger.error(msg % part.rootfs_dir)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078
79 real_rootfs_dir = cls.__get_rootfs_dir(rootfs_dir)
80
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050081 part.rootfs_dir = real_rootfs_dir
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082 part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot)
83