summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/imager
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/imager')
-rw-r--r--scripts/lib/mic/imager/baseimager.py47
-rw-r--r--scripts/lib/mic/imager/direct.py42
2 files changed, 19 insertions, 70 deletions
diff --git a/scripts/lib/mic/imager/baseimager.py b/scripts/lib/mic/imager/baseimager.py
index 0d591eaf43..7f32dd559e 100644
--- a/scripts/lib/mic/imager/baseimager.py
+++ b/scripts/lib/mic/imager/baseimager.py
@@ -97,41 +97,15 @@ class BaseImageCreator(object):
97 97
98 98
99 # 99 #
100 # Properties
101 #
102 def __get_instroot(self):
103 if self.__builddir is None:
104 raise CreatorError("_instroot is not valid before calling mount()")
105 return self.__builddir + "/install_root"
106 _instroot = property(__get_instroot)
107 """The location of the install root directory.
108
109 This is the directory into which the system is installed. Subclasses may
110 mount a filesystem image here or copy files to/from here.
111
112 Note, this directory does not exist before ImageCreator.mount() is called.
113
114 Note also, this is a read-only attribute.
115
116 """
117
118
119 #
120 # Hooks for subclasses 100 # Hooks for subclasses
121 # 101 #
122 def _mount_instroot(self, base_on = None): 102 def _create(self):
123 """Mount or prepare the install root directory. 103 """Create partitions for the disk image(s)
124 104
125 This is the hook where subclasses may prepare the install root by e.g. 105 This is the hook where subclasses may create the partitions
126 mounting creating and loopback mounting a filesystem image to 106 that will be assembled into disk image(s).
127 _instroot.
128 107
129 There is no default implementation. 108 There is no default implementation.
130
131 base_on -- this is the value passed to mount() and can be interpreted
132 as the subclass wishes; it might e.g. be the location of
133 a previously created ISO containing a system image.
134
135 """ 109 """
136 pass 110 pass
137 111
@@ -176,19 +150,16 @@ class BaseImageCreator(object):
176 150
177 runner.show('umount -l %s' % self.workdir) 151 runner.show('umount -l %s' % self.workdir)
178 152
179 def mount(self): 153 def create(self):
180 """Setup the target filesystem in preparation for an install. 154 """Create partitions for the disk image(s)
181 155
182 This function sets up the filesystem which the ImageCreator will 156 Create the partitions that will be assembled into disk
183 install into and configure. The ImageCreator class merely creates an 157 image(s).
184 install root directory, bind mounts some system directories (e.g. /dev)
185 and writes out /etc/fstab. Other subclasses may also e.g. create a
186 sparse file, format it and loopback mount it to the install root.
187 """ 158 """
188 self.__setup_tmpdir() 159 self.__setup_tmpdir()
189 self.__ensure_builddir() 160 self.__ensure_builddir()
190 161
191 self._mount_instroot() 162 self._create()
192 163
193 def unmount(self): 164 def unmount(self):
194 """Unmounts the target filesystem. 165 """Unmounts the target filesystem.
diff --git a/scripts/lib/mic/imager/direct.py b/scripts/lib/mic/imager/direct.py
index 2e6914b86d..b96740d0f4 100644
--- a/scripts/lib/mic/imager/direct.py
+++ b/scripts/lib/mic/imager/direct.py
@@ -79,9 +79,10 @@ class DirectImageCreator(BaseImageCreator):
79 self.staging_data_dir = staging_data_dir 79 self.staging_data_dir = staging_data_dir
80 80
81 def __write_fstab(self, image_rootfs): 81 def __write_fstab(self, image_rootfs):
82 """overriden to generate fstab (temporarily) in rootfs. This 82 """overriden to generate fstab (temporarily) in rootfs. This is called
83 is called from mount_instroot, make sure it doesn't get called 83 from _create, make sure it doesn't get called from
84 from BaseImage.mount()""" 84 BaseImage.create()
85 """
85 if image_rootfs is None: 86 if image_rootfs is None:
86 return None 87 return None
87 88
@@ -217,29 +218,15 @@ class DirectImageCreator(BaseImageCreator):
217 # 218 #
218 # Actual implemention 219 # Actual implemention
219 # 220 #
220 def _mount_instroot(self): 221 def _create(self):
221 """ 222 """
222 For 'wic', we already have our build artifacts and don't want 223 For 'wic', we already have our build artifacts - we just create
223 to loop mount anything to install into, we just create
224 filesystems from the artifacts directly and combine them into 224 filesystems from the artifacts directly and combine them into
225 a partitioned image. 225 a partitioned image.
226
227 We still want to reuse as much of the basic mic machinery
228 though; despite the fact that we don't actually do loop or any
229 other kind of mounting we still want to do many of the same
230 things to prepare images, so we basically just adapt to the
231 basic framework and reinterpret what 'mounting' means in our
232 context.
233
234 _instroot would normally be something like
235 /var/tmp/wic/build/imgcreate-s_9AKQ/install_root, for
236 installing packages, etc. We don't currently need to do that,
237 so we simplify life by just using /var/tmp/wic/build as our
238 workdir.
239 """ 226 """
240 parts = self._get_parts() 227 parts = self._get_parts()
241 228
242 self.__instimage = PartitionedMount(self._instroot) 229 self.__instimage = PartitionedMount()
243 230
244 for p in parts: 231 for p in parts:
245 # as a convenience, set source to the boot partition source 232 # as a convenience, set source to the boot partition source
@@ -250,20 +237,11 @@ class DirectImageCreator(BaseImageCreator):
250 for p in parts: 237 for p in parts:
251 # need to create the filesystems in order to get their 238 # need to create the filesystems in order to get their
252 # sizes before we can add them and do the layout. 239 # sizes before we can add them and do the layout.
253 # PartitionedMount.mount() actually calls __format_disks() 240 # PartitionedMount.create() actually calls __format_disks()
254 # to create the disk images and carve out the partitions, 241 # to create the disk images and carve out the partitions,
255 # then self.install() calls PartitionedMount.install() 242 # then self.install() calls PartitionedMount.install()
256 # which calls __install_partitition() for each partition 243 # which calls __install_partitition() for each partition
257 # to dd the fs into the partitions. It would be nice to 244 # to dd the fs into the partitions.
258 # be able to use e.g. ExtDiskMount etc to create the
259 # filesystems, since that's where existing e.g. mkfs code
260 # is, but those are only created after __format_disks()
261 # which needs the partition sizes so needs them created
262 # before its called. Well, the existing setup is geared
263 # to installing packages into mounted filesystems - maybe
264 # when/if we need to actually do package selection we
265 # should modify things to use those objects, but for now
266 # we can avoid that.
267 245
268 fstab = self.__write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) 246 fstab = self.__write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))
269 247
@@ -294,7 +272,7 @@ class DirectImageCreator(BaseImageCreator):
294 self.__disks[disk_name] = disk_obj 272 self.__disks[disk_name] = disk_obj
295 self.__instimage.add_disk(disk_name, disk_obj) 273 self.__instimage.add_disk(disk_name, disk_obj)
296 274
297 self.__instimage.mount() 275 self.__instimage.create()
298 276
299 def install(self): 277 def install(self):
300 """ 278 """