|
|
|
@ -23,7 +23,7 @@ from cl_datavars import glob_attr
|
|
|
|
|
from os import path
|
|
|
|
|
from os import readlink,listdir,access,R_OK
|
|
|
|
|
from cl_utils import isMount,typeFile,getTupleVersion,pathJoin,isFstabMount
|
|
|
|
|
from cl_distr import DistributiveRepository
|
|
|
|
|
from cl_distr import DistributiveRepository,PartitionDistributive
|
|
|
|
|
from cl_fill import clLocale
|
|
|
|
|
from operator import itemgetter
|
|
|
|
|
from cl_template import _terms
|
|
|
|
@ -150,9 +150,26 @@ class fillVars(object, glob_attr):
|
|
|
|
|
devices = filter( lambda x: not reWrongDevice.search(x),
|
|
|
|
|
listdir('/sys/block'))
|
|
|
|
|
device_hash = {}
|
|
|
|
|
execParted = self.getProgPath("/usr/sbin/parted")
|
|
|
|
|
if not execParted:
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%"parted")
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
for mapnum,device in enumerate(sorted(devices,key=self.separateDevice)):
|
|
|
|
|
device_hash[device] = {}
|
|
|
|
|
device_hash[device]['map'] = mapnum
|
|
|
|
|
device_hash[device]['table'] = None
|
|
|
|
|
execStr = '%(prog)s %(device)s print'% \
|
|
|
|
|
{'prog':execParted,
|
|
|
|
|
'device':"/dev/%s"%device}
|
|
|
|
|
floppyData = self.removeFloppy()
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
self.restoreFloppy(floppyData)
|
|
|
|
|
if res:
|
|
|
|
|
res = map(lambda x:x.rpartition("Partition Table:")[2],
|
|
|
|
|
filter(lambda x:x.startswith("Partition Table:"),
|
|
|
|
|
res))
|
|
|
|
|
if res:
|
|
|
|
|
device_hash[device]['table'] = res[-1].strip()
|
|
|
|
|
if device in usbdevices:
|
|
|
|
|
removablePath = '/sys/block/%s/removable'%device
|
|
|
|
|
if os.access(removablePath,R_OK) and \
|
|
|
|
@ -167,11 +184,15 @@ class fillVars(object, glob_attr):
|
|
|
|
|
|
|
|
|
|
def get_os_disk_hash(self):
|
|
|
|
|
reSdaPart = re.compile("^/dev/sd([a-z])(\d+)$")
|
|
|
|
|
devices = self.Get('os_device_hash').keys()
|
|
|
|
|
disks = reduce( lambda x,y: x +
|
|
|
|
|
map( lambda x: "/dev/%s"%x,
|
|
|
|
|
devicesHash = self.Get('os_device_hash')
|
|
|
|
|
devices = devicesHash.keys()
|
|
|
|
|
disksDevs = reduce( lambda x,y: x +
|
|
|
|
|
map( lambda x: ["/dev/%s"%x,y],
|
|
|
|
|
filter(lambda x: y in x,listdir('/sys/block/%s'%y))),
|
|
|
|
|
devices, [] )
|
|
|
|
|
disks = map(lambda x:x[0],disksDevs)
|
|
|
|
|
|
|
|
|
|
disksDevs = dict(disksDevs)
|
|
|
|
|
disk_hash = {}
|
|
|
|
|
# fill grub info
|
|
|
|
|
for dev in disks:
|
|
|
|
@ -184,31 +205,51 @@ class fillVars(object, glob_attr):
|
|
|
|
|
curDevice = None
|
|
|
|
|
|
|
|
|
|
# getting id
|
|
|
|
|
execProg = '/sbin/fdisk'
|
|
|
|
|
execStr = '%s -l'%execProg
|
|
|
|
|
if not path.exists(execProg):
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%execProg)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
execStr = '%s -l'%execProg
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
if res is False:
|
|
|
|
|
cl_overriding.printERROR(_("Cann't execute '%s'")%execStr)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
partedLines = filter(lambda x: x.startswith('/dev/'), res or [] )
|
|
|
|
|
partedMatrix = map(lambda x: filter(lambda y: y and y!="*",
|
|
|
|
|
x.split())[:6],
|
|
|
|
|
partedLines)
|
|
|
|
|
for part,nm,nm,nm,sysid,nm in filter(lambda x:len(x)>5,partedMatrix):
|
|
|
|
|
if not part in disk_hash:
|
|
|
|
|
disk_hash[part] = {}
|
|
|
|
|
disk_hash[part]['id'] = sysid
|
|
|
|
|
execFdisk = self.getProgPath("/sbin/fdisk")
|
|
|
|
|
execGdisk = self.getProgPath("/usr/sbin/gdisk")
|
|
|
|
|
# check on error utils path
|
|
|
|
|
for utilPath,name in [(execFdisk,"fdisk"),(execGdisk,"gdisk")]:
|
|
|
|
|
if not utilPath:
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%name)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
for device in devices:
|
|
|
|
|
if devicesHash[device]['table'] == 'msdos':
|
|
|
|
|
execStr = '%s -l %s'%(execFdisk,"/dev/%s"%device)
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
if res is False:
|
|
|
|
|
cl_overriding.printERROR(_("Cann't execute '%s'")%execStr)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
partedLines = filter(lambda x: x.startswith('/dev/'),res or [] )
|
|
|
|
|
partedMatrix = map(lambda x: filter(lambda y: y and y!="*",
|
|
|
|
|
x.split())[:6],
|
|
|
|
|
partedLines)
|
|
|
|
|
for part,nm,nm,nm,sysid,nm in \
|
|
|
|
|
filter(lambda x:len(x)>5,partedMatrix):
|
|
|
|
|
if not part in disk_hash:
|
|
|
|
|
disk_hash[part] = {}
|
|
|
|
|
disk_hash[part]['id'] = sysid
|
|
|
|
|
disk_hash[part]['table'] = 'msdos'
|
|
|
|
|
elif devicesHash[device]['table'] == 'gpt':
|
|
|
|
|
execStr = '%s -l %s'%(execGdisk,"/dev/%s"%device)
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
if res is False:
|
|
|
|
|
cl_overriding.printERROR(_("Cann't execute '%s'")%execStr)
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
for dev,partid in filter(lambda x:x[0] in disk_hash,
|
|
|
|
|
map(lambda x:["/dev/%s%s"%(device,x[0]),x[1]],
|
|
|
|
|
map(lambda x:x.split()[0:6:5],
|
|
|
|
|
reduce(lambda x,y:x+[y] \
|
|
|
|
|
if x or y.startswith("Number") else x,
|
|
|
|
|
res,[])[1:]))):
|
|
|
|
|
disk_hash[dev]['id'] = partid
|
|
|
|
|
disk_hash[dev]['table'] = 'gpt'
|
|
|
|
|
|
|
|
|
|
# parse all parted lines started with Disk and started with number
|
|
|
|
|
floppyData = self.removeFloppy()
|
|
|
|
|
execProg = '/usr/sbin/parted'
|
|
|
|
|
execProg = self.getProgPath("/usr/sbin/parted")
|
|
|
|
|
execStr = '%s -l'%execProg
|
|
|
|
|
if not path.exists(execProg):
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%execProg)
|
|
|
|
|
if not execProg:
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%"parted")
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
res = self._runos(execStr,env={"LANG":"C"})
|
|
|
|
|
self.restoreFloppy(floppyData)
|
|
|
|
@ -232,12 +273,15 @@ class fillVars(object, glob_attr):
|
|
|
|
|
# create entry if hash hasn't it
|
|
|
|
|
if not partition in disk_hash:
|
|
|
|
|
disk_hash[partition] = {}
|
|
|
|
|
disk_hash[partition]['part'] = parts[4]
|
|
|
|
|
if disk_hash[partition].get('table',None) == "gpt":
|
|
|
|
|
disk_hash[partition]['part'] = "gpt"
|
|
|
|
|
else:
|
|
|
|
|
disk_hash[partition]['part'] = parts[4]
|
|
|
|
|
disk_hash[partition]['size'] = parts[3]
|
|
|
|
|
# fill format, name and uuid
|
|
|
|
|
execStr = '/sbin/blkid'
|
|
|
|
|
if not path.exists(execStr):
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%execStr)
|
|
|
|
|
execStr = self.getProgPath('/sbin/blkid')
|
|
|
|
|
if not execStr:
|
|
|
|
|
cl_overriding.printERROR(_("Command not found '%s'")%"blkid")
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
res = self._runos(execStr)
|
|
|
|
|
if res is False:
|
|
|
|
@ -319,18 +363,18 @@ class fillVars(object, glob_attr):
|
|
|
|
|
|
|
|
|
|
def get_os_install_disk_id(self):
|
|
|
|
|
"""List id for partition after installation"""
|
|
|
|
|
formatId = { 'ext2' : '83',
|
|
|
|
|
'ext3' : '83',
|
|
|
|
|
'ext4' : '83',
|
|
|
|
|
'reiserfs' : '83',
|
|
|
|
|
'jfs' : '83',
|
|
|
|
|
'xfs' : '83',
|
|
|
|
|
'vfat' : 'b',
|
|
|
|
|
'swap' : '82'
|
|
|
|
|
}
|
|
|
|
|
return map(lambda x:formatId[x[0]] if x[0] in formatId else x[1],
|
|
|
|
|
diskHash = self.Get('os_disk_hash')
|
|
|
|
|
def getIdByFS(fs,parttable,oldid):
|
|
|
|
|
if parttable == "msdos":
|
|
|
|
|
return PartitionDistributive.formatId.get(fs,oldid)
|
|
|
|
|
elif parttable == "gpt":
|
|
|
|
|
return PartitionDistributive.formatIdGpt.get(fs,oldid)
|
|
|
|
|
return oldid
|
|
|
|
|
return map(lambda x:getIdByFS(x[0],
|
|
|
|
|
diskHash.get(x[2],{}).get('table',None),x[1]),
|
|
|
|
|
zip(self.Get('os_install_disk_format'),
|
|
|
|
|
self.Get('os_disk_id')))
|
|
|
|
|
self.Get('os_disk_id'),
|
|
|
|
|
self.Get('os_disk_dev')))
|
|
|
|
|
|
|
|
|
|
def get_os_disk_id(self):
|
|
|
|
|
"""List id for partition devices"""
|
|
|
|
@ -1193,8 +1237,9 @@ class fillVars(object, glob_attr):
|
|
|
|
|
return ""
|
|
|
|
|
category = "0300"
|
|
|
|
|
vendor = "10de"
|
|
|
|
|
lsPciProg = self.getProgPath("/usr/sbin/lspci")
|
|
|
|
|
nvidiacards = filter(lambda x:" %s: "%category in x,
|
|
|
|
|
self._runos('/usr/sbin/lspci -d %s: -n'%vendor))
|
|
|
|
|
self._runos('%s -d %s: -n'%(lsPciProg,vendor)))
|
|
|
|
|
if not nvidiaeclass:
|
|
|
|
|
return ""
|
|
|
|
|
cardsid = map(lambda x:x.groups()[0],
|
|
|
|
@ -1233,3 +1278,7 @@ class fillVars(object, glob_attr):
|
|
|
|
|
if imagename in ('/mnt/flash', '/mnt/squash', '/mnt/livecd', '/mnt/cdrom'):
|
|
|
|
|
return self.Get('os_linux_build')
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
def get_os_device_partition(self):
|
|
|
|
|
"""Get partition table list"""
|
|
|
|
|
return self.getAttributeFromHash('os_device_hash','table')
|
|
|
|
|