Add isPkgInstalled and fix video for server.

develop
Mike Hiretsky 13 years ago
parent ef4a651d73
commit 6325f31c51

@ -24,7 +24,7 @@ from cl_vars_share import varsShare, clLocale
from os.path import exists as pathexists
from os import path
from cl_utils import isMount, genpassword, getAvailableX11Drivers, \
listDirectory
listDirectory,isPkgInstalled
from encrypt import getHash
class fillVars(varsShare):
@ -447,7 +447,8 @@ class fillVars(varsShare):
videoVal = self.getValueFromCmdLine("calculate","video")
videoVal = {'i915':'intel'}.get(videoVal,videoVal)
if videoVal in list_avialable_drivers:
if not isPkgInstalled('xorg-server') or \
videoVal in list_avialable_drivers:
return videoVal
workedModules = map(lambda x:x[0],
filter(lambda x:x[1].isdigit() and int(x[1])>0,

@ -894,6 +894,20 @@ def getPkgUses(fullpkg):
filter(lambda x:x,
iuse)))
def isPkgInstalled(pkg,prefix='/'):
"""Check is package installed"""
pkgDir = path.join(prefix,'var/db/pkg')
if "/" in pkg:
category,op,pkg = pkg.partition('/')
return bool(
filter(lambda x:x.startswith(pkg),
listDirectory(path.join(pkgDir,category))))
else:
return bool(
filter(lambda x: filter(lambda y:y.startswith(pkg),
listDirectory(x)),
listDirectory(pkgDir,fullPath=True)))
def getPkgActiveUses(fullpkg):
"""Get active uses from package"""
res = getPkgUses(fullpkg)

Loading…
Cancel
Save