|
|
|
@ -18,14 +18,14 @@ import os
|
|
|
|
|
import sys
|
|
|
|
|
import re
|
|
|
|
|
from os import path
|
|
|
|
|
from calculate.lib.datavars import Variable,VariableError,ReadonlyVariable
|
|
|
|
|
from calculate.lib.datavars import Variable, VariableError, ReadonlyVariable
|
|
|
|
|
from calculate.lib.utils.portage import isPkgInstalled
|
|
|
|
|
from calculate.lib.utils.files import process,STDOUT,getProgPath
|
|
|
|
|
from calculate.lib.utils.files import process, STDOUT, getProgPath, readFile
|
|
|
|
|
from calculate.lib.utils.common import (getVideoFromXorgLog,
|
|
|
|
|
getVideoFromXorgConf, getVideoFromCmdLine,
|
|
|
|
|
getAvailableVideo, getValueFromCmdLine,
|
|
|
|
|
getCompositeFromXorgconf, getVideoFromModules,
|
|
|
|
|
getVideoFromVendor,getInstalledVideo)
|
|
|
|
|
getVideoFromVendor, getInstalledVideo)
|
|
|
|
|
from calculate.install.distr import DistributiveError
|
|
|
|
|
|
|
|
|
|
from calculate.lib.cl_lang import setLocalTranslate
|
|
|
|
@ -44,7 +44,7 @@ class VideoVariable(Variable):
|
|
|
|
|
if self.Get('os_install_root_type') == 'flash':
|
|
|
|
|
return \
|
|
|
|
|
_("Video configuration unavailable for Flash install")
|
|
|
|
|
if self.Get('os_install_x11_server_set') == 'no' and self.xorg_need:
|
|
|
|
|
if self.Get('os_install_x11_server_set') == 'off' and self.xorg_need:
|
|
|
|
|
return \
|
|
|
|
|
_("This distribution does not provide a Xorg server")
|
|
|
|
|
return ""
|
|
|
|
@ -126,7 +126,7 @@ class VariableOsX11KmsVideoDrv(ReadonlyVariable):
|
|
|
|
|
type = "list"
|
|
|
|
|
value = ["radeon","i915","intel","nouveau","ati"]
|
|
|
|
|
|
|
|
|
|
class VariableOsInstallX11VideoDrv(VideoVariable):
|
|
|
|
|
class VariableOsInstallX11VideoDrv(Variable):
|
|
|
|
|
"""
|
|
|
|
|
Video driver used by xorg
|
|
|
|
|
"""
|
|
|
|
@ -136,54 +136,81 @@ class VariableOsInstallX11VideoDrv(VideoVariable):
|
|
|
|
|
|
|
|
|
|
def init(self):
|
|
|
|
|
self.help = _("set the video driver")
|
|
|
|
|
self.label = _("{0} video driver").format("Xorg")
|
|
|
|
|
self.label = _("Video driver")
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
|
"""Get available (already installed or installable drivers"""
|
|
|
|
|
return self.Get('os_install_x11_video_available')
|
|
|
|
|
if self.Get('os_install_x11_server_set') == 'on':
|
|
|
|
|
return self.Get('os_install_x11_video_available')
|
|
|
|
|
else:
|
|
|
|
|
return self.Get('os_x11_kms_video_drv') + ["other"]
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
# get available videodriver list from install or configure distributive
|
|
|
|
|
list_video = self.Choice('os_install_x11_video_drv')
|
|
|
|
|
if not list_video:
|
|
|
|
|
if self.Get('os_install_x11_server_set') == 'on':
|
|
|
|
|
# get available videodriver list from install or configure distributive
|
|
|
|
|
list_video = self.Choice('os_install_x11_video_drv')
|
|
|
|
|
if not list_video:
|
|
|
|
|
return "other"
|
|
|
|
|
# if type system is usb-hdd then get detect video driver
|
|
|
|
|
if self.Get('os_install_root_type') == 'usb-hdd':
|
|
|
|
|
methods = ((getVideoFromModules,()),
|
|
|
|
|
(getVideoFromCmdLine,()),
|
|
|
|
|
(getVideoFromVendor,(self.Get('hr_video'),list_video)))
|
|
|
|
|
else:
|
|
|
|
|
# test current video driver for install system
|
|
|
|
|
methods = ((getVideoFromXorgLog,('/',list_video)),
|
|
|
|
|
(getVideoFromXorgConf,('/',)),
|
|
|
|
|
(getVideoFromModules,()),
|
|
|
|
|
(getVideoFromCmdLine,()),
|
|
|
|
|
(getVideoFromVendor,(self.Get('hr_video'),list_video)))
|
|
|
|
|
for func,args in methods:
|
|
|
|
|
drv = func(*args)
|
|
|
|
|
if drv in list_video:
|
|
|
|
|
return drv
|
|
|
|
|
return "other"
|
|
|
|
|
# if type system is usb-hdd then get detect video driver
|
|
|
|
|
if self.Get('os_install_root_type') == 'usb-hdd':
|
|
|
|
|
methods = ((getVideoFromModules,()),
|
|
|
|
|
(getVideoFromCmdLine,()),
|
|
|
|
|
(getVideoFromVendor,(self.Get('hr_video'),list_video)))
|
|
|
|
|
else:
|
|
|
|
|
# test current video driver for install system
|
|
|
|
|
methods = ((getVideoFromXorgLog,('/',list_video)),
|
|
|
|
|
(getVideoFromXorgConf,('/',)),
|
|
|
|
|
(getVideoFromModules,()),
|
|
|
|
|
(getVideoFromCmdLine,()),
|
|
|
|
|
(getVideoFromVendor,(self.Get('hr_video'),list_video)))
|
|
|
|
|
for func,args in methods:
|
|
|
|
|
drv = func(*args)
|
|
|
|
|
if drv in list_video:
|
|
|
|
|
return drv
|
|
|
|
|
return "other"
|
|
|
|
|
for drv in self.choice():
|
|
|
|
|
videoSysPath = path.join("/sys/module",drv,"refcnt")
|
|
|
|
|
refcnt = readFile(videoSysPath).strip()
|
|
|
|
|
if refcnt.isdigit() and int(refcnt) > 0:
|
|
|
|
|
return {'i915':'intel'}.get(drv,drv)
|
|
|
|
|
else:
|
|
|
|
|
return "other"
|
|
|
|
|
|
|
|
|
|
pkgDrvMap = {'nvidia':('NVidia','x11-drivers/nvidia-drivers'),
|
|
|
|
|
'fglrx':('ATI','x11-drivers/ati-drivers'),
|
|
|
|
|
'vboxdrv':('VirtualBox','x11-drivers/xf86-video-virtualbox')}
|
|
|
|
|
|
|
|
|
|
def check(self,value):
|
|
|
|
|
if self.Get('cl_action') == 'system':
|
|
|
|
|
availDrvs = self.Get('os_install_x11_video_available')
|
|
|
|
|
if not value in availDrvs:
|
|
|
|
|
raise VariableError(_("Only %s drivers are available")%
|
|
|
|
|
",".join(availDrvs))
|
|
|
|
|
if self.Get('os_install_x11_server_set') == 'on':
|
|
|
|
|
if self.Get('cl_action') == 'system':
|
|
|
|
|
availDrvs = self.Get('os_install_x11_video_available')
|
|
|
|
|
if not value in availDrvs:
|
|
|
|
|
raise VariableError(_("Only %s drivers are available")%
|
|
|
|
|
",".join(availDrvs))
|
|
|
|
|
else:
|
|
|
|
|
if not value in getInstalledVideo(prefix="/") and \
|
|
|
|
|
not value in ("auto","other"):
|
|
|
|
|
error =_("video driver %s is unavailable")%value
|
|
|
|
|
if value in self.pkgDrvMap:
|
|
|
|
|
error += ". " + (_("Install driver %s with:")
|
|
|
|
|
%self.pkgDrvMap[value][0])
|
|
|
|
|
error += "\n" + ("emerge %s"%self.pkgDrvMap[value][1])
|
|
|
|
|
raise VariableError(error)
|
|
|
|
|
else:
|
|
|
|
|
if not value in getInstalledVideo(prefix="/") and \
|
|
|
|
|
not value in ("auto","other"):
|
|
|
|
|
error =_("video driver %s is unavailable")%value
|
|
|
|
|
if value in self.pkgDrvMap:
|
|
|
|
|
error += ". " + (_("Install driver %s with:")
|
|
|
|
|
%self.pkgDrvMap[value][0])
|
|
|
|
|
error += "\n" + ("emerge %s"%self.pkgDrvMap[value][1])
|
|
|
|
|
raise VariableError(error)
|
|
|
|
|
availDrivers = self.Get('os_x11_kms_video_drv') + ["other"]
|
|
|
|
|
if not value in availDrivers:
|
|
|
|
|
raise VariableError("Only %s drivers are available" %
|
|
|
|
|
",".join(availDrivers))
|
|
|
|
|
|
|
|
|
|
def uncompatible(self):
|
|
|
|
|
"""
|
|
|
|
|
Video setting up unavailable for flash installation
|
|
|
|
|
"""
|
|
|
|
|
if self.Get('os_install_root_type') == 'flash':
|
|
|
|
|
return \
|
|
|
|
|
_("Video configuration unavailable for Flash install")
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
class VariableHrVideoId(ReadonlyVariable):
|
|
|
|
|
"""
|
|
|
|
@ -272,7 +299,7 @@ class VariableOsInstallX11ServerSet(ReadonlyVariable):
|
|
|
|
|
with image as distr:
|
|
|
|
|
distrPath = image.getDirectory()
|
|
|
|
|
if isPkgInstalled('xorg-server',prefix=distrPath):
|
|
|
|
|
return "yes"
|
|
|
|
|
return "on"
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
return "no"
|
|
|
|
|
return "off"
|
|
|
|
|