diff options
Diffstat (limited to 'scripts/lib/mic/imager')
-rw-r--r-- | scripts/lib/mic/imager/baseimager.py | 47 | ||||
-rw-r--r-- | scripts/lib/mic/imager/direct.py | 42 |
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): # - # Properties - # - def __get_instroot(self): - if self.__builddir is None: - raise CreatorError("_instroot is not valid before calling mount()") - return self.__builddir + "/install_root" - _instroot = property(__get_instroot) - """The location of the install root directory. - - This is the directory into which the system is installed. Subclasses may - mount a filesystem image here or copy files to/from here. - - Note, this directory does not exist before ImageCreator.mount() is called. - - Note also, this is a read-only attribute. - - """ - - - # # Hooks for subclasses # - def _mount_instroot(self, base_on = None): - """Mount or prepare the install root directory. + def _create(self): + """Create partitions for the disk image(s) - This is the hook where subclasses may prepare the install root by e.g. - mounting creating and loopback mounting a filesystem image to - _instroot. + This is the hook where subclasses may create the partitions + that will be assembled into disk image(s). There is no default implementation. - - base_on -- this is the value passed to mount() and can be interpreted - as the subclass wishes; it might e.g. be the location of - a previously created ISO containing a system image. - """ pass @@ -176,19 +150,16 @@ class BaseImageCreator(object): runner.show('umount -l %s' % self.workdir) - def mount(self): - """Setup the target filesystem in preparation for an install. + def create(self): + """Create partitions for the disk image(s) - This function sets up the filesystem which the ImageCreator will - install into and configure. The ImageCreator class merely creates an - install root directory, bind mounts some system directories (e.g. /dev) - and writes out /etc/fstab. Other subclasses may also e.g. create a - sparse file, format it and loopback mount it to the install root. + Create the partitions that will be assembled into disk + image(s). """ self.__setup_tmpdir() self.__ensure_builddir() - self._mount_instroot() + self._create() def unmount(self): """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): self.staging_data_dir = staging_data_dir 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()""" + """overriden to generate fstab (temporarily) in rootfs. This is called + from _create, make sure it doesn't get called from + BaseImage.create() + """ if image_rootfs is None: return None @@ -217,29 +218,15 @@ class DirectImageCreator(BaseImageCreator): # # Actual implemention # - def _mount_instroot(self): + def _create(self): """ - For 'wic', we already have our build artifacts and don't want - to loop mount anything to install into, we just create + For 'wic', we already have our build artifacts - we just create filesystems from the artifacts directly and combine them into a partitioned image. - - We still want to reuse as much of the basic mic machinery - though; despite the fact that we don't actually do loop or any - other kind of mounting we still want to do many of the same - things to prepare images, so we basically just adapt to the - basic framework and reinterpret what 'mounting' means in our - context. - - _instroot would normally be something like - /var/tmp/wic/build/imgcreate-s_9AKQ/install_root, for - installing packages, etc. We don't currently need to do that, - so we simplify life by just using /var/tmp/wic/build as our - workdir. """ parts = self._get_parts() - self.__instimage = PartitionedMount(self._instroot) + self.__instimage = PartitionedMount() for p in parts: # as a convenience, set source to the boot partition source @@ -250,20 +237,11 @@ class DirectImageCreator(BaseImageCreator): for p in parts: # need to create the filesystems in order to get their # sizes before we can add them and do the layout. - # PartitionedMount.mount() actually calls __format_disks() + # PartitionedMount.create() actually calls __format_disks() # to create the disk images and carve out the partitions, # then self.install() calls PartitionedMount.install() # which calls __install_partitition() for each partition - # to dd the fs into the partitions. It would be nice to - # be able to use e.g. ExtDiskMount etc to create the - # filesystems, since that's where existing e.g. mkfs code - # is, but those are only created after __format_disks() - # which needs the partition sizes so needs them created - # before its called. Well, the existing setup is geared - # to installing packages into mounted filesystems - maybe - # when/if we need to actually do package selection we - # should modify things to use those objects, but for now - # we can avoid that. + # to dd the fs into the partitions. fstab = self.__write_fstab(self.rootfs_dir.get("ROOTFS_DIR")) @@ -294,7 +272,7 @@ class DirectImageCreator(BaseImageCreator): self.__disks[disk_name] = disk_obj self.__instimage.add_disk(disk_name, disk_obj) - self.__instimage.mount() + self.__instimage.create() def install(self): """ |