Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/UbuntuDrivers/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/UbuntuDrivers/__pycache__/detect.cpython-310.pyc
o

�g��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
daiadZ
Gdd�de�Zdd	�Zd\d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zie_dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Z d(d)�Z!d]d,d-�Z"d.d/�Z#d0d1�Z$d^d2d3�Z%d_d4d5�Z&d`d6d7�Z'dad8d9�Z(d:d;�Z)d<d=�Z*Gd>d?�d?e�Z+d@dA�Z,dBdC�Z-dbdDdE�Z.d\dFdG�Z/dHdI�Z0dJdK�Z1dLdM�Z2dNdO�Z3dPdQ�Z4dRdS�Z5dTdU�Z6dVdW�Z7dXdY�Z8dZd[�Z9dS)czGHardware and driver package detection functionality for Ubuntu systems.�N)�kerneldetection�z/etc/custom_supported_gpus.jsonc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�NvidiaPkgNameInfoz%Class to process NVIDIA package namescCs:||_d|_d|_d|_d|_d|_d|_|�|j�dS)NF���r)�	_pkg_name�_obsolete_name_scheme�_server�_open�
_major_ver�_flavour�is_valid�
_process_name)�self�pkg_name�r�6/usr/lib/python3/dist-packages/UbuntuDrivers/detect.py�__init__szNvidiaPkgNameInfo.__init__cCs�d|vrt�d|�dSt�d�}|�|�}|r*d|_|�d�|_|j|_d|_	dSt�d�}|�|�}|rf|�d��
d�d	k|_|�d��
d
�d	k|_d|�d�|jrVdnd|jr\d
ndf|_d|_	dSdS)
N�nvidiaz8NvidiaPkgNameInfo: %s is not an NVIDIA package. Skippingznvidia-([0-9]+)T�znvidia-driver-([0-9]+)(.*)r�-serverr�-openz%s%s%sr)
�logging�debug�re�compile�matchr�groupr
rr�findrr	)r�name�patternrrrrr
(s,




�
�zNvidiaPkgNameInfo._process_namecC�|jS�N)r�rrrr�has_obsolete_name_schemeD�z*NvidiaPkgNameInfo.has_obsolete_name_schemecCr r!)rr"rrr�	is_serverGr$zNvidiaPkgNameInfo.is_servercCr r!)r	r"rrr�is_openJr$zNvidiaPkgNameInfo.is_opencCr r!)r
r"rrr�get_major_versionMr$z#NvidiaPkgNameInfo.get_major_versioncCr r!)rr"rrr�get_flavourPr$zNvidiaPkgNameInfo.get_flavourN)�__name__�
__module__�__qualname__�__doc__rr
r#r%r&r'r(rrrrrs
rcCstst��datS)zCache system architecturer)�system_architecture�apt_pkg�get_architecturesrrrr�get_apt_archTsr0c
Csbi}|rd|p	d}t�|�D]�\}}}d}d|vrUz!ttj�|d���}|����}Wd�n1s5wYWnPtyT}z
t�	d||�WYd}~qd}~wwd|vr�d|vr�ttj�|d���}	|	D]}
|
�
d�r||
�d	d
�d
��}nqiWd�n1s�wY|s�qtj�|d�}tj�|d�}tj�|�r�tj�|�s�q|||<q|S)
u�Get modaliases present in the system.

    This ignores devices whose drivers are statically built into the kernel, as
    you cannot replace them with other driver packages anyway.

    Return a modalias → sysfs path map.
    z
%s/devicesz/sys/devicesN�modaliasz0system_modaliases(): Cannot read %s/modalias: %s�ssb�ueventz	MODALIAS=�=r�driver�module)
�os�walk�open�path�join�read�strip�IOErrorrr�
startswith�split�islink)
�sys_path�aliases�devicesr:�dirs�filesr1�f�e�fd�line�
driverlink�modlinkrrr�system_modaliases\sD�����
���
rMc	Cs�d}|j�d�r'|j�dd�}z||}Wnty&t�d|�YdSwt�|�}|�|�}d}z|j	�
d�D]}|D]\}}	}
|�d�rLd}nq>q:Wnttfyct�d|�d}Ynw|spt�d	|j�dSz|d
}Wnty�t�d�YdSw|�|�}|jD]\}}
}|�d�r�|}q�|r�||}|j
D]}|jj|jkr�dSq�t�d|j|�t�d
|dd�|j
D�f�dSdS)Nznvidia-driver-zxserver-xorg-video-nvidia-z5Cannot find %s package in the cache. Cannot check ABITF�Dependszxorg-video-abi-z@The %s package seems to have no dependencies. Skipping ABI checkz;Skipping check for %s since it does not depend on video abizxserver-xorg-corez1xserver-xorg-core not available, cannot check ABIzBDriver package %s is incompatible with current X.org server ABI %sz%s is not in %scSsg|]}|j�qSr)�
parent_pkg)�.0�xrrr�
<listcomp>�sz+_check_video_abi_compat.<locals>.<listcomp>)rr?�replace�KeyErrorrrr.�DepCache�get_candidate_ver�depends_list_str�get�	TypeError�
provides_list�rev_depends_listrO)�	apt_cache�package�xorg_video_abi�xorg_driver_name�depcache�	candidate�needs_video_abi�dep_list�dep_name�dep_ver�dep_op�	xorg_core�
provides_name�provides_ver�	p_version�abi_pkg�deprrr�_check_video_abi_compat�sf�


����
�

�
��rmcCspt�|�}t�|�}i}|jD]�}z|�|�}|�|jd�|d}|s'WqWnttt	fy4Yqw|j
dt�fvr>qt||�sDqz<|�
d�D]4}|�d�}|sTqJ|�
d�\}}	|	�
d�D]}
|
��}
|
�
dd	�d}|�|i��|
t���|j�q`qJWqty�t�d
|j|f�Yqwi}|��D]\}}
t�d�dd
�|
��D��tj�}||
f||<q�|S)aIBuild a modalias map from an apt_pkg.Cache object.

    This filters out uninstallable video drivers (i. e. which depend on a video
    ABI that xserver-xorg-core does not provide).

    Return a map bus -> modalias -> [package, ...], where "bus" is the prefix of
    the modalias up to the first ':' (e. g. "pci" or "usb").
    r�
Modaliases�all�)�, �(�,�:rz*Package %s has invalid modalias header: %s�|cSsg|]}t�|��qSr)�fnmatch�	translate)rP�patrrrrR�sz+_apt_cache_modalias_map.<locals>.<listcomp>)r.rU�PackageRecords�packagesrV�lookup�	file_listrT�AttributeError�UnicodeDecodeError�architecturer0rmr@r=�
setdefault�set�addr�
ValueErrorr�error�itemsrrr;�keys�
IGNORECASE)r\r`�records�resultr]ra�m�partr6�lst�alias�bus�result2�	alias_maprxrrr�_apt_cache_modalias_map�sV
	


��

 ��	���r�cCstSr!)�custom_supported_gpus_jsonrrrr�path_get_custom_supported_gpus�sr�c	Cs�t�}d}z_t|d��O}z-tt�|�d�}|D]}|d|kr7|d�d�d}t�d||d	|f�nqWntyGt�	d
�Yn
wWd�W|SWd�W|S1s]wYW|Styut�	d|�Y|Sw)z|Get nvidia allowing driver for specific devices.

    did: 0x1234
    Return the situable nvidia driver version for it.
    N�r�chips�devid�branch�.rz0Found a specific nv driver version %s for %s(%s)rz;package_get_nv_allowing_driver(): unexpected json detected.z3package_get_nv_allowing_driver(): unable to read %s)
r�r9�list�json�loadr@r�info�	Exceptionr)�didr:�version�stream�gpus�gpurrr�package_get_nv_allowing_driver�s@���
��������r�csVt�}tdd��jD��}ztj|}Wnty&t��}|tj|<Ynw|�|�dd�ddif�\}}t	|�\}}d}	d}
|dkrzt
d|�}	d	|	}d
|}�jD]}
|
���d�d|krlt|g�||<d}
qV|	durz|
szt�
d|�|
s�|dus�|�|�s�gS|D]}t�|��|���r�||D]}
|�|
�q�q��fdd
�|D�S)z_Search packages which match the given modalias.

    Return a list of apt.Package objects.
    css�|]}|��VqdSr!)�get_fullname)rPr]rrr�	<genexpr>!s�z(packages_for_modalias.<locals>.<genexpr>rtrrN�10DE�0xznvidia-driver-%szpci:v000010DEd0000%s*z%s is not in the package pool.csg|]}�|�qSrr�rP�p�r\rrrR@sz)packages_for_modalias.<locals>.<listcomp>)r��hashrz�packages_for_modalias�
cache_mapsrTr�rXr@�_get_vendor_model_from_aliasr�r�rrrrv�fnmatchcase�lowerr�)r\r1�pkgs�apt_cache_hash�	cache_maprx�bus_map�vidr��nvamd�found�nvamdn�nvamdar�r�rr�rr�s@� 
��r�c	Cs�t�|�}|�|�}|dusJ�|j�d�rdSt�|�}|�|jd�|jdjD]&\}}|j	sIz|d}|dvWSt
yHYdSw|j	dvrQdSq+dS)NrFr�	Component)�
restricted�
multiverseT)r.rUrVrr?ryr{r|�version_list�	componentrT)r\�pkgr`rar��pfile�_r�rrr�_is_package_freeFs&


�
�r�cCsLt�|�}|�|�}|durdSz|jddjdkWSty%YdSw)NFr�Ubuntu)r.rUrVr|�originrT)r\r�r`rarrr�_is_package_from_distrocs

�r�c	Cs�t�|�}|�|�}t�|�}|�|jd�z|d}Wnttfy0t�	d|j
�YdSw|�d�}|dkrCt�	d|j
�dS|d|�}|S)z-Determine module name from apt Package objectrrnzM_pkg_get_module %s: package has no Modaliases header, cannot determine moduleNrrzR_pkg_get_module %s: package has invalid Modaliases header, cannot determine module)r.rUrVryr{r|rTr}rrrr)r\r�r`rar�r��parenr6rrr�_pkg_get_moduleos 


�
r�c	Cs�t�|�}|�|�}t�|�}|�|jd�z|d}Wnttfy0t�	d|j
�YdSw|dvr?t�	d|j
|�dS|S)z/Determine support level from apt Package objectr�SupportzR_pkg_get_support %s: package has no Support header, cannot determine support levelN)�PB�NFB�LTSB�LegacyzY_pkg_get_support %s: package has invalid Support %sheader, cannot determine support level)r.rUrVryr{r|rTr}rrr)r\r�r`rar��supportrrr�_pkg_get_support�s 


��r�c		Csjt�d|�}|�d�}|�d�}|dkrdSd|}t�}z�t|d��v}zTtt�|�d�}|D]F}|d	|krvd
|dvrv|d�d
�d|krdt	�
d|d�d
�d|f�WWd�WdSt	�d|�WWd�WdSq0Wnty�t	�
d�Yn
wWd�WdSWd�WdS1s�wYWdSty�t	�
d|�YdSw)zAalias: e.g. pci:v000010DEd000024BAsv0000103Csd000089C6bc03sc00i00zpci:v0000(.*)d0000(.*)sv(.*)r�r�Fz0x%sr�r�r��	runtimepm�featuresr�r�rz)Candidate version does not match %s != %sNzFound runtimepm supports on %s.Tz?_is_nv_allowing_runtimepm_supported(): unexpected json detectedz8_is_nv_allowing_runtimepm_supported(): unable to read %s)
r�searchrr�r9r�r�r�r@rrr�r�)	r��verr�r�r�r:r�r�r�rrr�#_is_nv_allowing_runtimepm_supported�sR

��	��
��������r�c
s�z+t�|�}|�|�}t�|�}|�|jd�t�|j�}|j�	d�d}|d}Wn
t
ttfy8YdSw|�
d�dkrBdS||�
d�d|�
d��}	|	�	d	�}
t�|�r\d
St�fdd�|
D��S)
z>Check if the package supports runtimepm for the given modaliasrr��	PmAliasesFznvidia(rrrrprqTc3s$�|]
}t����|���VqdSr!)rvr�)rP�regex�r�rrr��s�"z*_is_runtimepm_supported.<locals>.<genexpr>)r.rUrVryr{r|�
TagSection�record�ver_strr@rTr}r~rr��any)r\r�r�r`rar��sectionr�r��n�
modaliasesrr�r�_is_runtimepm_supported�s$


�

r�cCstj�d�duS)z*Check if the current session in on Wayland�WAYLAND_DISPLAYN)r7�environrXrrrr�is_wayland_session�sr�c
Cs�|jrdS|j�d�rd}n|j�d�rd}nt||�}|s dSztjd|gtjtjd�}|��Wntt	tj
fyQ}zt�dt
|��WYd}~dSd}~ww|jdkrat�d	|j|�d
St�d|j|�dS)zIDetermine if the kernel module from an apt.Package is manually installed.Fr�fglrx�modinfo)�stdout�stderrz_is_manual_install failed: %sNrzJ_is_manual_install %s: builds module %s which is available, manual installTzQ_is_manual_install %s: builds module %s which is not available, no manual install)�current_verrr?r��
subprocess�Popen�PIPE�communicate�OSError�FileNotFoundError�CalledProcessErrorrr�str�
returncode)r\r�r6r�rHrrr�_is_manual_install�s8
���
��r�c	
Cs�ztjddd|gdd�}Wn ttjfy.}zt�d||t|��WYd}~dSd}~wwt�d	|�d}d}|��D]}|�d
d�\}}d|vrM|}d
|vrS|}q=t�d||||�||fS)zTReturn (vendor, model) names for given device.

    Values are None if unknown.
    �udevadm�hwdbz--test=T)�universal_newlinesz-_get_db_name(%s, %s): udevadm hwdb failed: %sN�NNz_get_db_name: output
%s
r4r�_VENDOR�_MODELz-_get_db_name(%s, %s): vendor "%s", model "%s")	r��check_outputr�r�rrr��
splitlinesr@)	�syspathr��outrH�vendor�modelrJ�k�vrrr�_get_db_name�s.
�����rcCs,d}d|}t|d�}|�|�|��dS)zSet KMS on or off for NVIDIAz/lib/modprobe.d/nvidia-kms.confz�# This file was generated by ubuntu-drivers
# Set value to 1 to enable modesetting, 0 to disable it
options nvidia-drm modeset=%d
�wN)r9�write�close)�value�nvidia_kms_file�kms_text�kms_fdrrr�set_nvidia_kmss�

rFTcCs�t|�}|s'zt�d�}Wnty&}z
t�|�iWYd}~Sd}~wwi}|��D]T\}}t||�D]J}	|r@t||	�s@q6|sJt	�	|	j
d�rJq6||t||	�t||	�t||	�t
||	|�d�||	j
<t||�\}
}|
duru|
||	j
d<|dur�|||	j
d<q6q-dd�|D�}|r�|��D]
\}
}|
�d�r�|t|
<q�|jt�t�d	�|d
}|D]
}	|	|k||	d<q�t|���D]-\}}|D]&}	z||	}t||�t||�|d�||	<Wq�ty�t�d
|	�Yq�wq�|S)u�Get driver packages that are available for the system.

    This calls system_modaliases() to determine the system's hardware and then
    queries apt about which packages provide drivers for those. It also adds
    available packages from detect_plugin_packages().

    If you already have an apt_pkg.Cache() object, you should pass it as an
    argument for efficiency. If not given, this function creates a temporary
    one by itself.

    If freeonly is set to True, only free packages (from main and universe) are
    considered

    Return a dictionary which maps package names to information about them:

      driver_package → {'modalias': 'pci:...', ...}

    Available information keys are:
      'modalias':    Modalias for the device that needs this driver (not for
                     drivers from detect plugins)
      'syspath':     sysfs directory for the device that needs this driver
                     (not for drivers from detect plugins)
      'plugin':      Name of plugin that detected this package (only for
                     drivers from detect plugins)
      'free':        Boolean flag whether driver is free, i. e. in the "main"
                     or "universe" component.
      'from_distro': Boolean flag whether the driver is shipped by the distro;
                     if not, it comes from a (potentially less tested/trusted)
                     third party source.
      'vendor':      Human readable vendor name, if available.
      'model':       Human readable product name, if available.
      'recommended': Some drivers (nvidia, fglrx) come in multiple variants and
                     versions; these have this flag, where exactly one has
                     recommended == True, and all others False.
    N�
oem-*-meta)r1r��free�from_distror�r�r�r�cS�g|]	}|�d�r|�qS��nvidia-�r?r�rrrrRc�z*system_driver_packages.<locals>.<listcomp>r��keyr�recommended)r
r�pluginz*Package %s plugin not available. Skipping.)rMr.�Cacher�rr�r�r�r�rvrr�r�r�rr?�lookup_cache�sort�	functools�
cmp_to_key�_cmp_gfx_alternatives�detect_plugin_packagesrTr)r\rB�freeonly�include_oemr��exrzr�r�r�r�r��nvidia_packagesrrrrr��apt_prrr�system_driver_packagessj%
��
���
����r!cCs@t�d�}|�|�}|r|�d�dd�|�d�dd�fSdS)Nz$(.+):v(.+)d(.+)sv(.+)sd(.+)bc(.+)i.*r���r�)rrrr)r��modalias_pattern�detailsrrrr�s


$r�c
Cs�|dusJ�d}	t�|�}|j}t|�}|js!t�d|�|S|��r.t�d|�|S|��}d|}z||}|�	|�}	|rO|	j
dt�fvrR|}W|SW|SW|Sty^Y|Sw)Nz)Unsupported driver detected: %s. Skipping�%Legacy driver detected: %s. Skipping.znvidia-headless-no-dkms-%sro)
r.rUrrrrrr#r(rV�archr0rT)
r�r\�metapackager`r�nvidia_info�candidate_flavourrar]�package_candidaterrr�!_get_headless_no_dkms_metapackage�s:

����r,c	
Cs�|siSt|�}|s+zt�d�}Wnty*}z
t�|�iWYd}~Sd}~wwi}|��D])\}}t||�D]}t�|j	d�sDq:||t
||�t||�dt||�d�||j	<q:q1|S)u�Get device specific metapackages for this system

    This calls system_modaliases() to determine the system's hardware and then
    queries apt about which packages provide hardware enablement support for
    those.

    If you already have an apt_pkg.Cache() object, you should pass it as an
    argument for efficiency. If not given, this function creates a temporary
    one by itself.

    Return a dictionary which maps package names to information about them:

      driver_package → {'modalias': 'pci:...', ...}

    Available information keys are:
      'modalias':    Modalias for the device that needs this driver (not for
                     drivers from detect plugins)
      'syspath':     sysfs directory for the device that needs this driver
                     (not for drivers from detect plugins)
      'plugin':      Name of plugin that detected this package (only for
                     drivers from detect plugins)
      'free':        Boolean flag whether driver is free, i. e. in the "main"
                     or "universe" component.
      'from_distro': Boolean flag whether the driver is shipped by the distro;
                     if not, it comes from a (potentially less tested/trusted)
                     third party source.
      'vendor':      Human readable vendor name, if available.
      'model':       Human readable product name, if available.
      'recommended': Always True; we always recommend you install these
                     packages.
    Nr	T)r1r�r
rrr�)
rMr.rr�rr�r�r�rvrr�r�r�)	r\rBrr�rrzr�r�r�rrr�#system_device_specific_metapackages�s2 
����r-c
Cs�dg}t|�}|s*zt�d�}Wnty)}z
t�|�iWYd}~Sd}~wwi}|��D]]\}}t||�D]S}t||�\}	}
t	|�\}}|dur�|�
�|vr�||t||�t||�t
||�d�||j<|	durq|	||jd<|
dur||
||jd<t||�}
|
dur�|
||jd<q9q0dd�|D�}|r�|��D]
\}}|�d	�r�|t|<q�|jt�t�d
�|d}|D]
}||k||d<q�|S)
u�Get driver packages, for gpgpu purposes, that are available for the system.

    This calls system_modaliases() to determine the system's hardware and then
    queries apt about which packages provide drivers for those. Finally, it looks
    for the correct metapackage, by calling _get_headless_no_dkms_metapackage().

    If you already have an apt_pkg.Cache() object, you should pass it as an
    argument for efficiency. If not given, this function creates a temporary
    one by itself.

    Return a dictionary which maps package names to information about them:

      driver_package → {'modalias': 'pci:...', ...}

    Available information keys are:
      'modalias':    Modalias for the device that needs this driver (not for
                     drivers from detect plugins)
      'syspath':     sysfs directory for the device that needs this driver
                     (not for drivers from detect plugins)
      'plugin':      Name of plugin that detected this package (only for
                     drivers from detect plugins)
      'free':        Boolean flag whether driver is free, i. e. in the "main"
                     or "universe" component.
      'from_distro': Boolean flag whether the driver is shipped by the distro;
                     if not, it comes from a (potentially less tested/trusted)
                     third party source.
      'vendor':      Human readable vendor name, if available.
      'model':       Human readable product name, if available.
      'recommended': Some drivers (nvidia, fglrx) come in multiple variants and
                     versions; these have this flag, where exactly one has
                     recommended == True, and all others False.
    �10deN)r1r�r
rr�r�r�r(cSrr
rr�rrrrR/rz0system_gpgpu_driver_packages.<locals>.<listcomp>rrrr)rMr.rr�rr�r�r�rr�r�r�r�r�rr,r?rrrr�_cmp_gfx_alternatives_gpgpu)r\rB�vendors_whitelistr�rrzr�r�r�r�r��	vendor_id�model_idr(rrrrrrr�system_gpgpu_driver_packages�sT"
���
��
�r3c
Cs2i}|s%zt�d�}Wnty$}z
t�|�iWYd}~Sd}~wwt|||d���D]G\}}d|vr;|d}n|d}|�|i�dD]}||vrU|||||<qG||�di�}	|d|dd	�|	|<d
|vru|d
|	|d
<q.|��D]\}
}|dD]}t|||�s�nq�d|d<qzt	|�|S)
uGet by-device driver packages that are available for the system.

    This calls system_modaliases() to determine the system's hardware and then
    queries apt about which packages provide drivers for each of those. It also
    adds available packages from detect_plugin_packages(), using the name of
    the detction plugin as device name.

    If you already have an apt_pkg.Cache() object, you should pass it as an
    argument for efficiency. If not given, this function creates a temporary
    one by itself.

    If freeonly is set to True, only free packages (from main and universe) are
    considered

    Return a dictionary which maps devices to available drivers:

      device_name →  {'modalias': 'pci:...', <device info>,
                      'drivers': {'pkgname': {<driver package info>}}

    A key (device name) is either the sysfs path (for drivers detected through
    modaliases) or the detect plugin name (without the full path).

    Available keys in <device info>:
      'modalias':    Modalias for the device that needs this driver (not for
                     drivers from detect plugins)
      'vendor':      Human readable vendor name, if available.
      'model':       Human readable product name, if available.
      'drivers':     Driver package map for this device, see below. Installing any
                     of the drivers in that map will make this particular
                     device work. The keys are the package names of the driver
                     packages; note that this can be an already installed
                     default package such as xserver-xorg-video-nouveau which
                     provides a free alternative to the proprietary NVidia
                     driver; these will have the 'builtin' flag set.
      'manual_install':
                     None of the driver packages are installed, but the kernel
                     module that it provides is available; this usually means
                     that the user manually installed the driver from upstream.

    Aavailable keys in <driver package info>:
      'builtin':     The package is shipped by default in Ubuntu and MUST
                     NOT be uninstalled. This usually applies to free
                     drivers like xserver-xorg-video-nouveau.
      'free':        Boolean flag whether driver is free, i. e. in the "main"
                     or "universe" component.
      'from_distro': Boolean flag whether the driver is shipped by the distro;
                     if not, it comes from a (potentially less tested/trusted)
                     third party source.
      'recommended': Some drivers (nvidia, fglrx) come in multiple variants and
                     versions; these have this flag, where exactly one has
                     recommended == True, and all others False.
    N)rr�r)r1r�r��driversr
r)r
rrT�manual_install)
r.rr�rr�r!r�r�r��
_add_builtins)r\rBrr�rr��pkginfo�device_name�opt_keyr4r5r�rrr�system_device_drivers>sH5
���
�
����r:c	Cs�t||||d�}t||�}|st�d�|St�|�}t�|�}g}|D]V}	||	}
|
jsz|�|	�|�	|
�}|�
|jd�|dr]ztdd�}|�
d�|��Wn	ty\Ynwzt||	�}
|
ro||
jso|�|
�Wq$tyyYq$wq$|S)z4Return the list of packages that should be installed)rrz"No drivers found for installation.rr��/run/nvidia_runtimepm_supportedr�
)r!�auto_install_filterrrr.rUryr��appendrVr{r|r9rr�PermissionError�get_linux_modules_metapackagerT)r\rB�	free_onlyr�
driver_stringrzr`r��
to_installr��package_objra�pm_fd�modules_packagerrr�get_desktop_package_list�sF�







�

���rGcCs0|D]}t|�}|��dkrtd�dSqdS)zHApplies changes that need to happen before installing the NVIDIA driversi�rN)rr'r)rC�package_namer)rrr�$nvidia_desktop_pre_installation_hook�s��rIcCsztj�d�r;t�d�z	t�ddg�Wn	tyYnwtdd��}|�	d�Wd�dS1s4wYdSdS)Nr;z,Trying to select the on-demand PRIME profilez/usr/bin/prime-selectz	on-demandz$/etc/u-d-c-nvidia-runtimepm-overriderz!# File created by ubuntu-drivers
)
r7r:�isfilerrr��callr�r9r)rGrrr�%nvidia_desktop_post_installation_hook�s
�"��rLc@seZdZddd�Zdd�ZdS)�_GpgpuDriverNcCsd|_||_||_dS)N)r)�_vendors_whitelistr��flavour)rr�rOrrrr�s
z_GpgpuDriver.__init__cCs,|jr
t�|j|j�s
dS|jo|jS)NF)r�rv�filterrNrOr"rrrr�sz_GpgpuDriver.is_validr�)r)r*r+rrrrrrrM�s
rMcCs�t�}t�d�}t�d�}t�d�}|�|�}|�|�}|�|�}|r8|�d�|_d|�d�|�d�f|_|S|r?||_|S|rNd|�d�|�d�f|_|S)zReturns a _GpgpuDriver objectz(.+):([0-9]+)(.*)z([a-z]+)z([0-9]+)(.*)rz%s%sr�r#)rMrrrrr�rO)�stringr5�full_pattern�vendor_only_pattern�series_only_pattern�
full_match�vendor_match�series_matchrrr�_process_driver_string�s"





��rXcCs�g}g}i}	|s|S|r%|�d�D]}t|�}|r#|��r#|�|�qnt�}|�|�t|�dkr5|Sd}|D]}|jsCd||_|d7}q9d}g}|D]}|j}	|�|	�rat�	d�|S|�|	�|d7}qNd}|D]}|j
s||js|d||_|d7}qo|D]}|j
r�d|j|j
f}
nd|j}
|�t�
||
��q�|D]&}|D]!}|�|j�r�|j
r�||||<n
||�d�r�||||<nq�q�|S)	Nrsrrrz0Multiple nvidia versions passed at the same timez%s*%sz%s*r)r@rXrr>rM�lenr��__contains__rrrO�extendrvrPrX)rz�drivers_strr4�allowr��itemr5�it�vendors_tempr�rr�rrr�gpgpu_install_filtersh
��









��
racCspgd�}|r
t||�}|Sg}|D]}|�t�||��qi}|D]}d||vs/||dr5||||<q!|S)a�Get packages which are appropriate for automatic installation.

    Return the subset of the given list of packages which are appropriate for
    automatic installation by the installer. This applies to e. g. the Broadcom
    Wifi driver (as there is no alternative), but not to the FGLRX proprietary
    graphics driver (as the free driver works well and FGLRX does not provide
    KMS).
    )zbcmwl*z	pvr-omap*zvirtualbox-guest*znvidia-*zopen-vm-tools*r	r)rar[rvrP)rzr\�	whitelist�resultsr]rr�r�rrrr=js

�r=cCs�i}tj�dd�}tj�|�st�d|�|S|dur<zt�d�}Wnt	y;}z
t�
|�iWYd}~Sd}~wwt�|�D]�}|�d�sIqAtj�
||�}t�d|�i}t|���}ztt|��|d�|�|d|�}t�d	||�Wnt	y�t�d
|�YWd�qAw|dur�	Wd�qAt|�ttfvr�t�
d|t|��	Wd�qA|D]&}	z||	}
t||
�r�|�|g��|	�Wq�ty�t�d|	|�Yq�wWd�n1s�wYqA|S)
aaGet driver packages from custom detection plugins.

    Some driver packages cannot be identified by modaliases, but need some
    custom code for determining whether they apply to the system. Read all *.py
    files in /usr/share/ubuntu-drivers-common/detect/ or
    $UBUNTU_DRIVERS_DETECT_DIR and call detect(apt_cache) on them. Filter the
    returned lists for packages which are available for installation, and
    return the joined results.

    If you already have an existing apt_pkg.Cache() object, you can pass it as an
    argument for efficiency.

    Return pluginname -> [package, ...] map.
    �UBUNTU_DRIVERS_DETECT_DIRz(/usr/share/ubuntu-drivers-common/detect/z3Custom detection plugin directory %s does not existNz.pyz"Loading custom detection plugin %s�exec�detectzplugin %s return value: %szplugin %s failed:z6plugin %s returned a bad type %s (must be list or set)z.Ignoring unavailable package %s from plugin %s)r7r�rXr:�isdirrrr.rr�r��listdir�endswithr;r9rerr<�	exception�typer�r�rmr�r>rT)r\rz�	plugindirr�fnamer�symbrGr�r�r]rrrr�sf�
��

���
�����rcCst�|�r
t�|��d�SdS)z5Look up driver package and return their support levelr�N)rrX)rQrrr�_pkg_support_from_cache�s
rocCs�|�d�r|�d�sdS|�d�s|�d�rdS|�d�r$|�d�s$dS|�d�s0|�d�r0dSddg}d}d}t|�}t|�}||vrH|d7}||vrP|d7}||krY|d7}n||kra|d7}|dksi|dkru||krodS||krudSt|�dkr�t|�dkr�dSt|�dkr�t|�dkr�dSt|�dkr�t|�dkr�dSt|�dkr�t|�dkr�dSt|�d	kr�t|�d	kr�dSt|�d	kr�t|�d	kr�dSt|�d
kr�t|�d
kr�dSt|�d
kr�t|�d
kr�dS||kr�dS||kr�dS||ks�J�dS)aCompare two graphics driver names in terms of preference. (desktop)

    -open always sorts after non-open.
    -server always sorts after non-server.
    LTSB (Long Term Support Branch) always sorts before NFB (New Feature Branch).
    Legacy always sorts before Beta.
    rrrrr�r�r�dr��Beta�riro)rQ�y�preferred_support�x_score�y_score�	x_support�	y_supportrrrr�s`	
rcCsh|�d�r|�d�sdS|�d�s|�d�rdS|�d�r$|�d�s$dS|�d�s0|�d�r0dSt|�dkr>t|�dkr>dSt|�dkrLt|�dkrLdSt|�dkrZt|�dkrZdSt|�dkrht|�dkrhdSt|�dkrvt|�dkrvdSt|�dkr�t|�dkr�dSt|�dkr�t|�dkr�dSt|�dkr�t|�dkr�dS||kr�dS||kr�dS||ks�J�d	S)
aCompare two graphics driver names in terms of preference. (server)

    -open always sorts after non-open.
    -server always sorts before non-server.
    LTSB (Long Term Support Branch) always sorts before NFB (New Feature Branch).
    Legacy always sorts before Beta.
    rrrrr�r�r�rqrrr)rQrsrrrr/s<r/cCs�|��D]>\}}|dD]5}|�d�r ddddd�|dd<n"|�d�rA|dD]
}d|d|d<q)ddddd�|dd	<nqqd
S)zAdd builtin driver alternativesr4rTF)r
�builtinrrzxserver-xorg-video-nouveaur�rzxserver-xorg-video-atiN)r�r?)r4�devicer�r��drrrr6:s
�
����r6cC�t�|�}|��S)z0Return the linux headers for the system's kernel)r�KernelDetection�get_linux_headers_metapackage�r\�kernel_detectionrrr�get_linux_headersP�
r�cCr|�z.Return the linux image for the system's kernel)rr}�get_linux_image_metapackagerrrr�get_linux_imageVr�r�cCr|r�)rr}�get_linux_versionrrrrr�\r�r�cCr|)z4Return the linux metapackage for the system's kernel)rr}�get_linux_metapackagerrrr�	get_linuxbr�r�c	Cs�t�|�}z	|�||�}Wntyt�d|�YdSwz |j�d�D]}|D]\}}}|�d�r<|WSq+q'WdStt	fySt�d|�YdSw)NzNo candidate for %s foundrN�linux-image-z+Could not check dependencies for %s package)
r.rUrVrTrrrWrXr?rY)r\r�r`rarcrdrerfrrr�get_linux_image_from_metahs(
�
�����r�cCs|dusJ�d}d}d}t�|�}t|�}|js!t�d|�|S|��r.t�d|�|St|�}t||�}|r@|�	dd�}n	t�d|�|S|�
�}	d|	|f}
zB||
}|�|�}|r�|jdt
�fvr�t|�}
d|	|
f}t�d	|�||}|�|�}|r�|jdt
�fvr�t�d
|�|
}Wnty�t�d|
�Ynw|r�dd
�||jD�}d}d|	t|��	dd�f}|D]}||kr�|}q�|r�|}|Sd|	}t�d|�z||}|�|�}|r�|jdt
�fvr�|}W|SW|SW|St�y
t�d|�Y|Sw)zDReturn the linux-modules-$driver metapackage for the system's kernelNrzNNon NVIDIA linux-modules packages are not supported at this time: %s. Skippingr&r�z-No linux-image can be found for %s. Skipping.zlinux-modules-nvidia-%s-%srozlinux_modules_abi_candidate: %szFound ABI compatible %szNo "%s" can be found.cSs"g|]
}|jj�d�r|jj�qS)zlinux-modules-nvidia-)rOrr?)rPrlrrrrR�s�z1get_linux_modules_metapackage.<locals>.<listcomp>znvidia-dkms-%szFalling back to %s)r.rUrrrrr#r�r�rSr(rVr'r0r�rTr[r�)r\rar(�
linux_flavour�linux_modules_matchr`r)�linux_image_meta�linux_imager*�linux_modules_candidater]r+�
linux_version�linux_modules_abi_candidate�abi_specific�abi_specific_candidate�reverse_deps�pick�modules_candidaterl�dkms_packagerrrr@�s�



����
����r@r!)NNFT)NNTr�)NNF)NFTr)r):r,r7rrvr�rrr�r.�
UbuntuDriversrr-rr��objectrr0rMrmr�r�r�r�r�r�r�r�r�r�r�r�r�rrr!r�r,r-r3r:rGrIrLrMrXrar=rrorr/r6r�r�r�r�r�r@rrrr�<module>sp
8
/88)#
`
%
=
R
\-

d
>D* 

Spamworldpro Mini