You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
4.3 KiB
109 lines
4.3 KiB
#-*- coding: utf-8 -*-
|
|
|
|
# Copyright 2010 Calculate Ltd. http://www.calculate-linux.org
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
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):
|
|
|
|
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'))
|