diff options
author | João Henrique Ferreira de Freitas <joaohf@gmail.com> | 2014-03-29 00:12:08 -0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-30 10:10:35 +0100 |
commit | ba65fe654a66102e84582886cb0cc19889f5d3dd (patch) | |
tree | b9ad9aa0452bee7a93d0ebc5227a9700b70e57bb /scripts/lib/mic/imager/direct.py | |
parent | 3c0038488491374e745ebcfbd091c3f28cc8c089 (diff) | |
download | poky-ba65fe654a66102e84582886cb0cc19889f5d3dd.tar.gz |
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
(From OE-Core rev: 719d093c40e4c259a4c97d6c8a5efb5aeef5fd38)
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/mic/imager/direct.py')
-rw-r--r-- | scripts/lib/mic/imager/direct.py | 18 |
1 files changed, 11 insertions, 7 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): | |||
84 | self.hdddir = hdddir | 84 | self.hdddir = hdddir |
85 | self.staging_data_dir = staging_data_dir | 85 | self.staging_data_dir = staging_data_dir |
86 | 86 | ||
87 | def __write_fstab(self): | 87 | def __write_fstab(self, image_rootfs): |
88 | """overriden to generate fstab (temporarily) in rootfs. This | 88 | """overriden to generate fstab (temporarily) in rootfs. This |
89 | is called from mount_instroot, make sure it doesn't get called | 89 | is called from mount_instroot, make sure it doesn't get called |
90 | from BaseImage.mount()""" | 90 | from BaseImage.mount()""" |
91 | if image_rootfs is None: | ||
92 | return None | ||
91 | 93 | ||
92 | image_rootfs = self.rootfs_dir | 94 | fstab = image_rootfs + "/etc/fstab" |
95 | if not os.path.isfile(fstab): | ||
96 | return None | ||
93 | 97 | ||
94 | parts = self._get_parts() | 98 | parts = self._get_parts() |
95 | 99 | ||
96 | fstab = image_rootfs + "/etc/fstab" | ||
97 | |||
98 | self._save_fstab(fstab) | 100 | self._save_fstab(fstab) |
99 | fstab_lines = self._get_fstab(fstab, parts) | 101 | fstab_lines = self._get_fstab(fstab, parts) |
100 | self._update_fstab(fstab_lines, parts) | 102 | self._update_fstab(fstab_lines, parts) |
@@ -126,6 +128,8 @@ class DirectImageCreator(BaseImageCreator): | |||
126 | 128 | ||
127 | def _restore_fstab(self, fstab): | 129 | def _restore_fstab(self, fstab): |
128 | """Restore the saved fstab in rootfs""" | 130 | """Restore the saved fstab in rootfs""" |
131 | if fstab is None: | ||
132 | return | ||
129 | shutil.move(fstab + ".orig", fstab) | 133 | shutil.move(fstab + ".orig", fstab) |
130 | 134 | ||
131 | def _get_fstab(self, fstab, parts): | 135 | def _get_fstab(self, fstab, parts): |
@@ -235,8 +239,6 @@ class DirectImageCreator(BaseImageCreator): | |||
235 | 239 | ||
236 | self.__instimage = PartitionedMount(self._instroot) | 240 | self.__instimage = PartitionedMount(self._instroot) |
237 | 241 | ||
238 | fstab = self.__write_fstab() | ||
239 | |||
240 | for p in parts: | 242 | for p in parts: |
241 | # as a convenience, set source to the boot partition source | 243 | # as a convenience, set source to the boot partition source |
242 | # instead of forcing it to be set via bootloader --source | 244 | # instead of forcing it to be set via bootloader --source |
@@ -263,6 +265,9 @@ class DirectImageCreator(BaseImageCreator): | |||
263 | p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir, | 265 | p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir, |
264 | self.bootimg_dir, self.kernel_dir, self.native_sysroot) | 266 | self.bootimg_dir, self.kernel_dir, self.native_sysroot) |
265 | 267 | ||
268 | fstab = self.__write_fstab(p.get_rootfs()) | ||
269 | self._restore_fstab(fstab) | ||
270 | |||
266 | self.__instimage.add_partition(int(p.size), | 271 | self.__instimage.add_partition(int(p.size), |
267 | p.disk, | 272 | p.disk, |
268 | p.mountpoint, | 273 | p.mountpoint, |
@@ -273,7 +278,6 @@ class DirectImageCreator(BaseImageCreator): | |||
273 | boot = p.active, | 278 | boot = p.active, |
274 | align = p.align, | 279 | align = p.align, |
275 | part_type = p.part_type) | 280 | part_type = p.part_type) |
276 | self._restore_fstab(fstab) | ||
277 | self.__instimage.layout_partitions(self._ptable_format) | 281 | self.__instimage.layout_partitions(self._ptable_format) |
278 | 282 | ||
279 | self.__imgdir = self.workdir | 283 | self.__imgdir = self.workdir |