1- from dataclasses import dataclass
2- from pathlib import Path
3- from typing import Optional , Tuple
4- from collections .abc import MutableMapping
5- import zipfile
1+ import re
2+
63import distro
74import logging
85import os
1310import subprocess
1411import sys
1512import time
13+ import zipfile
1614
17- from ou_dedetai import constants , network
15+ from collections .abc import MutableMapping
16+ from dataclasses import dataclass
17+ from packaging .version import Version
18+ from pathlib import Path
19+ from typing import Optional , Tuple
20+
21+ from ou_dedetai import constants , network , wine
1822from ou_dedetai .app import App
1923
2024
21- def fix_ld_library_path (env : Optional [MutableMapping [str , str ]]) -> dict [str , str ]:
25+ def fix_ld_library_path (env : Optional [MutableMapping [str , str ]]) -> dict [str , str ]:
2226 """Removes pyinstaller bundled dynamic linked libraries when executing commands
2327
2428 - https://pyinstaller.org/en/latest/common-issues-and-pitfalls.html#launching-external-programs-from-the-frozen-application
@@ -366,6 +370,34 @@ class SuperuserCommandNotFound(Exception):
366370 """Superuser command not found. Install pkexec or sudo or doas"""
367371
368372
373+ class OpenGLIncompatible (Exception ):
374+ """OpenGL version is incompatible."""
375+
376+
377+ def check_opengl_version (app : App , required_version = "3.2" ) -> tuple [bool , str ]:
378+ try :
379+ env = wine .get_wine_env (app , None )
380+ result = run_command (['glxinfo' ], env = fix_ld_library_path (env ), capture_output = True , text = True , check = True )
381+ except FileNotFoundError :
382+ return False , "glxinfo command not found. Please install mesa-utils or equivalent."
383+ except subprocess .CalledProcessError as e :
384+ return False , f"glxinfo command failed: { e .stderr .strip ()} "
385+
386+ match = re .search (r"OpenGL version string:\s+([\d\.]+)" , result .stdout )
387+ if not match :
388+ return False , "Failed to parse OpenGL version from glxinfo output."
389+
390+ opengl_version = match .group (1 )
391+ if Version (opengl_version ) >= Version (required_version ):
392+ message = f"OpenGL Version: { opengl_version } is supported (>= { required_version } )."
393+ logging .info (message )
394+ return True , message
395+ else :
396+ message = f"OpenGL Version: { opengl_version } is not supported (must be >= { required_version } )."
397+ logging .info (message )
398+ raise OpenGLIncompatible ()
399+
400+
369401def get_superuser_command () -> str :
370402 if shutil .which ('pkexec' ):
371403 return "pkexec"
@@ -420,6 +452,7 @@ def get_package_manager() -> PackageManager | None:
420452 "binutils wget winbind " # wine
421453 "p7zip-full cabextract " # winetricks
422454 "xdg-utils " # For xdg-mime needed for custom url scheme registration
455+ "mesa-utils" # verify opengl version
423456 )
424457
425458 # Now set the appimage packages, this has changed over time
@@ -470,6 +503,7 @@ def get_package_manager() -> PackageManager | None:
470503 "mod_auth_ntlm_winbind samba-winbind samba-winbind-clients " # wine
471504 "cabextract " # winetricks
472505 "xdg-utils " # For xdg-mime needed for custom url scheme registration
506+ "glx-utils" # verify opengl version
473507 )
474508 incompatible_packages = "" # appimagelauncher handled separately
475509 elif shutil .which ('zypper' ) is not None : # OpenSUSE
@@ -485,6 +519,7 @@ def get_package_manager() -> PackageManager | None:
485519 "curl gawk grep " # other
486520 "7zip cabextract " # winetricks
487521 "xdg-utils " # For xdg-mime needed for custom url scheme registration
522+ "Mesa-demo-x" # verify opengl version
488523 )
489524 incompatible_packages = "" # appimagelauncher handled separately
490525 elif shutil .which ('apk' ) is not None : # alpine
@@ -496,11 +531,12 @@ def get_package_manager() -> PackageManager | None:
496531 packages = (
497532 "bash bash-completion " # bash support
498533 "gcompat " # musl to glibc
499- #"fuse-common fuse fuse3 " # appimages
534+ #"fuse-common fuse fuse3 " # appimages; incompatible with muslc
500535 "wget curl " # network
501536 "7zip cabextract " # winetricks
502537 "samba sed grep gawk bash bash-completion " # other
503538 "xdg-utils " # For xdg-mime needed for custom url scheme registration
539+ "mesa-demos" # verify opengl version
504540 )
505541 incompatible_packages = "" # appimagelauncher handled separately
506542 elif shutil .which ('pamac' ) is not None : # manjaro
@@ -515,6 +551,7 @@ def get_package_manager() -> PackageManager | None:
515551 "curl gawk grep " # other
516552 "7zip cabextract " # winetricks (7zip used to be called p7zip)
517553 "xdg-utils " # For xdg-mime needed for custom url scheme registration
554+ "mesa-utils" # verify opengl version
518555 )
519556 incompatible_packages = "" # appimagelauncher handled separately
520557 elif shutil .which ('pacman' ) is not None : # arch, steamOS
@@ -536,6 +573,7 @@ def get_package_manager() -> PackageManager | None:
536573 "lib32-ncurses ocl-icd lib32-ocl-icd libxslt lib32-libxslt libva lib32-libva gtk3 lib32-gtk3 "
537574 "gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader lib32-vulkan-icd-loader "
538575 "xdg-utils " # For xdg-mime needed for custom url scheme registration
576+ "mesa-utils" # verify opengl version
539577 )
540578 else : # arch
541579 packages = (
@@ -548,6 +586,7 @@ def get_package_manager() -> PackageManager | None:
548586 "libva mpg123 v4l-utils " # video
549587 "libxslt sqlite " # misc
550588 "xdg-utils " # For xdg-mime needed for custom url scheme registration
589+ "mesa-utils" # verify opengl version
551590 )
552591 incompatible_packages = "" # appimagelauncher handled separately
553592 elif os_name == "org.freedesktop.platform" :
0 commit comments