Add variables for searching stage image.

develop
parent 21e3061919
commit 2f7b986940

Binary file not shown.

@ -29,6 +29,13 @@ DESCRIPTION = _("The Calculate Linux system assemble")
CMD_OPTIONS = [{'shortOption':"f",
'longOption':"force",
'help':_("no questions during the creating process")
},
{'shortOption':"s",
'longOption':"os",
'optVal':"SYSTEM",
'type':'choice',
'choices':['cld','cds','cls','css','cldg','cldx'],
'help':_("select operation system")
}]
USAGE = _("%prog [options]")
@ -51,5 +58,12 @@ class assemble_cmd(share_cmd):
"""Check values all specified options."""
if len(args) > 0:
self.optobj.error(_("unrecognized option") + ": %s"% "".join(args))
if values.s:
self.logicObj.clVars.Set('os_assemble_linux_shortname',
values.s.upper(),True)
self.optobj.checkVarSyntax(values)
return (values, args)
def setAction(self):
"""Set action by configuration or install system"""
self.logicObj.clVars.Set('cl_action', "configure",True)

@ -17,8 +17,92 @@
import os
import re
import cl_overriding
import operator
from cl_vars_share import varsShare
from os import path
from cl_distr import DistributiveRepository
class fillVars(object, varsShare):
pass
def get_os_assemble_linux_shortname(self):
"""Get short system name"""
if self.Get('cl_action') == 'configure':
return self.Get('os_linux_shortname')
else:
systemRoot = self.Get('cl_assemble_path')
return self.getShortnameByMakeprofile(systemRoot) or \
self.getShortnameByIni(systemRoot) or \
self.detectOtherShortname(systemRoot) or \
"Linux"
def get_os_assemble_linux_name(self):
"""Get full system name"""
linuxShortName = self.Get("os_assemble_linux_shortname")
return self.dictLinuxName.get(linuxShortName,"Linux")
def get_os_assemble_linux_subname(self):
"""Get posfix name of system"""
linuxShortName = self.Get("os_assemble_linux_shortname")
return self.dictLinuxSubName.get(linuxShortName,"")
def get_os_assemble_linux_ver(self):
"""Get system version"""
imagename = self.getImage(self.Get('cl_assemble_image_path'),
self.Get('os_assemble_arch_machine'),
self.Get('os_assemble_linux_shortname'))
res = DistributiveRepository.reDistName.search(imagename)
if res:
return res.groupdict()['ver']
elif path.isdir(imagename):
d = DistributiveRepository()._getdistrinfo(imagename)
if "linuxver" in d:
return d['linuxver']
else:
if self.Get('os_assemble_linux_shortname') == \
self.Get('os_linux_shortname'):
return self.Get('os_linux_ver')
return ""
def get_os_assemble_arch_machine(self):
"""Marching architecture for assembling"""
return self.Get('os_arch_machine')
def get_cl_assemble_image_path(self):
if self.Get('cl_action') == 'configure':
return ['/var/calculate/remote/linux',
'/var/calculate/linux',
'/usr/calculate/share/linux',
'/var/calculate/remote/stages/',
'/usr/calculate/share/stages/']
def get_os_assemble_linux_system(self):
"""Get assemble linux system (server or desktop)"""
shortName = self.Get('os_assemble_linux_shortname')
return self.dictNameSystem.get(shortName,"")
def getImage(self,imagePath,archMachine,
shortName,linuxVer=None):
"""Get image by parameters"""
distRep = DistributiveRepository(self.Get('cl_assemble_image_path'))
convert = {'desktop':'cls',
'server':'css'}
shortname = convert.get(self.Get('os_assemble_linux_system'),"")
if self.Get('os_assemble_linux_shortname').lower() in convert.values():
shortname = ""
if shortname:
distr = distRep.getBestDistributive(march=archMachine,
shortname=shortname,
discardType=[],
version=linuxVer,
op_compare=operator.ge)
else:
distr = ""
return distr or distRep.getBestStage(march=archMachine)
def get_cl_assemble_image(self):
"""Get image file from distributive repository"""
return self.getImage(self.Get('cl_assemble_image_path'),
self.Get('os_assemble_arch_machine'),
self.Get('os_assemble_linux_shortname'),
self.Get('os_assemble_linux_ver'))

@ -30,3 +30,29 @@ class Data:
# program version
cl_ver = {'value':__version__}
# system image for installation
cl_assemble_image = {}
# path which contains images
cl_assemble_image_path = {}
cl_assemble_path = {'value':'/mnt/builder'}
# linux version of installation os
os_assemble_linux_ver = {'mode':'w'}
# subname of installation os
os_assemble_linux_subname = {'mode':'w'}
# shortname of installation os
os_assemble_linux_shortname = {'mode':'w'}
# name of installation os
os_assemble_linux_name = {'mode':'w'}
# installation os system: server or desktop
os_assemble_linux_system = {}
# arch of assembling os
os_assemble_arch_machine = {}

@ -41,6 +41,7 @@ if __name__ == "__main__":
# set values to variables
if not assemble.setVars(options):
sys.exit(1)
assemble.setAction()
# print variables
if options.v or options.filter or options.xml:
assemble.printVars(options)

Loading…
Cancel
Save