Added install variables

netsetup
Mike Hiretsky 14 years ago
parent 80acce2fed
commit 1b1af9ff57

@ -43,7 +43,7 @@ class DistributiveRepository:
'march':"|".join(marches),
'ext':"|".join(extensiton)
}, re.X)
def __init__(self,directories):
def __init__(self,directories=[]):
self.dirs = directories
def _getAvailableDistributives(self,system=None,shortname=None,march=None,
@ -74,7 +74,7 @@ class DistributiveRepository:
reduce(lambda x,y: x + y,
allFiles, []))
def _getDistributiveByFile(self,filename):
def getDistributiveByFile(self,filename):
"""Get Distributive object by filename"""
# MAGIC_COMPRESS 0x000004 Check inside compressed files
tf = typeFile(magic=0x4)
@ -90,7 +90,6 @@ class DistributiveRepository:
raise DistributiveError("Wrong distributive '%s':\n%s"%
(filename,ftype))
def getBestDistributive(self,system=None,shortname=None,march=None,
version=None):
"""Get the actualest distributive"""

@ -153,6 +153,23 @@ class fillVars(object, glob_attr):
"""List uudi for partition devices"""
return self.getAttributeFromHash('os_disk_hash','uuid')
def isFstabMount(self,path):
"""В случае описания монитрования выдает другой примонтированный путь"""
absPath = os.path.abspath(path)
# convert fstab to
# [['/dev/sda3', '/', '', 'reiserfs', 'noatime', '', '', '0', '2\n'],
# ['/dev/sda5', '/var/calculate', 'reiserfs', 'noatime', '0', '0\n']]
listFstab = map(lambda x: filter(lambda x: x,
x.replace('\t',' ').split(' ')),
filter(lambda x: not x.startswith('#') and x.strip(),
open("/etc/fstab")))
# get mount point or device or dir
return filter(lambda x: x!=absPath,
reduce(lambda x,y: y,
filter(lambda x: absPath in x and x[1] != "none",
map(lambda x: [x[0], x[1]],
listFstab)),[""]))[0]
def get_os_disk_install(self):
"""List mounted points for installed system"""
rootdev = self.Get('os_root_dev')
@ -164,7 +181,7 @@ class fillVars(object, glob_attr):
"swap" in disk_hash[disk]['format']:
return "swap"
else:
mount_point = isMount(disk)
mount_point = self.isFstabMount(disk)
if mount_point == "/":
return ""
else:
@ -181,7 +198,7 @@ class fillVars(object, glob_attr):
return "swap"
else:
return ""
return map(lambda x: isMount(x) or isSwap(x) or "",
return map(lambda x: self.isFstabMount(x) or isSwap(x) or "",
sorted(self.Get('os_disk_hash').keys()))
def get_os_disk_format(self):
@ -241,6 +258,7 @@ class fillVars(object, glob_attr):
(x[0],x[1],x[2]),devicesForFstab[:1]))
otherLines ="\n".join(map(lambda x: "%s\t%s\t%s\tnoatime\t0 0" %
(x[0],x[1],x[2]),devicesForFstab[1:]))
# TODO: getting all bind mount points
return "\n".join([rootLine,otherLines])
def get_os_net_config_info(self):
@ -254,7 +272,7 @@ class fillVars(object, glob_attr):
zip(self.Get('os_disk_dev'),
self.Get('os_disk_install')))))
def get_os_linux_system(self):
def get_os_install_linux_system(self):
"""Get linux system (server or desktop)"""
mapNameSystem = {'CDS':'server',
'CLD':'desktop',
@ -263,7 +281,7 @@ class fillVars(object, glob_attr):
'CLS':'desktop',
'CSS':'server'
}
shortName = self.Get('os_linux_shortname')
shortName = self.Get('os_install_linux_shortname')
if shortName in mapNameSystem:
return mapNameSystem[shortName]
else:
@ -321,18 +339,56 @@ class fillVars(object, glob_attr):
distRep = DistributiveRepository(self.Get('cl_image_path'))
return distRep.getBestDistributive(
march=self.Get('os_arch_machine'),
shortname=self.Get('os_linux_shortname').lower()) or ""
shortname=self.Get('os_install_linux_shortname').lower()) or ""
def get_os_install_linux_shortname(self):
"""Shortname of installation os"""
return self.Get('os_linux_shortname')
def get_os_linux_ver(self):
def get_os_install_linux_ver(self):
"""Linux version of installation os"""
imagename = self.Get('cl_image')
res = DistributiveRepository.reDistName.search(imagename)
if res:
return res.groupdict()['ver']
else:
return ""
if self.Get('os_install_linux_shortname') == \
self.Get('os_linux_shortname'):
return self.Get('os_linux_ver')
return ""
def get_cl_pkgdir_path(self):
return "/var/calculate/remote/packages/%s/%s/%s" % (
self.Get('os_linux_shortname'),
self.Get('os_linux_ver'),
self.Get('os_arch_machine'))
def get_os_install_linux_subname(self):
"""Subname of installation os"""
linuxShortName = self.Get("os_install_linux_shortname")
if linuxShortName:
dictLinuxSubName = {"CLD":"KDE", "CLDX":"XFCE", "CLDG":"GNOME"}
if linuxShortName in dictLinuxSubName.keys():
return dictLinuxSubName[linuxShortName]
else:
return ""
else:
return ""
def get_os_install_linux_name(self):
"""Name of installation os"""
linuxShortName = self.Get("os_install_linux_shortname")
if linuxShortName:
dictLinuxName = {"CLD":"Calculate Linux Desktop",
"CLDX":"Calculate Linux Desktop",
"CLDG":"Calculate Linux Desktop",
"CDS":"Calculate Directory Server",
"CLS":"Calculate Linux Scratch",
"CSS":"Calculate Scratch Server",
"Gentoo":"Gentoo"}
if linuxShortName in dictLinuxName.keys():
return dictLinuxName[linuxShortName]
else:
return "Linux"
else:
return "Linux"

@ -105,8 +105,8 @@ class cl_install(color_print):
def printInfo(self,sourceDistr,targetDistr):
self.printSUCCESS(_("Installation %s %s")%
(self.clVars.Get('os_linux_name'),
self.clVars.Get('os_linux_subname')))
(self.clVars.Get('os_install_linux_name'),
self.clVars.Get('os_install_linux_subname')))
self.defaultPrint(_("System information\n"))
self.printSUCCESS(_("Computer name")+": %s"%
self.clVars.Get('os_net_hostname'))
@ -115,11 +115,12 @@ class cl_install(color_print):
self.printSUCCESS(_("Network devices")+": %s"%
self.clVars.Get("os_net_interfaces_info"))
self.printSUCCESS(_("Installed system")+": %s %s"%
(self.old_os_linux_name, self.old_os_linux_ver))
(self.clVars.Get('os_linux_name'),
self.clVars.Get('os_linux_ver')))
self.defaultPrint(_("Hardware\n"))
self.printSUCCESS(_("Machine hardware name")+": %s"%
self.clVars.Get('os_arch_machine'))
self.printSUCCESS(_("Quantity processors")+": %s(var name)"%
self.printSUCCESS(_("Quantity processors")+": %s"%
self.clVars.Get('hr_cpu_num'))
self.printSUCCESS(_("Videocard")+": %s"%
'<needed>')
@ -139,11 +140,14 @@ class cl_install(color_print):
self.printSUCCESS(_("Installation volume")+": %s"%
self.clVars.Get('os_root_dev'))
self.printSUCCESS(_("File system")+": %s"%
"<needed>")
self.getFieldByField("format","install","/"))
self.printSUCCESS(_("Swap disk")+": %s"%
"<needed>")
self.getFieldByField("dev","install","swap"))
self.printSUCCESS(_("Mounted disks")+": %s"%
"<needed>")
", ".join(map(lambda x: x[0],
filter(lambda x: not x[1] in ["","/","swap"],
zip(self.clVars.Get('os_disk_dev'),
self.clVars.Get('os_disk_load'))))))
self.defaultPrint(_("Network services\n"))
self.printSUCCESS(_("PROXY")+": %s"%
@ -154,9 +158,9 @@ class cl_install(color_print):
"<needed>")
self.printSUCCESS("Found update: %s %s %s"%
(self.clVars.Get('os_linux_name'),
self.clVars.Get('os_linux_subname'),
self.clVars.Get('os_linux_ver')))
(self.clVars.Get('os_install_linux_name'),
self.clVars.Get('os_install_linux_subname'),
self.clVars.Get('os_install_linux_ver')))
def wait(self,sec=10):
self.printSUCCESS(_("Press %s to cancel")%"Ctrl+C"+"... %d"%sec, printBR=False)
@ -187,25 +191,58 @@ class cl_install(color_print):
else:
return dirsFiles
def setInstallDisk(self,disk):
if not disk in self.clVars.Get('os_disk_dev'):
raise InstallError(_("Wrong target drive name %s"%disk))
else:
osdiskload = \
filter(lambda x: (x[1] or x[2] == "extended") and x[0] == disk,
def setInstallDisk(self,disks):
"""Set installation partitions"""
osdiskdev = self.clVars.Get('os_disk_dev')
# find wrong disks
wrongDisks = filter(lambda x: not x[0] in osdiskdev,disks)
if wrongDisks:
raise InstallError(_("Wrong disk names %s"%", ".join(wrongDisks)))
# default mount point is root
disks = map(lambda x:[x[0],x[1] or '/',x[2]], disks)
# root partition needed
if not filter(lambda x: x[1] == '/',disks):
raise InstallError(_("Need specify root partition"))
# detect duplicate mountPoints
mountPoints = map(lambda x:x[1], disks)
if list(set(mountPoints)) != mountPoints:
raise InstallError(_("Duplicate mount points %s")%", ".join(
filter(lambda x: mountPoints.count(x) > 1,
list(set(mountPoints)))))
# detect duplicate partition
devices = map(lambda x:x[0], disks)
if list(set(devices)) != devices:
raise InstallError(_("Duplicate devices points %s")%", ".join(
filter(lambda x: devices.count(x) > 1,
list(set(devices)))))
# detect using extended drives
usedExtendedDrives = map(lambda x: x[0] and x in devices,
filter(lambda x: x[1] == "extended",
zip(self.clVars.Get('os_disk_dev'),
self.clVars.Get('os_disk_load'),
self.clVars.Get('os_disk_part')))
if len(osdiskload) > 0:
if osdiskload[0][2] == "extended":
raise InstallError(
_("Specified drive '%s' is extended"%disk))
else:
raise InstallError(
_("Specified drive '%s' mounted to '%s'")%
(disk,osdiskload[0][1]))
else:
self.clVars.Set('os_root_dev',disk,True)
self.clVars.Get('os_disk_part'))))
if usedExtendedDrives:
raise InstallError(_("Specified disk '%s' is extended")%", ".join(
usedExtendedDrives))
#for disk in disks:
#
#else:
# osdiskload = \
# filter(lambda x: (x[1] or x[2] == "extended") and x[0] == disk,
# zip(self.clVars.Get('os_disk_dev'),
# self.clVars.Get('os_disk_load'),
# self.clVars.Get('os_disk_part')))
# if len(osdiskload) > 0:
# if osdiskload[0][2] == "extended":
# raise InstallError(
# _("Specified drive '%s' is extended"%disk))
# else:
# raise InstallError(
# _("Specified drive '%s' mounted to '%s'")%
# (disk,osdiskload[0][1]))
# else:
# self.clVars.Set('os_root_dev',disk,True)
def getDeviceByField(self,field,value):
"""Get device by fields (install load format uuid grub part name)"""
@ -252,12 +289,11 @@ class cl_install(color_print):
try:
targetDistr = self.getTargetDistributive(
self.clVars.Get('os_root_dev'),buildermode)
distRep = DistributiveRepository('/usr/calculate/share/linux')
sourceDistr = distRep.getLastDistributive(
march=self.clVars.Get('os_arch_machine'),
shortname=self.clVars.Get('os_linux_shortname').lower())
if sourceDistr:
distRep = DistributiveRepository()
distName = self.clVars.Get('cl_image')
if distName:
# print info
sourceDistr = distRep.getDistributiveByFile(distName)
self.printInfo(sourceDistr,targetDistr)
# wait 10 sec
waittime = 3
@ -308,6 +344,9 @@ class cl_install(color_print):
self.printSUCCESS(_("System successfully installed"))
return False
def setLinuxName(self,shortname):
self.clVars.Set('os_install_linux_shortname',shortname,True)
def setAllLocaleByLang(self,lang):
"""Set all locale variable by specified lang"""
locale = clLocale()

@ -33,8 +33,8 @@ CMD_OPTIONS = [{'shortOption':"T",
},
{'shortOption':"d",
'longOption':"disk",
'optVal':"DISK",
'help':_("the disk for installation")
'optVal':"DISK[:[PART:FILESYSTEM]]",
'help':_("the DISK for installation, which mounted to PART")
},
{'shortOption':"s",
'longOption':"os",
@ -68,6 +68,12 @@ class install_cmd(cl_install,opt,share_cmd):
values.vars is None and \
values.d is None:
self.error(_("need specify disk by '-d' option"))
# check syntax DISK:PART:FS
if values.d:
wrongValue = filter(lambda x: x.count(":") > 2)
self.error(
_("option %s: disk specifing error: '%s'")
% ", ".join(wrongValue))
if values.s:
choices = ['cld','cds','cls','css','cldg','cldx']
if not values.s.lower() in choices:
@ -104,15 +110,21 @@ class install_cmd(cl_install,opt,share_cmd):
else:
self.printERROR(_('variable %s not found')%k)
return False
if options.T:
self.clVars.Set('cl_image','',True)
if options.d:
try:
self.setInstallDisk(options.d)
# convert from ["/dev/sda1","/dev/sda5:/var/calculate]
# to [['/dev/sda1','',''],['/dev/sda5','/var/calculate','']]
self.setInstallDisk(
map(lambda x:x+['']*(3-len(x)),
map(lambda x:x.split(':'),
options.d)))
except InstallError,e:
self.error(str(e))
self.old_os_linux_name = self.clVars.Get('os_linux_shortname')
self.old_os_linux_ver = self.clVars.Get('os_linux_ver')
self.clVars.Get('cl_image')
if options.s:
self.clVars.Set('os_linux_shortname',options.s.upper(),True)
self.setLinuxName(options.s.upper())
return True
def displayVars(self,vars):

@ -95,9 +95,6 @@ class Data:
# content of /etc/conf.d/net.* file
os_net_config_info = {}
# system: server or desktop
os_linux_system = {}
# scheduler
os_kernel_scheduler = {}
@ -123,3 +120,19 @@ class Data:
# LINGUAS value
os_linguas = {'mode':'w'}
# linux version of installation os
os_install_linux_ver = {'mode':'w'}
# subname of installation os
os_install_linux_subname = {'mode':'w'}
# shortname of installation os
os_install_linux_shortname = {'mode':'w'}
# name of installation os
os_install_linux_name = {'mode':'w'}
# installation os system: server or desktop
os_install_linux_system = {}

@ -1,32 +1,28 @@
# Calculate comment=#
timeout 5
default 0
fallback 1
#?os_linux_ver<9.8#
splashimage=(hd#-disk(/boot,grub)-#)/boot/grub/calculate.xpm.gz
#os_linux_ver#
#?os_linux_ver>=9.8#
splashimage=(hd#-disk(/boot,grub)-#)/boot/grub/grub-calculate.xpm.gz
#os_linux_ver#
#?os_linux_system==desktop&&os_linux_subname!=#
title #-os_linux_name-# #-os_arch_machine-# #-os_linux_ver-# #-os_linux_subname-#
#os_linux_system#
#?os_linux_system==desktop&&os_linux_subname==#
title #-os_linux_name-# #-os_arch_machine-# #-os_linux_ver-#
#os_linux_system#
#?os_linux_system==server#
title #-os_linux_name-# #-os_arch_machine-# #-os_linux_ver-#
#os_linux_system#
#?os_install_linux_system==desktop&&os_install_linux_subname!=#
title #-os_install_linux_name-# #-os_arch_machine-# #-os_install_linux_ver-# #-os_install_linux_subname-#
#os_install_linux_system#
#?os_install_linux_system==desktop&&os_install_linux_subname==#
title #-os_install_linux_name-# #-os_arch_machine-# #-os_install_linux_ver-#
#os_install_linux_system#
#?os_install_linux_system==server#
title #-os_install_linux_name-# #-os_arch_machine-# #-os_install_linux_ver-#
#os_install_linux_system#
root (hd#-disk(/boot,grub)-#)
#?os_linux_system==desktop#
#?os_install_linux_system==desktop#
kernel /boot/vmlinuz root=#-os_root_dev-# video=uvesafb:ywrap,1024x768-32@60,mtrr:3,splash=silent,theme:tty1 CONSOLE=/dev/tty1 udev quiet #-os_kernel_resume-# elevator=#-os_kernel_scheduler-# doscsi#-os_kernel_attr-#
#os_linux_system#
#?os_linux_system==server&&os_linux_shortname!=CSS#
#os_install_linux_system#
#?os_install_linux_system==server&&os_install_linux_shortname!=CSS#
kernel /boot/vmlinuz root=#-os_root_dev-# video=uvesafb:ywrap,1024x768-32@60,mtrr:3,splash=silent,theme:tty1 CONSOLE=/dev/tty1 udev quiet #-os_kernel_resume-# elevator=#-os_kerenl_scheduler-# doscsi#-os_kernel_attr-#
#os_linux_system#
#?os_linux_shortname==CSS#
#os_install_linux_system#
#?os_install_linux_shortname==CSS#
kernel /boot/vmlinuz root=#-os_root_dev-# video=uvesafb:ywrap,1024x768-32@60,mtrr:3 udev quiet #-os_kernel_resume-# elevator=#-os_kernel_scheduler-# doscsi#-os_kernel_attr-#
#os_linux_shortname#
#os_install_linux_shortname#
initrd /boot/initrd
#-os_grub_info-#

@ -1,4 +1,4 @@
# Calculate os_linux_shortname!=CSS
# Calculate os_install_linux_shortname!=CSS
# On which TTYs should fbcondecor be enabled? Defaults to RC_TTY_NUMBER.
FBCONDECOR_TTYS="1 2 3 4 5 6"

@ -1,3 +1,4 @@
# Calculate comment=#
#-os_fstab_mount_info-#
#-os_fstab_swap_info-#

Loading…
Cancel
Save