| 1 |
config |
1.1 |
import sre, modules, portage
|
| 2 |
|
|
from output import *
|
| 3 |
|
|
import sre
|
| 4 |
|
|
|
| 5 |
|
|
CONFILE="/etc/env.d/09opengl"
|
| 6 |
|
|
IMPPATH="/usr/lib/opengl"
|
| 7 |
|
|
|
| 8 |
config |
1.5 |
def check_version():
|
| 9 |
|
|
return 1
|
| 10 |
|
|
|
| 11 |
config |
1.1 |
def switch_profile(profile):
|
| 12 |
config |
1.5 |
if not modules.isroot():
|
| 13 |
|
|
modules.error("opengl", "Must be root")
|
| 14 |
|
|
return 1
|
| 15 |
|
|
|
| 16 |
|
|
if not check_version():
|
| 17 |
|
|
modules.error("opengl", "Your xorg-x11 seems outdated - aborting")
|
| 18 |
|
|
return 1
|
| 19 |
|
|
|
| 20 |
|
|
implem = get_implem()
|
| 21 |
|
|
|
| 22 |
|
|
if len(implem) == 0:
|
| 23 |
|
|
modules.error("Couldn't get current profile")
|
| 24 |
|
|
return 1
|
| 25 |
|
|
|
| 26 |
|
|
|
| 27 |
config |
1.1 |
|
| 28 |
|
|
def get_implem():
|
| 29 |
|
|
try:
|
| 30 |
kugelfang |
1.4 |
myenv = modules.read_envvar("opengl" ,CONFILE, "LDPATH")
|
| 31 |
config |
1.1 |
except:
|
| 32 |
|
|
modules.error("Exception occurred")
|
| 33 |
kugelfang |
1.4 |
mymatch = sre.match("/usr/lib/opengl/([a-z.\-+]+)/lib",myenv)
|
| 34 |
|
|
if mymatch:
|
| 35 |
|
|
return mymatch.group(1)
|
| 36 |
|
|
else:
|
| 37 |
|
|
return ""
|
| 38 |
config |
1.1 |
|
| 39 |
|
|
def print_implem(cmdline):
|
| 40 |
config |
1.5 |
my_implem = get_implem()
|
| 41 |
|
|
if not len(my_implem) == 0:
|
| 42 |
|
|
print my_implem
|
| 43 |
config |
1.1 |
else:
|
| 44 |
config |
1.3 |
modules.error("opengl", "No implementation found - aborting")
|
| 45 |
config |
1.1 |
|
| 46 |
|
|
def get_implementations():
|
| 47 |
config |
1.5 |
my_dirs = os.listdir(IMPPATH)
|
| 48 |
kugelfang |
1.2 |
implementations = []
|
| 49 |
config |
1.5 |
for x in my_dirs:
|
| 50 |
config |
1.1 |
if x != "global":
|
| 51 |
|
|
implementations += [x]
|
| 52 |
|
|
return implementations
|
| 53 |
|
|
|
| 54 |
|
|
|
| 55 |
|
|
def count_implementations():
|
| 56 |
config |
1.5 |
my_dirs = os.listdir(IMPPATH)
|
| 57 |
config |
1.1 |
count = 0
|
| 58 |
config |
1.5 |
for x in my_dirs:
|
| 59 |
config |
1.1 |
if not x == "global":
|
| 60 |
|
|
count += 1
|
| 61 |
|
|
return count
|
| 62 |
|
|
|
| 63 |
|
|
def print_usage(cmdline):
|
| 64 |
|
|
print "usage: gentoo-update --opengl <implementation>"
|
| 65 |
|
|
print
|
| 66 |
|
|
print darkgreen(" --print-opengl-profile")
|
| 67 |
|
|
print "\t\tPrints the currently used BLAS Profiles."
|
| 68 |
|
|
print darkgreen(" --help-opengl")
|
| 69 |
|
|
print "\t\tPrint this message"
|
| 70 |
|
|
|
| 71 |
|
|
GL_FUNCTIONS={
|
| 72 |
|
|
"print-opengl-profile":[print_implem, "opengl"],
|
| 73 |
|
|
"help-opengl":[print_usage, "opengl"],
|
| 74 |
|
|
"opengl-implementations":[get_implementations, "opengl"]
|
| 75 |
|
|
}
|
| 76 |
|
|
|
| 77 |
kugelfang |
1.2 |
modules.FUNCTIONS.update(GL_FUNCTIONS)
|