summaryrefslogtreecommitdiff
path: root/scripts/lib
diff options
context:
space:
mode:
authorJoão Henrique Ferreira de Freitas <joaohf@gmail.com>2014-03-29 00:12:08 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-30 10:01:58 +0100
commit719d093c40e4c259a4c97d6c8a5efb5aeef5fd38 (patch)
tree7dcaaf88343d4e1926f4d379e8cac385879ad414 /scripts/lib
parenta8762f3be215678a6806cabe49647083f42323a8 (diff)
downloadopenembedded-core-719d093c40e4c259a4c97d6c8a5efb5aeef5fd38.tar.gz
openembedded-core-719d093c40e4c259a4c97d6c8a5efb5aeef5fd38.tar.bz2
openembedded-core-719d093c40e4c259a4c97d6c8a5efb5aeef5fd38.zip
wic: Extend --rootfs-dir to connect rootfs-dirs
The wic command-line param --rootfs-dir gets generalized to support multiple directories. Each '--rootfs-dir' could be connected using a special string, that should be present in .wks. I.e: wic create ... --rootfs-dir rootfs1=/some/rootfs/dir \ --rootfs-dir rootfs2=/some/other/rootfs/dir part / --source rootfs --rootfs-dir="rootfs1" --ondisk sda --fstype=ext3 \ --label primary --align 1024 part /standby --source rootfs --rootfs-dir="rootfs2" \ --ondisk sda --fstype=ext3 --label secondary --align 1024 The user could use harded-code directory instead of connectors. Like this: wic create ... hard-coded-path.wks -r /some/rootfs/dir part / --source rootfs --ondisk sda --fstype=ext3 --label primary --align 1024 part /standby --source rootfs --rootfs-dir=/some/rootfs/dir \ --ondisk sda --fstype=ext3 --label secondary --align 1024 Signed-off-by: João Henrique Ferreira de Freitas <joaohf@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/mic/imager/direct.py18
-rw-r--r--scripts/lib/mic/plugins/imager/direct_plugin.py17
-rw-r--r--scripts/lib/mic/plugins/source/rootfs.py18
3 files changed, 42 insertions, 11 deletions
diff --git a/scripts/lib/mic/imager/direct.py b/scripts/lib/mic/imager/direct.py
index ac63c38903..2cf4c8de95 100644
--- a/scripts/lib/mic/imager/direct.py
+++ b/scripts/lib/mic/imager/direct.py
@@ -84,17 +84,19 @@ class DirectImageCreator(BaseImageCreator):
self.hdddir = hdddir
self.staging_data_dir = staging_data_dir
- def __write_fstab(self):
+ def __write_fstab(self, image_rootfs):
"""overriden to generate fstab (temporarily) in rootfs. This
is called from mount_instroot, make sure it doesn't get called
from BaseImage.mount()"""
+ if image_rootfs is None:
+ return None
- image_rootfs = self.rootfs_dir
+ fstab = image_rootfs + "/etc/fstab"
+ if not os.path.isfile(fstab):
+ return None
parts = self._get_parts()
- fstab = image_rootfs + "/etc/fstab"
-
self._save_fstab(fstab)
fstab_lines = self._get_fstab(fstab, parts)
self._update_fstab(fstab_lines, parts)
@@ -126,6 +128,8 @@ class DirectImageCreator(BaseImageCreator):
def _restore_fstab(self, fstab):
"""Restore the saved fstab in rootfs"""
+ if fstab is None:
+ return
shutil.move(fstab + ".orig", fstab)
def _get_fstab(self, fstab, parts):
@@ -235,8 +239,6 @@ class DirectImageCreator(BaseImageCreator):
self.__instimage = PartitionedMount(self._instroot)
- fstab = self.__write_fstab()
-
for p in parts:
# as a convenience, set source to the boot partition source
# instead of forcing it to be set via bootloader --source
@@ -263,6 +265,9 @@ class DirectImageCreator(BaseImageCreator):
p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir,
self.bootimg_dir, self.kernel_dir, self.native_sysroot)
+ fstab = self.__write_fstab(p.get_rootfs())
+ self._restore_fstab(fstab)
+
self.__instimage.add_partition(int(p.size),
p.disk,
p.mountpoint,
@@ -273,7 +278,6 @@ class DirectImageCreator(BaseImageCreator):
boot = p.active,
align = p.align,
part_type = p.part_type)
- self._restore_fstab(fstab)
self.__instimage.layout_partitions(self._ptable_format)
self.__imgdir = self.workdir
diff --git a/scripts/lib/mic/plugins/imager/direct_plugin.py b/scripts/lib/mic/plugins/imager/direct_plugin.py
index e015256fa1..fc7c10c3df 100644
--- a/scripts/lib/mic/plugins/imager/direct_plugin.py
+++ b/scripts/lib/mic/plugins/imager/direct_plugin.py
@@ -43,6 +43,19 @@ class DirectPlugin(ImagerPlugin):
name = 'direct'
@classmethod
+ def __rootfs_dir_to_dict(self, rootfs_dirs):
+ """
+ Gets a string that contain 'connection=dir' splitted by
+ space and return a dict
+ """
+ krootfs_dir = {}
+ for rootfs_dir in rootfs_dirs.split(' '):
+ k, v = rootfs_dir.split('=')
+ krootfs_dir[k] = v
+
+ return krootfs_dir
+
+ @classmethod
def do_create(self, subcmd, opts, *args):
"""
Create direct image, called from creator as 'direct' cmd
@@ -63,11 +76,13 @@ class DirectPlugin(ImagerPlugin):
image_output_dir = args[7]
oe_builddir = args[8]
+ krootfs_dir = self.__rootfs_dir_to_dict(rootfs_dir)
+
configmgr._ksconf = ksconf
creator = direct.DirectImageCreator(oe_builddir,
image_output_dir,
- rootfs_dir,
+ krootfs_dir,
bootimg_dir,
kernel_dir,
native_sysroot,
diff --git a/scripts/lib/mic/plugins/source/rootfs.py b/scripts/lib/mic/plugins/source/rootfs.py
index 6323811183..75999e03d2 100644
--- a/scripts/lib/mic/plugins/source/rootfs.py
+++ b/scripts/lib/mic/plugins/source/rootfs.py
@@ -45,14 +45,26 @@ class RootfsPlugin(SourcePlugin):
@classmethod
def do_prepare_partition(self, part, cr, cr_workdir, oe_builddir, bootimg_dir,
- kernel_dir, rootfs_dir, native_sysroot):
+ kernel_dir, krootfs_dir, native_sysroot):
"""
Called to do the actual content population for a partition i.e. it
'prepares' the partition to be incorporated into the image.
In this case, prepare content for legacy bios boot partition.
"""
- if part.rootfs:
- rootfs_dir = part.rootfs
+ if part.rootfs is None:
+ if not 'ROOTFS_DIR' in krootfs_dir:
+ msg = "Couldn't find --rootfs-dir, exiting"
+ msger.error(msg)
+ rootfs_dir = krootfs_dir['ROOTFS_DIR']
+ else:
+ if part.rootfs in krootfs_dir:
+ rootfs_dir = krootfs_dir[part.rootfs]
+ elif os.path.isdir(part.rootfs):
+ rootfs_dir = part.rootfs
+ else:
+ msg = "Couldn't find --rootfs-dir=%s connection"
+ msg += " or it is not a valid path, exiting"
+ msger.error(msg % part.rootfs)
part.set_rootfs(rootfs_dir)
part.prepare_rootfs(cr_workdir, oe_builddir, rootfs_dir, native_sysroot)