|
|
|
@ -786,7 +786,7 @@ class otherfilesCopy(scanDirectory):
|
|
|
|
|
{'src':pathname,'dst':pathJoin(self.target,pathname)})
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
class Install(color_print, SignalInterrupt):
|
|
|
|
|
"""Primary class for templates appling and system installation"""
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
@ -1293,27 +1293,25 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def setDisks(self,listDisks,listBinds,listSwaps):
|
|
|
|
|
def setDisks(self,listDisks):
|
|
|
|
|
"""Set data for installation partitions"""
|
|
|
|
|
convObj = convertDictOpt(self.clVars)
|
|
|
|
|
try:
|
|
|
|
|
listDisks = map(convObj, listDisks)
|
|
|
|
|
# detect previous system if not specified root partition
|
|
|
|
|
if not filter(lambda x: x['mountPoint'] == '/',listDisks):
|
|
|
|
|
prevRootDev = self.clVars.Get('os_install_dev_from')
|
|
|
|
|
if prevRootDev:
|
|
|
|
|
listDisks += map(convObj, [{'mountPoint': '',
|
|
|
|
|
'options': ['noatime'],
|
|
|
|
|
'dev': prevRootDev,
|
|
|
|
|
'fileSystem': ''}])
|
|
|
|
|
listBinds = map(convObj, listBinds)
|
|
|
|
|
listSwaps = map(convObj, listSwaps)
|
|
|
|
|
except InstallError,e:
|
|
|
|
|
self.printERROR(str(e))
|
|
|
|
|
if convObj.listFileSystemCorrupted:
|
|
|
|
|
self.printWARNING(_("See 'man mount' for file system") + " "+\
|
|
|
|
|
", ".join(convObj.listFileSystemCorrupted))
|
|
|
|
|
return False
|
|
|
|
|
listSwaps = filter(lambda x:x[0].startswith('/dev') and
|
|
|
|
|
x[1] == "swap",listDisks)
|
|
|
|
|
listBinds = filter(lambda x:not x[0].startswith('/dev'),listDisks)
|
|
|
|
|
listDisks = filter(lambda x:x[0].startswith('/dev') and
|
|
|
|
|
x[1] != "swap",listDisks)
|
|
|
|
|
listDisks = map(convObj, listDisks)
|
|
|
|
|
# detect previous system if not specified root partition
|
|
|
|
|
if not filter(lambda x: x['mountPoint'] == '/',listDisks):
|
|
|
|
|
prevRootDev = self.clVars.Get('os_install_dev_from')
|
|
|
|
|
if prevRootDev:
|
|
|
|
|
listDisks += map(convObj, [{'mountPoint': '',
|
|
|
|
|
'options': ['noatime'],
|
|
|
|
|
'dev': prevRootDev,
|
|
|
|
|
'fileSystem': ''}])
|
|
|
|
|
listBinds = map(convObj, listBinds)
|
|
|
|
|
listSwaps = map(convObj, listSwaps)
|
|
|
|
|
# break perform if disk params empty and os_install_dev_from empty
|
|
|
|
|
if not (listDisks or listSwaps or listBinds):
|
|
|
|
|
return True
|
|
|
|
@ -1326,18 +1324,16 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
# check mount options for scratch and flash
|
|
|
|
|
if filter(lambda x: x != '/', usedMP):
|
|
|
|
|
if self.clVars.Get('os_install_scratch') == "on":
|
|
|
|
|
self.printERROR(
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Builder mode does not support multipartition install"))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# check specified devices
|
|
|
|
|
wrongDevices = list(set(usedDevicesOnlyDisks) - \
|
|
|
|
|
set(self.clVars.Get('os_disk_dev')))
|
|
|
|
|
wrongDevices = wrongDevices + list(set(usedDevicesOnlySwap) - \
|
|
|
|
|
set(self.clVars.Get('os_disk_dev')+["none"]))
|
|
|
|
|
if wrongDevices:
|
|
|
|
|
self.printERROR(_("Incorrect device '%s'")%wrongDevices[0])
|
|
|
|
|
return False
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Incorrect device '%s'")%wrongDevices[0])
|
|
|
|
|
|
|
|
|
|
# detect using extended partition
|
|
|
|
|
extendedPartitions = map(lambda x: x[1],
|
|
|
|
@ -1346,10 +1342,9 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
self.clVars.Get('os_disk_dev'))))
|
|
|
|
|
usingExtPart = list(set(usedDevices)&set(extendedPartitions))
|
|
|
|
|
if usingExtPart:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Unable to use the extended partition %s for installation")%
|
|
|
|
|
usingExtPart[0])
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# detect using CDROM disks
|
|
|
|
|
cdromPartitions = map(lambda x: x[1],
|
|
|
|
@ -1358,9 +1353,9 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
self.clVars.Get('os_disk_dev'))))
|
|
|
|
|
usingCdromPart = list(set(usedDevices)&set(cdromPartitions))
|
|
|
|
|
if usingCdromPart:
|
|
|
|
|
self.printERROR(_("Unable to use CDROM %s for installation")%
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Unable to use CDROM %s for installation")%
|
|
|
|
|
usingCdromPart[0])
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# detect using RAID member disks
|
|
|
|
|
raidMemberData = filter(lambda x: "raidmember" in x[0],
|
|
|
|
@ -1373,14 +1368,13 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
raidMemberData)[0][0]
|
|
|
|
|
raidMemberData = raidMemberData.rpartition("raidmember(")[2]
|
|
|
|
|
raidMemberData = raidMemberData.partition(")")[0]
|
|
|
|
|
self.printERROR(_("Unable to use active {typepart} member {part} "
|
|
|
|
|
raise InstallError([
|
|
|
|
|
_("Unable to use active {typepart} member {part} "
|
|
|
|
|
"for installation").format(
|
|
|
|
|
typepart="RAID",part=usingRaidMemberPart[0]))
|
|
|
|
|
self.printERROR(
|
|
|
|
|
typepart="RAID",part=usingRaidMemberPart[0]),
|
|
|
|
|
_("To use this partition, you have to stop RAID %s")%
|
|
|
|
|
raidMemberData)
|
|
|
|
|
self.printERROR(" mdadm -S %s"%raidMemberData)
|
|
|
|
|
return False
|
|
|
|
|
raidMemberData,
|
|
|
|
|
(" mdadm -S %s"%raidMemberData)])
|
|
|
|
|
|
|
|
|
|
# detect using LVM member disks
|
|
|
|
|
lvmMemberData = filter(lambda x: "lvmmember" in x[0],
|
|
|
|
@ -1395,15 +1389,14 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
lvmMemberData = lvmMemberData.partition(")")[0]
|
|
|
|
|
prop = getUdevDeviceInfo(name=lvmMemberData)
|
|
|
|
|
vgName = prop.get('DM_VG_NAME','')
|
|
|
|
|
self.printERROR(_("Unable to use active {typepart} member {part} "
|
|
|
|
|
raise InstallError([
|
|
|
|
|
_("Unable to use active {typepart} member {part} "
|
|
|
|
|
"for installation").format(
|
|
|
|
|
typepart="LVM",part=usingLvmMemberPart[0]))
|
|
|
|
|
self.printERROR(
|
|
|
|
|
typepart="LVM",part=usingLvmMemberPart[0]),
|
|
|
|
|
_("To use this partition, you have to remove LVM %s")%
|
|
|
|
|
lvmMemberData)
|
|
|
|
|
self.printERROR(" vgremove %s"%vgName)
|
|
|
|
|
self.printERROR(" pvremove %s"%usingLvmMemberPart[0])
|
|
|
|
|
return False
|
|
|
|
|
lvmMemberData,
|
|
|
|
|
(" vgremove %s"%vgName),
|
|
|
|
|
(" pvremove %s"%usingLvmMemberPart[0])])
|
|
|
|
|
|
|
|
|
|
srcMountPoints = map(lambda x:x['srcMountPoint'],listBinds)
|
|
|
|
|
destMountPoints = map(lambda x:x['destMountPoint'],listBinds)
|
|
|
|
@ -1411,23 +1404,23 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
if wrongBind:
|
|
|
|
|
incompBind = filter(lambda x:x[1]==wrongBind[0],
|
|
|
|
|
zip(srcMountPoints,destMountPoints))
|
|
|
|
|
self.printERROR(_("Source directory %(src)s already used "
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Source directory %(src)s already used "
|
|
|
|
|
"for binding '%(bindSrc)s' to '%(bindDst)s'")\
|
|
|
|
|
%{'src':wrongBind[0],
|
|
|
|
|
'bindSrc':incompBind[0][0],
|
|
|
|
|
'bindDst':incompBind[0][1]})
|
|
|
|
|
return False
|
|
|
|
|
# Check bind params
|
|
|
|
|
wrongBind = filter(lambda x:not x[0].startswith("/") or
|
|
|
|
|
not x[1].startswith("/") and
|
|
|
|
|
x[1] != "none",
|
|
|
|
|
zip(srcMountPoints,destMountPoints))
|
|
|
|
|
if wrongBind:
|
|
|
|
|
self.printERROR(_("Incorrect mount point (bind '%(bindSrc)s' to "\
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Incorrect mount point (bind '%(bindSrc)s' to "\
|
|
|
|
|
"'%(bindDst)s')")\
|
|
|
|
|
%{'bindSrc':wrongBind[0][0],
|
|
|
|
|
'bindDst':wrongBind[0][1]})
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Check '/' in start path
|
|
|
|
|
wrongMP = filter(lambda x: not x.startswith("/") and x!="none",
|
|
|
|
@ -1435,21 +1428,18 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
filter(lambda x: not x.startswith("/"),
|
|
|
|
|
map(lambda x:x['srcMountPoint'],listBinds))
|
|
|
|
|
if wrongMP:
|
|
|
|
|
self.printERROR(_("Incorrect mount point '%s'")%wrongMP[0])
|
|
|
|
|
return False
|
|
|
|
|
raise InstallError(_("Incorrect mount point '%s'")%wrongMP[0])
|
|
|
|
|
|
|
|
|
|
# detect duplicate devices
|
|
|
|
|
dupDevices = list(set(filter(lambda x:usedDevices.count(x)>1,
|
|
|
|
|
usedDevices)))
|
|
|
|
|
if dupDevices:
|
|
|
|
|
self.printERROR(_("Device '%s' is used twice")%dupDevices[0])
|
|
|
|
|
return False
|
|
|
|
|
raise InstallError(_("Device '%s' is used twice")%dupDevices[0])
|
|
|
|
|
# detect duplicate mount points
|
|
|
|
|
dupMP = list(set(filter(lambda x:usedMP.count(x)>1 and x != "none",
|
|
|
|
|
usedMP)))
|
|
|
|
|
if dupMP:
|
|
|
|
|
self.printERROR(_("Mount point '%s' is used twice")%dupMP[0])
|
|
|
|
|
return False
|
|
|
|
|
raise InstallError(_("Mount point '%s' is used twice")%dupMP[0])
|
|
|
|
|
|
|
|
|
|
rootdevs = map(lambda x:x['dev'],
|
|
|
|
|
filter(lambda x:"mountPoint" in x and \
|
|
|
|
@ -1502,10 +1492,10 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
mountPoint = ""
|
|
|
|
|
curMP = curDevMount[dev]
|
|
|
|
|
if curMP and ( curMP != mountPoint and isFormat or curMP == '/' ):
|
|
|
|
|
self.printERROR(_("Specified disk '%s' mounted to")\
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Specified disk '%s' mounted to")\
|
|
|
|
|
%dev + " " + _("'%s' in the current system")\
|
|
|
|
|
%curMP)
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
if mountPoint and mountPoint in dictMountDev and \
|
|
|
|
|
mountPoint != "swap":
|
|
|
|
@ -1543,7 +1533,7 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
# update install root dev
|
|
|
|
|
rootDev = filter(lambda x:x[1]['mountPoint']=='/',devMount.items())
|
|
|
|
|
if not rootDev:
|
|
|
|
|
self.printERROR(_("The root partition must be specified"))
|
|
|
|
|
raise InstallError(_("The root partition must be specified"))
|
|
|
|
|
return False
|
|
|
|
|
self.clVars.Set('os_install_root_dev',rootDev[0][0],True)
|
|
|
|
|
osInstallRootType = self.clVars.Get('os_install_root_type')
|
|
|
|
@ -1559,20 +1549,17 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
new_bind_dest = []
|
|
|
|
|
new_bind_src = []
|
|
|
|
|
if filter(lambda x: x != '/', usedMP):
|
|
|
|
|
self.printERROR(
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Installation to flash disk is not supported for "
|
|
|
|
|
"multipartition install"))
|
|
|
|
|
return False
|
|
|
|
|
if filter(lambda x:x['dev']!="none",listSwaps):
|
|
|
|
|
self.printERROR(
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Installation to flash disk is not "
|
|
|
|
|
"supported for swap disks"))
|
|
|
|
|
return False
|
|
|
|
|
if builderMode:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Installation to flash disk is not supported"
|
|
|
|
|
" in builder mode"))
|
|
|
|
|
return False
|
|
|
|
|
# receive substitution func. Discard all mp, exclude '/' for flash
|
|
|
|
|
if osInstallRootType != "flash":
|
|
|
|
|
substitution = lambda data,mp: data
|
|
|
|
@ -1602,11 +1589,9 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
('os_install_bind_path',new_bind_src),
|
|
|
|
|
('os_install_bind_mountpoint',new_bind_dest)))
|
|
|
|
|
if not self.clVars.Get('os_grub2_path'):
|
|
|
|
|
if not self.checkForLegacyGrub():
|
|
|
|
|
return False
|
|
|
|
|
self.checkForLegacyGrub()
|
|
|
|
|
else:
|
|
|
|
|
if not self.checkForGrub2():
|
|
|
|
|
return False
|
|
|
|
|
self.checkForGrub2()
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def checkForGrub2(self):
|
|
|
|
@ -1618,18 +1603,16 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
where="os_install_disk_mount", eq="/")
|
|
|
|
|
grubDiskType = bootDiskType or rootDiskType
|
|
|
|
|
if "lvm-raid" in grubDiskType:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Grub does not support booting from a RAID assembled from LVM.")
|
|
|
|
|
+ " " +
|
|
|
|
|
_("Try to use a separate /boot partition"))
|
|
|
|
|
return False
|
|
|
|
|
if grubDiskType.count("raid")>1:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Grub does not support booting from a RAID assembled "
|
|
|
|
|
"from another RAID.")
|
|
|
|
|
+ " " +
|
|
|
|
|
_("Try to use a separate /boot partition"))
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def checkForLegacyGrub(self):
|
|
|
|
@ -2429,7 +2412,21 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def installSystem(self, force=False, bootDisk=None, stdinReadPwd=False,
|
|
|
|
|
def checkInstallParam(self,disks=None,mbr=None,builder=None,typeDisk=None):
|
|
|
|
|
errors = []
|
|
|
|
|
if disks:
|
|
|
|
|
try:
|
|
|
|
|
self.setDisks(disks)
|
|
|
|
|
except InstallError,e:
|
|
|
|
|
errors.append('disks',e)
|
|
|
|
|
return errors
|
|
|
|
|
|
|
|
|
|
def installSystem(self,disks=None,mbr=None,builder=None,
|
|
|
|
|
typeDisk=None):
|
|
|
|
|
self.checkInstallParam(disks,mbr,builder,typeDisk)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def installSystem2(self, force=False, bootDisk=None, stdinReadPwd=False,
|
|
|
|
|
builder=False, flagSpinner=True, update=False):
|
|
|
|
|
"""install System by current variable enviroment"""
|
|
|
|
|
sourceDistr = None
|
|
|
|
|