|
|
|
@ -27,6 +27,7 @@ from cl_utils import runOsCommand,appendProgramToEnvFile, \
|
|
|
|
|
scanDirectory,process,getTupleVersion, \
|
|
|
|
|
detectDeviceForPartition,listDirectory, \
|
|
|
|
|
cmpVersion
|
|
|
|
|
from cl_vars_share import varsShare
|
|
|
|
|
|
|
|
|
|
from cl_kernel_utils import KernelConfig,InitRamFs
|
|
|
|
|
|
|
|
|
@ -790,18 +791,6 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
self.clVars.importInstall()
|
|
|
|
|
self.clVars.flIniFile()
|
|
|
|
|
|
|
|
|
|
def applyTemplatesLive(self):
|
|
|
|
|
"""Apply templates for root of system."""
|
|
|
|
|
#self.clVars.Set("cl_root_path","/", True)
|
|
|
|
|
self.clVars.Set("cl_chroot_path","/", True)
|
|
|
|
|
self.clTempl = template(self.clVars,cltFilter=False)
|
|
|
|
|
dirsFiles = self.clTempl.applyTemplates()
|
|
|
|
|
if self.clTempl.getError():
|
|
|
|
|
self.printERROR(self.clTempl.getError())
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return dirsFiles
|
|
|
|
|
|
|
|
|
|
def cmpInstallVersion(self):
|
|
|
|
|
"""Compare current and install version(build)
|
|
|
|
|
|
|
|
|
@ -940,12 +929,23 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
else:
|
|
|
|
|
self.printWARNING(_("No update available."))
|
|
|
|
|
|
|
|
|
|
def canInstallGrub2(self,target):
|
|
|
|
|
"""Check that system has grub2 in current and installed system"""
|
|
|
|
|
if self.clVars.Get('os_grub2_path'):
|
|
|
|
|
return bool(
|
|
|
|
|
filter(lambda x:x.startswith('grub-1.99'),
|
|
|
|
|
listDirectory('/var/db/pkg/sys-boot')))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def prepareBoot(self,targetDistr):
|
|
|
|
|
"""Prepare system for boot"""
|
|
|
|
|
if self.clVars.Get('os_install_root_type') == "flash":
|
|
|
|
|
self.installSyslinuxBootloader(targetDistr)
|
|
|
|
|
else:
|
|
|
|
|
self.installGrubBootloader(targetDistr)
|
|
|
|
|
if self.canInstallGrub2(targetDistr):
|
|
|
|
|
self.installGrub2Bootloader(targetDistr)
|
|
|
|
|
else:
|
|
|
|
|
self.installLegacyGrubBootloader(targetDistr)
|
|
|
|
|
|
|
|
|
|
def getTargetDistributive(self,disk,fileSystem="reiserfs",isFormat=False,
|
|
|
|
|
systemId=None,buildermode=False):
|
|
|
|
@ -1041,10 +1041,24 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
self.clTempl.closeFiles()
|
|
|
|
|
self.clTempl = None
|
|
|
|
|
|
|
|
|
|
def applyTemplatesLive(self):
|
|
|
|
|
"""Apply templates for root of system."""
|
|
|
|
|
#self.clVars.Set("cl_root_path","/", True)
|
|
|
|
|
self.clVars.Set("cl_chroot_path","/", True)
|
|
|
|
|
self.clVars.Set("cl_chroot_grub","/", True)
|
|
|
|
|
self.clTempl = template(self.clVars,cltFilter=False)
|
|
|
|
|
dirsFiles = self.clTempl.applyTemplates()
|
|
|
|
|
if self.clTempl.getError():
|
|
|
|
|
self.printERROR(self.clTempl.getError())
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return dirsFiles
|
|
|
|
|
|
|
|
|
|
def applyTemplatesFlash(self,directory):
|
|
|
|
|
"""Apply templates for root of system."""
|
|
|
|
|
#self.clVars.Set("cl_root_path",directory, True)
|
|
|
|
|
self.clVars.Set("cl_chroot_path","/", True)
|
|
|
|
|
self.clVars.Set("cl_chroot_grub","/", True)
|
|
|
|
|
self.clVars.Set("cl_root_path",directory, True)
|
|
|
|
|
self.clTempl = template(self.clVars,cltObj=False)
|
|
|
|
|
dirsFiles = self.clTempl.applyTemplates()
|
|
|
|
@ -1055,7 +1069,6 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
|
|
|
|
|
def applyTemplates(self,directory):
|
|
|
|
|
"""Apply templates for root of system."""
|
|
|
|
|
#self.clVars.Set("cl_root_path",directory, True)
|
|
|
|
|
self.clVars.Set("cl_chroot_path",directory, True)
|
|
|
|
|
clTemplateCltPath = \
|
|
|
|
|
filter(lambda x:path.exists(x),
|
|
|
|
@ -1474,30 +1487,96 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
# is partition active
|
|
|
|
|
return self.setActivePartition(self.clVars.Get('os_install_root_dev'))
|
|
|
|
|
|
|
|
|
|
def installGrubBootloader(self,target):
|
|
|
|
|
def varSelect(self,selField,where="os_disk_dev",eq=""):
|
|
|
|
|
"""Select value from os_disk/device matrix"""
|
|
|
|
|
res = filter(lambda x: x[1] == eq,
|
|
|
|
|
zip(self.clVars.Get(selField),
|
|
|
|
|
self.clVars.Get(where))) or\
|
|
|
|
|
[("","")]
|
|
|
|
|
return res[0][0]
|
|
|
|
|
|
|
|
|
|
def getPartitionForParted(self,partition):
|
|
|
|
|
"""Get partition info for parted exectution"""
|
|
|
|
|
# get disk num and partitin num
|
|
|
|
|
bootMap = \
|
|
|
|
|
self.varSelect("os_disk_grub",where="os_disk_dev",eq=partition)
|
|
|
|
|
# check valid numbers
|
|
|
|
|
deviceNumber,op,partitionNumber = bootMap.partition(',')
|
|
|
|
|
if not deviceNumber.isdigit() or \
|
|
|
|
|
not partitionNumber.isdigit():
|
|
|
|
|
return (False,False)
|
|
|
|
|
# get partition number
|
|
|
|
|
partitionNumber = int(partitionNumber)+1
|
|
|
|
|
# get device name
|
|
|
|
|
deviceName = self.varSelect("os_device_dev",where="os_device_map",
|
|
|
|
|
eq=int(deviceNumber))
|
|
|
|
|
if deviceName:
|
|
|
|
|
return ("/dev/%s"%deviceName,partitionNumber)
|
|
|
|
|
return (False,False)
|
|
|
|
|
|
|
|
|
|
def setBiosGrubForBootPartition(self):
|
|
|
|
|
"""Set bios_grub flag for boot partition in gpt"""
|
|
|
|
|
for bootPath in ("/boot","/"):
|
|
|
|
|
# get grub disk by mount point
|
|
|
|
|
bootPart = self.varSelect(
|
|
|
|
|
"os_disk_part",where="os_install_disk_mount",eq=bootPath)
|
|
|
|
|
if bootPart:
|
|
|
|
|
if bootPart == "gpt":
|
|
|
|
|
bootPart = self.varSelect(
|
|
|
|
|
"os_disk_dev",where="os_install_disk_mount",eq=bootPath)
|
|
|
|
|
deviceName,partitionNumber = \
|
|
|
|
|
self.getPartitionForParted(bootPart)
|
|
|
|
|
cmdParted = varsShare().getProgPath('/usr/sbin/parted')
|
|
|
|
|
if not cmdParted:
|
|
|
|
|
return False
|
|
|
|
|
partedProcess = process(cmdParted,deviceName,
|
|
|
|
|
"set",str(partitionNumber),"bios_grub","on")
|
|
|
|
|
return partedProcess.success()
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def installGrub2Bootloader(self,target):
|
|
|
|
|
"""Install grub2 boot loader"""
|
|
|
|
|
cmdGrubInstall = self.clVars.Get('os_grub2_path')
|
|
|
|
|
if not self.setBiosGrubForBootPartition():
|
|
|
|
|
raise DistributiveError(
|
|
|
|
|
_("Cann't set bios_grub flag for boot partition"))
|
|
|
|
|
if not cmdGrubInstall:
|
|
|
|
|
raise DistributiveError(_("Cann't install bootloader"))
|
|
|
|
|
|
|
|
|
|
mbrDisk = self.clVars.Get('os_install_mbr')
|
|
|
|
|
grubProcess = process(cmdGrubInstall,
|
|
|
|
|
"--boot-directory=%s"%target.getBootDirectory(),
|
|
|
|
|
"/dev/%s"%mbrDisk)
|
|
|
|
|
if grubProcess.failed():
|
|
|
|
|
raise DistributiveError(_("Cann't install bootloader"))
|
|
|
|
|
|
|
|
|
|
def installLegacyGrubBootloader(self,target):
|
|
|
|
|
"""Install boot loader
|
|
|
|
|
|
|
|
|
|
Perform grub installation to disk, which has root partition
|
|
|
|
|
"""
|
|
|
|
|
if not path.exists('/sbin/grub'):
|
|
|
|
|
cmdGrub = varsShare().getProgPath('/sbin/grub')
|
|
|
|
|
if not cmdGrub:
|
|
|
|
|
raise DistributiveError(_("Cann't install bootloader"))
|
|
|
|
|
grubProcess = process("/sbin/grub",
|
|
|
|
|
grubProcess = process(cmdGrub,
|
|
|
|
|
"--device-map=%s/boot/grub/device.map"%target.getDirectory(),
|
|
|
|
|
"--batch",stderr=STDOUT)
|
|
|
|
|
bootDisk = self.getFieldByField("grub","mount","/boot",
|
|
|
|
|
secondPrefix="os_install_disk")
|
|
|
|
|
if not bootDisk:
|
|
|
|
|
bootDisk = self.getFieldByField("grub","mount","/",
|
|
|
|
|
secondPrefix="os_install_disk")
|
|
|
|
|
for bootPath in ("/boot","/"):
|
|
|
|
|
# get grub disk by mount point
|
|
|
|
|
bootDisk = self.varSelect(
|
|
|
|
|
"os_disk_grub",where="os_install_disk_mount",eq=bootPath)
|
|
|
|
|
if bootDisk:
|
|
|
|
|
break
|
|
|
|
|
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')))
|
|
|
|
|
mbrDiskNum = self.varSelect(
|
|
|
|
|
"os_device_map",where="os_device_dev",eq=mbrDisk)
|
|
|
|
|
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")
|
|
|
|
|
for line in ("root (hd%s)"%bootDisk,
|
|
|
|
|
"setup (hd%d)"%mbrDiskNum,
|
|
|
|
|
"quit"):
|
|
|
|
|
grubProcess.write("%s\n"%line)
|
|
|
|
|
if grubProcess.failed():
|
|
|
|
|
raise DistributiveError(_("Cann't install bootloader"))
|
|
|
|
|
|
|
|
|
@ -1843,37 +1922,19 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
"""Clean initrd from needless modules"""
|
|
|
|
|
# get path to initrd and initrd-install in new system
|
|
|
|
|
# (/boot/initramfs-...-install,/boot/initramfs-...)
|
|
|
|
|
initrdPath = path.join(self.clVars.Get('cl_chroot_path'),
|
|
|
|
|
'boot',self.clVars.Get('os_install_initrd'))
|
|
|
|
|
initrdInstallPath = path.join(self.clVars.Get('cl_chroot_path'),
|
|
|
|
|
'boot',self.clVars.Get('os_install_initrd_install'))
|
|
|
|
|
# section which must contains equealent modules and kernel buildins
|
|
|
|
|
importantSections = ['File systems','Pseudo filesystems',
|
|
|
|
|
'CDROM.*Filesystems', 'DOS.*Filesystems',
|
|
|
|
|
'SCSI Transport']
|
|
|
|
|
curConfig = dict(KernelConfig().getSectionParams(*importantSections))
|
|
|
|
|
if not self.clVars.Get('os_install_kernel_config'):
|
|
|
|
|
copy2(initrdInstallPath,initrdPath);
|
|
|
|
|
return True
|
|
|
|
|
newConfig = KernelConfig( configFile=
|
|
|
|
|
path.join(self.clVars.Get('cl_chroot_path'),
|
|
|
|
|
'boot',self.clVars.Get('os_install_kernel_config')))
|
|
|
|
|
newConfig = newConfig.getSectionParams(*importantSections)
|
|
|
|
|
conflictOptions = filter(lambda x: x[1]=="M" and
|
|
|
|
|
x[0] in curConfig and
|
|
|
|
|
curConfig[x[0]]=="Y",
|
|
|
|
|
newConfig)
|
|
|
|
|
if conflictOptions:
|
|
|
|
|
copy2(initrdInstallPath,initrdPath);
|
|
|
|
|
return True
|
|
|
|
|
hr_video = {'nvidia':'nouveau',
|
|
|
|
|
'ati':'radeon',
|
|
|
|
|
'intel':'intel'}.get(self.clVars.Get('hr_video'),"")
|
|
|
|
|
x11_video_drv = self.clVars.Get('os_install_x11_video_drv')
|
|
|
|
|
if x11_video_drv == hr_video:
|
|
|
|
|
x11_video_drv = ""
|
|
|
|
|
return InitRamFs(initrdInstallPath).cleanInitRamFs(initrdPath,
|
|
|
|
|
x11_video_drv)
|
|
|
|
|
chrootPath = path.join(self.clVars.Get('cl_chroot_path'),'boot')
|
|
|
|
|
chrootGrub = path.join(self.clVars.Get('cl_chroot_grub'),'boot')
|
|
|
|
|
initrdPath = path.join(chrootPath,self.clVars.Get('os_install_initrd'))
|
|
|
|
|
initrdInstallPath = path.join(chrootPath,
|
|
|
|
|
self.clVars.Get('os_install_initrd_install'))
|
|
|
|
|
copy2(initrdInstallPath,initrdPath);
|
|
|
|
|
# if chrootGrub and chrootPath different then it is scratch mode
|
|
|
|
|
if chrootGrub != chrootPath:
|
|
|
|
|
# copy initrd to scratch device
|
|
|
|
|
initrdPathScratch = path.join(chrootGrub,
|
|
|
|
|
self.clVars.Get('os_install_initrd'))
|
|
|
|
|
copy2(initrdInstallPath,initrdPathScratch);
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def afterCopyHDDinstall(self,targetDistr, addUsers, changePwdUsers,
|
|
|
|
|
migrateUsers):
|
|
|
|
@ -1894,6 +1955,13 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
fileCpy.performCopy('/etc')
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
# optimize initrd
|
|
|
|
|
self.clVars.Set("cl_chroot_path",targetDistr.getDirectory(), True)
|
|
|
|
|
self.clVars.Set("cl_chroot_grub",
|
|
|
|
|
targetDistr.getBootDirectory()[:-4], True)
|
|
|
|
|
self.printMessageForTest(_("Creating new initrd file"))
|
|
|
|
|
self.printByResult(self.cleanInitrd())
|
|
|
|
|
|
|
|
|
|
# join templates
|
|
|
|
|
self.printMessageForTest(_("Updating config"))
|
|
|
|
|
self.applyTemplates(targetDistr.getDirectory())
|
|
|
|
@ -1901,11 +1969,6 @@ class cl_install(color_print, SignalInterrupt):
|
|
|
|
|
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|
|
|
|
|
|
# optimize initrd
|
|
|
|
|
if self.clVars.Get('os_install_root_type') != "usb-hdd":
|
|
|
|
|
self.printMessageForTest(_("Creating new initrd file"))
|
|
|
|
|
self.printByResult(self.cleanInitrd())
|
|
|
|
|
|
|
|
|
|
self.printMessageForTest(_("Post-install configuration"))
|
|
|
|
|
targetDistr.postinstallMountBind()
|
|
|
|
|
self.printByResult(True)
|
|
|
|
|