diff --git a/pym/install/distr.py b/pym/install/distr.py index 78e6828..6c0bc76 100644 --- a/pym/install/distr.py +++ b/pym/install/distr.py @@ -306,15 +306,14 @@ class Distributive(object): def getEfiDirectories(self): return [path.join(self.getDirectory(), "boot/efi")] - @classmethod - def _makeDirectory(cls, pathname): + def _makeDirectory(self, pathname): """Make directory and parent. If directory exists then return False else True""" try: parent = path.split(path.normpath(pathname))[0] if not path.exists(parent): - cls._makeDirectory(parent) + self._makeDirectory(parent) else: if path.exists(pathname): return False @@ -335,8 +334,7 @@ class Distributive(object): raise DistributiveError(_("Squash size unsupported for %s") % str(self.__class__.__name__)) - @classmethod - def _removeDirectory(cls, directory): + def _removeDirectory(self, directory): """Remove directory and files contained in it""" try: if path.exists(directory): @@ -449,8 +447,7 @@ class Distributive(object): return max(squashfiles, key=self._getSquashNum).group() return None - @classmethod - def _mountToDirectory(cls, file, directory, mountopts="", count=2): + def _mountToDirectory(self, file, directory, mountopts="", count=2): """Mount squashfs to directory""" # 2816 code return by mount if device is absent (update /dev by udev) NO_SUCH_DEVICE = 2816 @@ -469,17 +466,16 @@ class Distributive(object): if mountProcess.returncode() == NO_SUCH_DEVICE and count: sleep(0.5) mountProcess.close() - return cls._mountToDirectory(file, directory, mountopts, + return self._mountToDirectory(file, directory, mountopts, count - 1) try: - cls._removeDirectory(directory) + self._removeDirectory(directory) except Exception: pass raise DistributiveError( - cls.mountError % (file, mountProcess.read())) + self.mountError % (file, mountProcess.read())) - @classmethod - def _umountDirectory(cls, directory): + def _umountDirectory(self, directory): """Umount directory""" if isMount(directory): processUmount = None @@ -1146,17 +1142,15 @@ class PartitionDistributive(Distributive): self.changeSystemID(dev, systemid, partTable) return True - @classmethod - def _checkMount(cls, dev): + def _checkMount(self, dev): """Checking mount point""" if isMount(dev): raise DistributiveError( _("Failed to format %s: this partition is mounted") % dev) - @classmethod - def formatPartition(cls, dev, format="ext4", label=""): + def formatPartition(self, dev, format="ext4", label=""): """Format partition""" - if not format in cls.format_map: + if not format in self.format_map: raise DistributiveError( _("The specified format of '%s' is not supported") % format) if dev in map(lambda y: y.split(" ")[0], @@ -1164,12 +1158,12 @@ class PartitionDistributive(Distributive): open("/proc/swaps"))): raise DistributiveError( _("Failed to format %s: this partition is used as swap") % dev) - cls._checkMount(dev) + self._checkMount(dev) if not os.access(dev, os.W_OK): raise DistributiveError(_("Failed to format the partition") + " %s:\n%s" % (dev, _("Permission denied"))) - format_process = cls.format_map[format](dev, label) + format_process = self.format_map[format](dev, label) if format_process.failed(): raise DistributiveError( _("Failed to format the partition") + diff --git a/pym/install/install.py b/pym/install/install.py index 3f8d0ce..6c53383 100644 --- a/pym/install/install.py +++ b/pym/install/install.py @@ -310,11 +310,23 @@ class Install(MethodsInterface): num=len(formatdisk)) i = 1 for dev, fs in formatdisk: - PartitionDistributive.formatPartition(dev, format="vfat") + self.formatPartition(dev, format="vfat") self.setProgress(i) i += 1 self.endTask(True) + def umountDirectory(self, directory): + return PartitionDistributive(None)._umountDirectory(directory) + + def makeDirectory(self, directory): + return PartitionDistributive(None)._makeDirectory(directory) + + def mountToDirectory(self, dev, mp): + return PartitionDistributive(None)._mountToDirectory(dev, mp) + + def formatPartition(self, dev, format="ext4", label=""): + return PartitionDistributive(None).formatPartition(dev, format, label) + def mount_efi_fstab(self): oldmp_efi = self.clVars.select('os_disk_mount', os_disk_mount__startswith="/boot/efi") @@ -324,13 +336,13 @@ class Install(MethodsInterface): curdev = isMount(mp) if curdev != dev: if curdev: - PartitionDistributive._umountDirectory(mp) - PartitionDistributive._makeDirectory(mp) - PartitionDistributive._mountToDirectory(dev, mp) + self.umountDirectory(mp) + self.makeDirectory(mp) + self.mountToDirectory(dev, mp) if mp in oldmp_efi: oldmp_efi.remove(mp) for mp in oldmp_efi: - PartitionDistributive._umountDirectory(mp) + self.umountDirectory(mp) def install_grub_uefi(self, cmd_grub_install, prefix_boot, target): if self.clVars.Get('cl_action') != "system":