|
|
|
@ -29,7 +29,7 @@ from cl_utils import runOsCommand,appendProgramToEnvFile, \
|
|
|
|
|
cmpVersion,STDOUT,getUdevDeviceInfo, \
|
|
|
|
|
getLvmPartitions,getInstalledVideo, \
|
|
|
|
|
getSupportArch, refreshLVM, refreshUdev, \
|
|
|
|
|
isPkgInstalled
|
|
|
|
|
isPkgInstalled, checkUtils, countPartitions
|
|
|
|
|
from cl_vars_share import varsShare
|
|
|
|
|
|
|
|
|
|
from cl_kernel_utils import KernelConfig,InitRamFs
|
|
|
|
@ -899,7 +899,8 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
pxe = clGet('os_install_pxe')=='on'
|
|
|
|
|
pxeflash = flash or pxe
|
|
|
|
|
usbhdd = clGet('os_install_root_type')=="usb-hdd"
|
|
|
|
|
hdd = clGet('os_install_root_type')=="hdd"
|
|
|
|
|
hdd = clGet('os_install_root_type')=="hdd" and not pxe
|
|
|
|
|
x11print = bool(clGet('os_install_x11_video_drv'))
|
|
|
|
|
if not flash:
|
|
|
|
|
musers = ", ".join(set(clGet('cl_migrate_user'))-set(['root'])) \
|
|
|
|
|
or _("none")
|
|
|
|
@ -939,8 +940,9 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
(_("Number of processors"),clGet('hr_cpu_num'),hdd),
|
|
|
|
|
(_("Videocard"),clGet('hr_video_name'),hdd),
|
|
|
|
|
(_("{0} video driver").format("Xorg"),
|
|
|
|
|
clGet('os_install_x11_video_drv'),hdd),
|
|
|
|
|
(_("Screen resolution"),clGet('os_install_x11_resolution'),hdd)
|
|
|
|
|
clGet('os_install_x11_video_drv'),hdd and x11print),
|
|
|
|
|
(_("Screen resolution"),clGet('os_install_x11_resolution'),
|
|
|
|
|
hdd and x11print)
|
|
|
|
|
],
|
|
|
|
|
[(_("Network devices"),not pxeflash),
|
|
|
|
|
(self.printNetworkTables,None,True)
|
|
|
|
@ -948,11 +950,12 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
[(_("Routes"),not pxeflash),
|
|
|
|
|
(self.printRouteTables,None,True)
|
|
|
|
|
],
|
|
|
|
|
[(_("Location"),not pxe),
|
|
|
|
|
(_("Master boot record")+" (MBR)",mbrdisk,True),
|
|
|
|
|
[(_("Location"),True),
|
|
|
|
|
(_("Master boot record")+" (MBR)",mbrdisk,not pxe),
|
|
|
|
|
(_("PXE installation directory"),clGet('os_install_pxe_path'),pxe),
|
|
|
|
|
(self.printLocationTables,None,True)
|
|
|
|
|
],
|
|
|
|
|
[(_("Perform pre-install checkups"),True)]
|
|
|
|
|
[(_("Perform pre-install checkups"),not pxe)]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
for section in printData:
|
|
|
|
@ -1781,33 +1784,68 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def setActivePartition(self,partition):
|
|
|
|
|
"""TODO: don't work with GPT. Don't work must be rewrite!!!!!"""
|
|
|
|
|
reActive = re.compile('^%s\s*[*]'%partition)
|
|
|
|
|
device = filter(lambda x:x in partition,
|
|
|
|
|
self.clVars.Get('os_device_dev'))
|
|
|
|
|
if not device:
|
|
|
|
|
raise DistributiveError(_("Failed to find the parent device"))
|
|
|
|
|
device = device[0]
|
|
|
|
|
|
|
|
|
|
fdiskProcess = process("/sbin/fdisk","-l",device)
|
|
|
|
|
if fdiskProcess.failed():
|
|
|
|
|
raise DistributiveError(_("Failed to get device information\n%s")%
|
|
|
|
|
fdiskProcess.read())
|
|
|
|
|
if not filter(reActive.search,fdiskProcess):
|
|
|
|
|
grubDisk = self.getFieldByField("grub","mount","/",
|
|
|
|
|
secondPrefix="os_install_disk")
|
|
|
|
|
if grubDisk and grubDisk.rpartition(',')[2].isdigit():
|
|
|
|
|
fdiskProcess = process("/sbin/fdisk", device)
|
|
|
|
|
fdiskProcess.write("a\n%d\nw\n"%
|
|
|
|
|
(int(grubDisk.rpartition(',')[2])+1))
|
|
|
|
|
if fdiskProcess.success():
|
|
|
|
|
return True
|
|
|
|
|
if filter(reActive.search,process("/sbin/fdisk",
|
|
|
|
|
"-l",device)):
|
|
|
|
|
return True
|
|
|
|
|
raise DistributiveError(_("Failed to set the active partition"))
|
|
|
|
|
else:
|
|
|
|
|
"""Change partition id, specified by systemid"""
|
|
|
|
|
deviceName = detectDeviceForPartition(partition)
|
|
|
|
|
if deviceName is None:
|
|
|
|
|
raise DistributiveError(
|
|
|
|
|
_("Failed to determine the parent device for %s")%partition)
|
|
|
|
|
# device hasn't any partition
|
|
|
|
|
elif deviceName == "":
|
|
|
|
|
return True
|
|
|
|
|
fdiskProg, gdiskProg, partedProg = checkUtils('/sbin/fdisk',
|
|
|
|
|
'/usr/sbin/gdisk','/usr/sbin/parted')
|
|
|
|
|
partitionNumber = \
|
|
|
|
|
getUdevDeviceInfo(name=partition).get('ID_PART_ENTRY_NUMBER','')
|
|
|
|
|
devicePartitionCount = countPartitions(deviceName)
|
|
|
|
|
if deviceName and not partitionNumber:
|
|
|
|
|
raise DistributiveError(
|
|
|
|
|
_("Failed to determine the partition number for %s")%partition)
|
|
|
|
|
bootFlag = "boot" if parttable == "dos" else "legacy_boot"
|
|
|
|
|
parted = process(partedProg, "-m",deviceName,"print")
|
|
|
|
|
DEVICENUM,FLAGS = 0,6
|
|
|
|
|
changeActive = \
|
|
|
|
|
map(lambda x:x[DEVICENUM],
|
|
|
|
|
filter(lambda x:x[DEVICENUM] != partitionNumber and \
|
|
|
|
|
bootFlag in x[FLAGS].strip(';').split(', ') or \
|
|
|
|
|
x[DEVICENUM] == partitionNumber and \
|
|
|
|
|
not bootFlag in x[FLAGS].strip(';').split(', '),
|
|
|
|
|
filter(lambda x:len(x)>=7,
|
|
|
|
|
map(lambda x:x.split(':'),
|
|
|
|
|
parted.readlines()[2:]))))
|
|
|
|
|
if parttable == "dos":
|
|
|
|
|
fdisk = process(fdiskProg,deviceName,stderr=STDOUT)
|
|
|
|
|
pipe = Popen([fdiskProg,deviceName],
|
|
|
|
|
stdin=PIPE, stdout=PIPE,stderr=PIPE)
|
|
|
|
|
if changeActive:
|
|
|
|
|
if devicePartitionCount > 1:
|
|
|
|
|
for partnum in changeActive:
|
|
|
|
|
pipe.stdin.write("a\n%s\n",partnum)
|
|
|
|
|
pipe.stdin.write("w\n")
|
|
|
|
|
else:
|
|
|
|
|
pipe.stdin.write("a\nw\n")
|
|
|
|
|
pipe.stdin.close()
|
|
|
|
|
pipe.wait()
|
|
|
|
|
elif parttable == "gpt":
|
|
|
|
|
fdisk = process(gdiskProg,deviceName,stderr=STDOUT)
|
|
|
|
|
pipe = Popen([gdiskProg,deviceName],
|
|
|
|
|
stdin=PIPE, stdout=PIPE,stderr=PIPE)
|
|
|
|
|
if changeActive:
|
|
|
|
|
if devicePartitionCount > 1:
|
|
|
|
|
pipe.stdin.write("x\n")
|
|
|
|
|
for partnum in changeActive:
|
|
|
|
|
pipe.stdin.write("a\n%s\n2\n\n",partnum)
|
|
|
|
|
pipe.stdin.write("w\n")
|
|
|
|
|
else:
|
|
|
|
|
pipe.stdin.write("x\na\n2\n\nw\n")
|
|
|
|
|
pipe.stdin.close()
|
|
|
|
|
pipe.wait()
|
|
|
|
|
for waittime in (0.1,0.2,0.5,1,2,4):
|
|
|
|
|
if path.exists(dev):
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
sleep(waittime)
|
|
|
|
|
raise InstallError(
|
|
|
|
|
_("Failed to found partition %s after changing the activity")%dev)
|
|
|
|
|
|
|
|
|
|
def installSyslinuxBootloader(self,target):
|
|
|
|
|
"""Install boot loader by syslinux
|
|
|
|
@ -1881,6 +1919,13 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
|
|
|
|
|
def installGrub2Bootloader(self,target):
|
|
|
|
|
"""Install grub2 boot loader"""
|
|
|
|
|
for bootPath in ("/boot","/"):
|
|
|
|
|
# get grub disk by mount point
|
|
|
|
|
bootDisk = self.varSelect(
|
|
|
|
|
"os_disk_dev",where="os_install_disk_mount",eq=bootPath)
|
|
|
|
|
if bootDisk:
|
|
|
|
|
self.setActivePartition(bootDisk)
|
|
|
|
|
break
|
|
|
|
|
cmdGrubInstall = self.clVars.Get('os_grub2_path')
|
|
|
|
|
#if not self.setBiosGrubForBootPartition():
|
|
|
|
|
# raise DistributiveError(
|
|
|
|
@ -1912,6 +1957,8 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
bootDisk = self.varSelect(
|
|
|
|
|
"os_disk_grub",where="os_install_disk_mount",eq=bootPath)
|
|
|
|
|
if bootDisk:
|
|
|
|
|
self.setActivePartition(self.varSelect(
|
|
|
|
|
"os_disk_dev",where="os_install_disk_mount",eq=bootPath))
|
|
|
|
|
break
|
|
|
|
|
mbrDisk = self.clVars.Get('os_install_mbr')
|
|
|
|
|
mbrDiskNum = self.varSelect(
|
|
|
|
|