summaryrefslogtreecommitdiffstats
path: root/scripts/lib/wic/plugins/source/rootfs.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/wic/plugins/source/rootfs.py')
-rw-r--r--scripts/lib/wic/plugins/source/rootfs.py92
1 files changed, 92 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..a432a18705
--- /dev/null
+++ b/scripts/lib/wic/plugins/source/rootfs.py
@@ -0,0 +1,92 @@
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
28import os
29import shutil
30import re
31import tempfile
32
33from wic import kickstart, msger
34from wic.utils import misc, fs_related, errors, runner, cmdln
35from wic.conf import configmgr
36from wic.plugin import pluginmgr
37import wic.imager.direct as direct
38from wic.pluginbase import SourcePlugin
39from wic.utils.oe.misc import *
40from wic.imager.direct import DirectImageCreator
41
42class 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, source_params, cr, cr_workdir,
66 oe_builddir, bootimg_dir, kernel_dir,
67 krootfs_dir, native_sysroot):
68 """
69 Called to do the actual content population for a partition i.e. it
70 'prepares' the partition to be incorporated into the image.
71 In this case, prepare content for legacy bios boot partition.
72 """
73 if part.rootfs is None:
74 if not 'ROOTFS_DIR' in krootfs_dir:
75 msg = "Couldn't find --rootfs-dir, exiting"
76 msger.error(msg)
77 rootfs_dir = krootfs_dir['ROOTFS_DIR']
78 else:
79 if part.rootfs in krootfs_dir:
80 rootfs_dir = krootfs_dir[part.rootfs]
81 elif part.rootfs:
82 rootfs_dir = part.rootfs
83 else:
84 msg = "Couldn't find --rootfs-dir=%s connection"
85 msg += " or it is not a valid path, exiting"
86 msger.error(msg % part.rootfs)
87
88 real_rootfs_dir = self.__get_rootfs_dir(rootfs_dir)
89
90 part.set_rootfs(real_rootfs_dir)
91 part.prepare_rootfs(cr_workdir, oe_builddir, real_rootfs_dir, native_sysroot)
92