[services] kernel-switcher: add opengl switcher, improve application output
This commit is contained in:
@@ -17,6 +17,7 @@ from entropy.exceptions import DependenciesNotRemovable
|
||||
from entropy.i18n import _
|
||||
from entropy.client.interfaces import Client
|
||||
import entropy.dep
|
||||
import entropy.tools
|
||||
|
||||
# equo modules
|
||||
from text_query import print_package_info
|
||||
@@ -56,9 +57,29 @@ def _get_target_tag(etp_client, kernel_match):
|
||||
|
||||
def _setup_kernel_symlink(target_tag):
|
||||
eselect_exec = "/usr/bin/eselect"
|
||||
if os.access(eselect_exec, os.X_OK) and not etpUi['pretend']:
|
||||
if os.access(eselect_exec, os.X_OK):
|
||||
subprocess.call((eselect_exec, "kernel", "set", target_tag))
|
||||
|
||||
# removing and installing proprietary drivers might reset the selected
|
||||
# OpenGL implementation
|
||||
|
||||
def _get_opengl_impl():
|
||||
eselect_exec = "/usr/bin/eselect"
|
||||
sts = 1
|
||||
out = "xorg-x11"
|
||||
if os.access(eselect_exec, os.X_OK) and not etpUi['pretend']:
|
||||
sts, xout = entropy.tools.getstatusoutput("%s opengl show" % (
|
||||
eselect_exec,))
|
||||
if sts == 0:
|
||||
out = xout
|
||||
return out
|
||||
|
||||
def _set_opengl_impl(opengl):
|
||||
eselect_exec = "/usr/bin/eselect"
|
||||
if os.access(eselect_exec, os.X_OK):
|
||||
args = (eselect_exec, "opengl", "set", opengl)
|
||||
subprocess.call(args)
|
||||
|
||||
def _show_kernel_warnings(kernel_atom):
|
||||
print_info("%s %s" % (purple(kernel_atom), teal(_("has been installed."))))
|
||||
print_warning("%s: %s" % (red(_("Attention")),
|
||||
@@ -124,12 +145,14 @@ def _switch_kernel(args):
|
||||
matches = [x for x in matches if x is not None]
|
||||
matches.append(kernel_match)
|
||||
|
||||
opengl = _get_opengl_impl()
|
||||
rc, other = install_packages(
|
||||
etp_client,
|
||||
atomsdata = matches,
|
||||
check_critical_updates = False
|
||||
)
|
||||
if rc == 0:
|
||||
if (rc == 0) and (not etpUi['pretend']):
|
||||
_set_opengl_impl(opengl)
|
||||
_setup_kernel_symlink(target_tag)
|
||||
_show_kernel_warnings(kernel_atom)
|
||||
return rc
|
||||
|
||||
Reference in New Issue
Block a user