|
|
|
@ -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") +
|
|
|
|
|