diff options
Diffstat (limited to 'scripts/lib/wic/plugins/imager/direct.py')
| -rw-r--r-- | scripts/lib/wic/plugins/imager/direct.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index f20d8433f1..4f441c1ae5 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py | |||
| @@ -32,6 +32,8 @@ import uuid | |||
| 32 | 32 | ||
| 33 | from time import strftime | 33 | from time import strftime |
| 34 | 34 | ||
| 35 | from oe.path import copyhardlinktree | ||
| 36 | |||
| 35 | from wic import WicError | 37 | from wic import WicError |
| 36 | from wic.filemap import sparse_copy | 38 | from wic.filemap import sparse_copy |
| 37 | from wic.ksparser import KickStart, KickStartError | 39 | from wic.ksparser import KickStart, KickStartError |
| @@ -115,12 +117,18 @@ class DirectPlugin(ImagerPlugin): | |||
| 115 | fstab_lines = fstab.readlines() | 117 | fstab_lines = fstab.readlines() |
| 116 | 118 | ||
| 117 | if self._update_fstab(fstab_lines, self.parts): | 119 | if self._update_fstab(fstab_lines, self.parts): |
| 118 | shutil.copyfile(fstab_path, fstab_path + ".orig") | 120 | # copy rootfs dir to workdir to update fstab |
| 121 | # as rootfs can be used by other tasks and can't be modified | ||
| 122 | new_rootfs = os.path.realpath(os.path.join(self.workdir, "rootfs_copy")) | ||
| 123 | copyhardlinktree(image_rootfs, new_rootfs) | ||
| 124 | fstab_path = os.path.join(new_rootfs, 'etc/fstab') | ||
| 125 | |||
| 126 | os.unlink(fstab_path) | ||
| 119 | 127 | ||
| 120 | with open(fstab_path, "w") as fstab: | 128 | with open(fstab_path, "w") as fstab: |
| 121 | fstab.writelines(fstab_lines) | 129 | fstab.writelines(fstab_lines) |
| 122 | 130 | ||
| 123 | return fstab_path | 131 | return new_rootfs |
| 124 | 132 | ||
| 125 | def _update_fstab(self, fstab_lines, parts): | 133 | def _update_fstab(self, fstab_lines, parts): |
| 126 | """Assume partition order same as in wks""" | 134 | """Assume partition order same as in wks""" |
| @@ -156,7 +164,10 @@ class DirectPlugin(ImagerPlugin): | |||
| 156 | filesystems from the artifacts directly and combine them into | 164 | filesystems from the artifacts directly and combine them into |
| 157 | a partitioned image. | 165 | a partitioned image. |
| 158 | """ | 166 | """ |
| 159 | fstab_path = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) | 167 | new_rootfs = self._write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) |
| 168 | if new_rootfs: | ||
| 169 | # rootfs was copied to update fstab | ||
| 170 | self.rootfs_dir['ROOTFS_DIR'] = new_rootfs | ||
| 160 | 171 | ||
| 161 | for part in self.parts: | 172 | for part in self.parts: |
| 162 | # get rootfs size from bitbake variable if it's not set in .ks file | 173 | # get rootfs size from bitbake variable if it's not set in .ks file |
| @@ -172,12 +183,7 @@ class DirectPlugin(ImagerPlugin): | |||
| 172 | if rsize_bb: | 183 | if rsize_bb: |
| 173 | part.size = int(round(float(rsize_bb))) | 184 | part.size = int(round(float(rsize_bb))) |
| 174 | 185 | ||
| 175 | try: | 186 | self._image.prepare(self) |
| 176 | self._image.prepare(self) | ||
| 177 | finally: | ||
| 178 | if fstab_path: | ||
| 179 | shutil.move(fstab_path + ".orig", fstab_path) | ||
| 180 | |||
| 181 | self._image.layout_partitions() | 187 | self._image.layout_partitions() |
| 182 | self._image.create() | 188 | self._image.create() |
| 183 | 189 | ||
