|
|
|
@ -24,7 +24,7 @@ import traceback
|
|
|
|
|
from os.path import exists as pathexists,join as pathjoin,dirname
|
|
|
|
|
from cl_utils import runOsCommand,appendProgramToEnvFile, \
|
|
|
|
|
removeProgramToEnvFile,pathJoin, \
|
|
|
|
|
scanDirectory
|
|
|
|
|
scanDirectory,process
|
|
|
|
|
|
|
|
|
|
from cl_kernel import KernelConfig,InitRamFs
|
|
|
|
|
|
|
|
|
@ -58,7 +58,7 @@ from cl_distr import PartitionDistributive,DistributiveRepository,\
|
|
|
|
|
Spinner
|
|
|
|
|
from cl_string import tableReport
|
|
|
|
|
from time import sleep
|
|
|
|
|
from subprocess import Popen,PIPE
|
|
|
|
|
from subprocess import PIPE,STDOUT
|
|
|
|
|
from server.utils import dialogYesNo
|
|
|
|
|
from cl_migrate_users import migrate, currentUsers
|
|
|
|
|
from cl_utils import getUserPassword
|
|
|
|
@ -722,8 +722,8 @@ class cl_install(color_print):
|
|
|
|
|
sleep(1)
|
|
|
|
|
self.defaultPrint("\b\b \n")
|
|
|
|
|
|
|
|
|
|
def prepareBoot(self,targetDistr, grubDisk="0"):
|
|
|
|
|
self.installBootloader(targetDistr, grubDisk="0")
|
|
|
|
|
def prepareBoot(self,targetDistr):
|
|
|
|
|
self.installBootloader(targetDistr)
|
|
|
|
|
|
|
|
|
|
def getTargetDistributive(self,disk,fileSystem="reiserfs",isFormat=False,
|
|
|
|
|
systemId=None):
|
|
|
|
@ -782,7 +782,8 @@ class cl_install(color_print):
|
|
|
|
|
zip(self.clVars.Get('os_install_bind_dir'),
|
|
|
|
|
self.clVars.Get('os_install_bind_mountpoint'))))
|
|
|
|
|
|
|
|
|
|
def setInstallOptions(self, listDisks, listBinds, listSwaps, listUsers):
|
|
|
|
|
def setInstallOptions(self, listDisks, listBinds, listSwaps, listUsers,
|
|
|
|
|
mbrDisk):
|
|
|
|
|
"""Set data for installation partitions"""
|
|
|
|
|
if listUsers:
|
|
|
|
|
migrateUsers = list(set(listUsers))
|
|
|
|
@ -1061,6 +1062,21 @@ class cl_install(color_print):
|
|
|
|
|
disk['systemId'] = updateIdDict[disk['dev']]
|
|
|
|
|
else:
|
|
|
|
|
disk['systemId'] = None
|
|
|
|
|
bootDiskGrub = ""
|
|
|
|
|
if mbrDisk == "off":
|
|
|
|
|
self.clVars.Set('os_install_mbr',"",force=True)
|
|
|
|
|
elif mbrDisk:
|
|
|
|
|
listbootDiskGrub = map(lambda x: x[0],
|
|
|
|
|
filter(lambda x: "/dev/"+x[0]==mbrDisk,
|
|
|
|
|
zip(self.clVars.Get('os_device_dev'),
|
|
|
|
|
self.clVars.Get('os_device_map'))))
|
|
|
|
|
if filter(lambda x: "/dev/%s"%x == mbrDisk,
|
|
|
|
|
self.clVars.Get('os_device_dev')):
|
|
|
|
|
self.clVars.Set('os_install_mbr',mbrDisk.strip('/dev/'),
|
|
|
|
|
force=True)
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("Cann't found disk '%s'")%mbrDisk)
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def getDeviceByField(self,field,value, secondPrefix="os_disk"):
|
|
|
|
@ -1084,28 +1100,30 @@ class cl_install(color_print):
|
|
|
|
|
else:
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def installBootloader(self,target, grubDisk="0"):
|
|
|
|
|
def installBootloader(self,target):
|
|
|
|
|
"""Install boot loader
|
|
|
|
|
|
|
|
|
|
Perform grub installation to disk, which has root partition
|
|
|
|
|
"""
|
|
|
|
|
pipe = Popen(["/sbin/grub",
|
|
|
|
|
grubProcess = process("/sbin/grub",
|
|
|
|
|
"--device-map=%s/boot/grub/device.map"%target.getDirectory(),
|
|
|
|
|
"--batch"], stdin=PIPE, stdout=PIPE,stderr=PIPE)
|
|
|
|
|
"--batch")
|
|
|
|
|
bootDisk = self.getFieldByField("grub","mount","/boot",
|
|
|
|
|
secondPrefix="os_install_disk")
|
|
|
|
|
if not bootDisk:
|
|
|
|
|
bootDisk = self.getFieldByField("grub","mount","/",
|
|
|
|
|
secondPrefix="os_install_disk")
|
|
|
|
|
pipe.stdin.write("root (hd%s)\n" %bootDisk)
|
|
|
|
|
# TODO: change hd0 for bootloader install to other disks
|
|
|
|
|
# may be another parameters
|
|
|
|
|
pipe.stdin.write("setup (hd%s)\n"%grubDisk)
|
|
|
|
|
pipe.stdin.write("quit\n")
|
|
|
|
|
pipe.stdin.close()
|
|
|
|
|
# TODO: break if command is hang (KeyboardInterrupt is supported)
|
|
|
|
|
if pipe.wait() != 0:
|
|
|
|
|
raise DistributiveError("Cann't install bootloader")
|
|
|
|
|
mbrDisk = self.clVars.Get('os_install_mbr')
|
|
|
|
|
mbrDiskNum = filter(lambda x:x[0]==mbrDisk,
|
|
|
|
|
zip(self.clVars.Get('os_device_dev'),
|
|
|
|
|
self.clVars.Get('os_device_map')))
|
|
|
|
|
if not mbrDiskNum:
|
|
|
|
|
raise DistributiveError(_("Cann't determine mbr disk"))
|
|
|
|
|
grubProcess.write("root (hd%s)\n" %bootDisk)
|
|
|
|
|
grubProcess.write("setup (hd%d)\n"%mbrDiskNum[0][1])
|
|
|
|
|
grubProcess.write("quit\n")
|
|
|
|
|
if grubProcess.failed():
|
|
|
|
|
raise DistributiveError(_("Cann't install bootloader"))
|
|
|
|
|
|
|
|
|
|
def generateTableData(self):
|
|
|
|
|
"""Get data from print table"""
|
|
|
|
@ -1399,16 +1417,6 @@ class cl_install(color_print):
|
|
|
|
|
#waittime = 3
|
|
|
|
|
#self.printSUCCESS(_("Installation will start pass %d seconds.")
|
|
|
|
|
#%waittime)
|
|
|
|
|
bootDiskGrub = ""
|
|
|
|
|
if bootDisk:
|
|
|
|
|
listbootDiskGrub = map(lambda x: x[1],
|
|
|
|
|
filter(lambda x: "/dev/"+x[0]==bootDisk,
|
|
|
|
|
zip(self.clVars.Get('os_device_dev'),
|
|
|
|
|
self.clVars.Get('os_device_map'))))
|
|
|
|
|
if listbootDiskGrub:
|
|
|
|
|
bootDiskGrub=listbootDiskGrub[0]
|
|
|
|
|
else:
|
|
|
|
|
raise InstallError(_("Cann't found disk %s")%bootDisk)
|
|
|
|
|
self.printInfo(sourceDistr,targetDistr)
|
|
|
|
|
targetDistr = self.getTargetDistributive(rootPartdev,
|
|
|
|
|
fileSystem=rootPartFileSystem,
|
|
|
|
@ -1525,10 +1533,8 @@ the system") + " (yes/no)"
|
|
|
|
|
if not objMigrate.migrate(addUsers,changePwdUsers,migrateUsers):
|
|
|
|
|
raise InstallError(_("Can not migrate users to new system"))
|
|
|
|
|
# change boot config
|
|
|
|
|
self.printMessageForTest(_("Preparing system for reboot"))
|
|
|
|
|
if bootDiskGrub:
|
|
|
|
|
self.prepareBoot(targetDistr, bootDiskGrub)
|
|
|
|
|
else:
|
|
|
|
|
if self.clVars.Get('os_install_mbr'):
|
|
|
|
|
self.printMessageForTest(_("Preparing system for reboot"))
|
|
|
|
|
self.prepareBoot(targetDistr)
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
# optimize initrd
|
|
|
|
|