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/DistUpgrade/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/DistUpgrade/__pycache__/DistUpgradeQuirks.cpython-310.pyc
o

S(e��@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	m
Z
ddlmZddl
mZGdd�de�ZdS)�N)�PIPE�Popen�)�get_arch)�gettextc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dodIdJ�Z'dpdLdM�Z(dNdO�Z)dPdQ�Z*dRdS�Z+dqdUdV�Z,dWdX�Z-dYdZ�Z.d[d\�Z/d]d^�Z0d_d`�Z1dadb�Z2dcdd�Z3drdfdg�Z4drdhdi�Z5dsdkdl�Z6dmdn�Z7dKS)t�DistUpgradeQuirksz�
    This class collects the various quirks handlers that can
    be hooked into to fix/work around issues that the individual
    releases have
    cCsd||_|j|_||_tddgtdd���d��|_t�|_	d|_
d|_d|_d|_
d|_d|_dS)N�unamez-rT��stdout�universal_newlinesrF)�
controller�_view�configrr�communicate�striprr�arch�extra_snap_space�_poke�_snapstore_reachable�
_snap_list�
_from_version�_to_version)�selfrr�r�?/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeQuirks.py�__init__-s"
���
zDistUpgradeQuirks.__init__cCs�|jjrt�d�dS|j�dd�}|j�dd�}d|}t||d�}|dur1t�d|�|�d||f}t||d�}|durKt�d|�|�d	||f}t||d�}|durgt�d|�|�dSdS)
a�
        Run the specific quirks handler, the follow handlers are supported:
        - PreCacheOpen: run *before* the apt cache is opened the first time
                        to set options that affect the cache
        - PostInitialUpdate: run *before* the sources.list is rewritten but
                             after an initial apt-get update
        - PreDistUpgradeCache: run *right before* the dist-upgrade is
                               calculated in the cache
        - PostDistUpgradeCache: run *after* the dist-upgrade was calculated
                                in the cache
        - StartUpgrade: before the first package gets installed (but the
                        download is finished)
        - PostUpgrade: run *after* the upgrade is finished successfully and
                       packages got installed
        - PostCleanup: run *after* the cleanup (orphaned etc) is finished
        z)not running quirks in partialUpgrade modeN�Sources�To�From�%szquirks: running %sz%s%sz	from_%s%s)r�_partialUpgrade�logging�infor�get�getattr�debug)r�
quirksName�
to_release�from_release�funcname�funcrrr�run?s*

�zDistUpgradeQuirks.runcC�t�d�dS)z3 run before the apt cache is opened the first time zrunning Quirks.PreCacheOpenN�r!r%�rrrr�PreCacheOpenm�zDistUpgradeQuirks.PreCacheOpencCs�t�d�|��|��|��|��|��|jj}|�	|�|�
�d|vr1t�d�dS|djrFtj
�d�sBtj
�d�rF|��|jrO|��dSdS)z2 run after the apt cache is opened the first time z%running Quirks.jammyPostInitialUpdate�snapd�'package required for Quirk not in cacheNz/run/snapd.socketz/run/snapd-snap.socket)r!r%�_get_from_and_to_version�_test_and_fail_on_i386�_test_and_fail_on_aufs�_test_and_fail_on_power8�_test_and_fail_on_pam_tallyr�cache�_test_and_warn_if_ros_installed�_fix_missing_nvidia_metapackage�is_installed�os�path�exists�_checkStoreConnectivityr�_calculateSnapSizeRequirements�rr8rrr�jammyPostInitialUpdaters*




�
��z(DistUpgradeQuirks.jammyPostInitialUpdatecCs�t�d�|jj}d|vrt�d�dS|djr |jr |��d|vr-|djr-|��d|vr@|djrB|��|�	�dSdSdS)Nzrunning Quirks.jammyPostUpgrader1r2zubuntu-desktop-raspizlinux-firmware-raspi2)
r!r%rr8r;r�_replaceDebsAndSnaps�_replace_fkms_overlay�_remove_uboot_on_rpi�_remove_netplan_match_rpirArrr�jammyPostUpgrade�s$


�

�z"DistUpgradeQuirks.jammyPostUpgradecCr,)z run after cleanup zrunning Quirks.PostCleanupNr-r.rrr�PostCleanup�r0zDistUpgradeQuirks.PostCleanupcCs>t�d�|��|��|��|��|��|��dS)Nzrunning Quirks.StartUpgrade)r!r%�
_applyPatches�_removeOldApportCrashes�_killUpdateNotifier�_killKBluetooth�_pokeScreensaver�_stopDocvertConverterr.rrr�StartUpgrade�s
zDistUpgradeQuirks.StartUpgradecCr,)z/ run right before calculating the dist-upgrade z"running Quirks.PreDistUpgradeCacheNr-r.rrr�PreDistUpgradeCache�r0z%DistUpgradeQuirks.PreDistUpgradeCachecCst�d�|��dS)z( run after calculating the dist-upgrade z#running Quirks.PostDistUpgradeCacheN)r!r%�_install_linux_metapackager.rrr�PostDistUpgradeCache�s
z&DistUpgradeQuirks.PostDistUpgradeCachecCsjt�}z
tjddgtjdd�}Wnty|YSw|��d�d�D]
}|r2|�|��d�q%|S)z8 return a set of pci ids of the system (using lspci -n) �lspciz-nTr	r�
�)�set�
subprocessrr�OSErrorr�split�add)rrS�p�linerrr�_get_pci_ids�s
���zDistUpgradeQuirks._get_pci_idscs�t��}z|�d�jj���d�_|�d�jj���d�_WdSt	yYt
�fdd�|�d�D��jj���d�_t
�fdd�|�d�D��jj���d�_YdSw)Nrrc3�$�|]
}|j�jjkr|jVqdS�N)�seriesr�fromDist�version��.0�rr.rr�	<genexpr>�����z=DistUpgradeQuirks._get_from_and_to_version.<locals>.<genexpr>�objectc3r^r_)r`r�toDistrbrcr.rrrf�rg)�distro_info�UbuntuDistroInforbrrarYrrir�AttributeError�next�get_all)r�dirr.rr3�s(�
������z*DistUpgradeQuirks._get_from_and_to_versioncCs�d}tj�|�r
dtjvrdStjgd�ttjd�d�}|dkr't�	d�dSt�|g�}t�	d||f�|dkrN|j
�td	�td
��}|sP|j
��dSdSdS)Nz/usr/lib/nux/unity_support_test�DISPLAY)�psz-Czunity-panel-service�w)r
rz5_test_and_warn_for_unity_3d_support: no unity runningz6_test_and_warn_for_unity_3d_support '%s' returned '%s'zBYour graphics hardware may not be fully supported in Ubuntu 14.04.aSRunning the 'unity' desktop environment is not fully supported by your graphics hardware. You will maybe end up in a very slow environment after the upgrade. Our advice is to keep the LTS version for now. For more information see https://wiki.ubuntu.com/X/Bugs/UpdateManagerWarningForUnity3D Do you still want to continue with the upgrade?)r<r=r>�environrW�call�open�devnullr!r%r
�askYesNoQuestion�_r�abort)r�UNITY_SUPPORT_TEST�return_code�resrrr�#_test_and_warn_for_unity_3d_support�s6
������
z5DistUpgradeQuirks._test_and_warn_for_unity_3d_supportcCsNgd�}|��}t|��|�r#|j�td�td��}|s%|j��dSdSdS)N)z	8086:7121z	8086:7125z	8086:1132z	8086:3577z	8086:2562z	8086:3582z	8086:2572zFYour graphics hardware may not be fully supported in Ubuntu 12.04 LTS.z�The support in Ubuntu 12.04 LTS for your Intel graphics hardware is limited and you may encounter problems after the upgrade. For more information see https://wiki.ubuntu.com/X/Bugs/UpdateManagerWarningForI8xx Do you want to continue with the upgrade?)r]rV�intersectionr
rwrxrry)r�I8XX_PCI_IDSrSr|rrr�_test_and_warn_on_i8xx�s�
�z(DistUpgradeQuirks._test_and_warn_on_i8xxcCs�|�d�rJ|�d�sL|j�td�td��}|s|j��gd�}t�dd�	|��|jj
�dd�}|D]}|�|�q4|jj
�
ddd	�	|��d
Sd
Sd
S)zi
        Some cards are no longer supported by fglrx. Check if that
        is the case and warn
        �fglrxzhUpgrading may reduce desktop effects, and performance in games and other graphically intensive programs.z�This computer is currently using the AMD 'fglrx' graphics driver. No version of this driver is available that works with your hardware in Ubuntu 10.04 LTS.

Do you want to continue?)zxorg-driver-fglrxzxorg-driver-fglrx-envyzfglrx-kernel-sourcezfglrx-amdccclezxorg-driver-fglrx-dev�libamdxvba1z	remove %s�, �Distro�PostUpgradePurge�,N)�_checkVideoDriver�_supportInModaliasesr
rwrxrryr!r%�joinr�getlist�appendrV)rr|�removals�postupgradepurge�removerrr�'_test_and_warn_on_dropped_fglrx_supports*
��
���z9DistUpgradeQuirks._test_and_warn_on_dropped_fglrx_supportcCsl|jdkrd}n|jdkrd}|jdkr4t�d�td�}td|j|f�}|j�||�|j��d	Sd	S)
z}
        Test and fail if the package architecture is i386 as we
        have dropped support for this architecture.
        z18.04z
April 2023z19.04zJanuary 2020�i386zapt architecture is i386�'Sorry, no more upgrades for this systemz�There will not be any further Ubuntu releases for this system's 'i386' architecture.

Updates for Ubuntu %s will continue until %s.N)rrr!�errorrxr
rry)r�updates_end�summary�msgrrrr4=s



��z(DistUpgradeQuirks._test_and_fail_on_i386cCs>|jdkr|��s|j�td�td��|j��dSdSdS)z~
        Test and fail if the cpu is not a arm v6 or greater,
        from 9.10 on we do no longer support those CPUs
        �armelzNo ARMv6 CPUz�Your system uses an ARM CPU that is older than the ARMv6 architecture. All packages in karmic were built with optimizations requiring ARMv6 as the minimal architecture. It is not possible to upgrade your system to a new Ubuntu release with this hardware.N)r�_checkArmCPUr
r�rxrryr.rrr�_test_and_fail_on_non_arm_v6Qs
�	�z.DistUpgradeQuirks._test_and_fail_on_non_arm_v6cCsPdD]#}tj�|�r%t�d�td�}td|�}|j�||�|j��qdS)z�
        Test and fail if docker has aufs storage driver available
        as it is deprecated after 20.04. Even if no containers are
        currently running aufs, the upgrade could break existing
        container images.
        )z+/var/snap/docker/common/var-lib-docker/aufsz/var/lib/docker/aufszDocker config uses aufszISorry, this storage driver is not supported in kernels for newer releasesz�There will not be any further Ubuntu releases that provide kernel support for the aufs storage driver.

Please ensure that none of your containers are using the aufs storage driver, remove the directory %s and try again.N)	r<r=r>r!r�rxr
rry)r�aufs_dirr�r�rrrr5cs
�
��z(DistUpgradeQuirks._test_and_fail_on_aufsc	Cs�t�d�D]U}|dvrqttj�d|���=}|��}t�d|tj�rKt	�
d�td�}td�dtd�}|j�
||�|j
��	Wd	�d	SWd	�n1sUwYqd	S)
a�
        Test and fail if pam_tally or pam_tally2 appears in the system's
        PAM config for any service.  These modules have been dropped as
        obsolete, so references to them in the config will break services
        on upgrade.  The libpam-modules package has a preinst that will also
        enforce this, but we want to enforce at the start of the upgrade
        before we get halfway through an apt transaction.  LP: #1977493
        z
/etc/pam.d)zcommon-accountzcommon-authzcommon-passwordzcommon-sessionzcommon-session-noninteractivez^[^#]*pam_tallyzpam_tally* in usez<You are using pam_tally or pam_tally2 in your configuration.aNThe pam_tally and pam_tally2 modules have been removed from PAM. You are using one of these modules in your PAM configuration in /etc/pam.d. You must remove the uses of these modules before PAM can be upgraded; including these modules in your PAM configuration after the upgrade will stop users from being able to log into the system.z

z@Consider the pam_faillock module as a replacement for pam_tally.N)r<�listdirrur=r��read�re�search�	MULTILINEr!r�rxr
rry)r�f�contentr�r�rrrr7ys*

��

����z-DistUpgradeQuirks._test_and_fail_on_pam_tallycCs�|jdkrdSd}|jdkrd}n|jdkrd}td��;}|��}t�d	|tj�rOt�d
�t	d�}t	d|j|f�}|j
�||�|j��Wd�dSWd�dS1sZwYdS)
a#
        Test and fail if running on a POWER8 processor. Starting with Ubuntu
        22.04, ppc64el is compiled for POWER9 processors. Prior to 22.04 it
        was/is compiled for POWER8 processors. Hence POWER8 processors are not
        able to run, install or upgrade to jammy.
        �ppc64elN�z20.04z
April 2025z21.10z	July 2022�
/proc/cpuinfoz^cpu\s*:\s*POWER8zPOWER8 processor detectedr�z�There will not be any further Ubuntu releases for this system's POWER8 processor.

Updates for Ubuntu %s will continue until %s.)
rrrur�r�r�r�r!r�rxr
rry)rr�r��cpuinfor�r�rrrr6�s(




��"�z*DistUpgradeQuirks._test_and_fail_on_power8cCs`z	t�dd�WdSty/t�d�|j�td�td��}|s'|j�	�|j�
�YdSw)zd
        upstart and vserver environments are not a good match, warn
        if we find one
        rrz
no init foundzNo init availableaYour system appears to be a virtualised environment without an init daemon, e.g. Linux-VServer. Ubuntu 10.04 LTS cannot function within this type of environment, requiring an update to your virtual machine configuration first.

Are you sure you want to continue?N)r<�killrXr!�warningr
rwrxrry�
processEvents�rr|rrr�_test_and_warn_if_vserver�s
�
�z+DistUpgradeQuirks._test_and_warn_if_vservercCs�t�}dD]}|�t�d|��qd}|D]}|rn|D]}|�|j�r0|js,|jr.d}nqq|rH|j�	t
d�t
d��}|sJ|j��dSdSdS)z�
        Test and warn if ROS is installed. A given ROS release only
        supports specific Ubuntu releases, and can cause the upgrade
        to fail in an overly-cryptic manner.
        )�catkinzrosboost-cfg�roscleanzros-environmentz
ros-workspacez
ros-[^\-]+-%sFTz-The Robot Operating System (ROS) is installeda	It appears that ROS is currently installed. Each ROS release is very strict about the versions of Ubuntu it supports, and Ubuntu upgrades can fail if that guidance isn't followed. Before continuing, please either uninstall ROS, or ensure the ROS release you have installed supports the version of Ubuntu to which you're upgrading.

For ROS 1 releases, refer to REP 3:
https://www.ros.org/reps/rep-0003.html

For ROS 2 releases, refer to REP 2000:
https://www.ros.org/reps/rep-2000.html

Are you sure you want to continue?N)
rVrZr��compile�match�namer;�marked_installr
rwrxrry)rr8�ros_package_patterns�package_name�ros_is_installed�pkg�patternr|rrrr9�s2�����z1DistUpgradeQuirks._test_and_warn_if_ros_installedcCslt�d�tj�d�st�d�dStd��}|��}Wd�n1s%wYt�	d|tj
�r4dSdS)zE
        parse /proc/cpuinfo and search for ARMv6 or greater
        zchecking for ARM CPU versionr�zcannot open /proc/cpuinfo ?!?FNz^Processor\s*:\s*ARMv[45]T)r!r%r<r=r>r�rur�r�r�r�)rr�r�rrrr�s



��zDistUpgradeQuirks._checkArmCPUcCsZt�d�tj�d�st�d�dStd��
}|��}Wd�|S1s&wY|S)z�
        read /sys/class/dmi/id/sys_vendor in case there are
        system specific issues with upgrading e.g LP: #1928434
        zchecking for system vendorz/sys/class/dmi/id/sys_vendorz(cannot open /sys/class/dmi/id/sys_vendorr�N)r!r%r<r=r>r�rur�)rr��vendorrrr�_readDMIVendors




��z DistUpgradeQuirks._readDMIVendorcC�,tj�d�rt�d�t�ddg�dSdS)z, /etc/init.d/apparmor stop (see bug #559433)z/etc/init.d/apparmorz/etc/init.d/apparmor stop�stopN�r<r=r>r!r%rWrtr.rrr�
_stopApparmor�
�zDistUpgradeQuirks._stopApparmorcCr�)z5 /etc/init.d/docvert-converter stop (see bug #450569)z/etc/init.d/docvert-converterz"/etc/init.d/docvert-converter stopr�Nr�r.rrrrN#r�z'DistUpgradeQuirks._stopDocvertConvertercC�,tj�d�rt�d�t�gd��dSdS)zkill update-notifier�/usr/bin/killallzkilling update-notifier)�killall�-qzupdate-notifierNr�r.rrrrK)s
�z%DistUpgradeQuirks._killUpdateNotifiercCr�)z3killall kblueplugd kbluetooth (riddel requested it)r�zkilling kblueplugd kbluetooth4)r�r��
kblueplugd�kbluetooth4Nr�r.rrrrL0r�z!DistUpgradeQuirks._killKBluetoothc	Cs�tj�d�r>tj�d�r@t�d�d}|d7}|d7}ztj|dd�|_	t
�|j�WdSt
tfy=t�d	�YdSwdSdS)
Nz/usr/bin/xdg-screensaverrpz$setup poke timer for the screensaverzwhile true;z3 do /usr/bin/xdg-screensaver reset >/dev/null 2>&1;z sleep 30; doneT)�shellz failed to setup screensaver poke)r<r=r>rsr#r!r%rWrr�atexit�register�_stopPokeScreensaverrX�
ValueError�	exception)r�cmdrrrrM6s
�
��z"DistUpgradeQuirks._pokeScreensavercCsNd}|jdur%z|j��|j��}Wnty!t�d�Ynwd|_|S)NFzfailed to stop screensaver poke)r�	terminate�waitrXr!r�r�rrrr�Cs

�z&DistUpgradeQuirks._stopPokeScreensaverc
Csvz dD]}t�d|�D]}t�d||f�t�|�qqWdSty:}zt�d|�WYd}~dSd}~ww)z: remove old apport crash files and whoopsie control files )z.crashz.uploadz	.uploadedz/var/crash/*%szremoving old %s file '%s'z+error during unlink of old crash files (%s)N)�globr!r%r<�unlink�	Exceptionr�)r�extr��errrrJNs����z)DistUpgradeQuirks._removeOldApportCrashescCsZd}tj��}d|d<tgd�tt|dd���}t�d|dtj�r'd|_	d	St�d
|dtj�rxt
�d�d}|jj
}d|vrU|djrU|djj�d
�sUt
�d�d}|rltd�}td�}|j�||�|j��n6|j�td�td��}n*d|dvr�t
�d�|j�td�td��}nd|dvr�d}t
�d�nt
�d�|s�|j��d	Sd	S)z: check for connectivity to the snap store to install snapsFzC.UTF-8�LANG)�snapr%�connectivityT)r
�stderr�envrz	^ \* PASSrNz^ \*.*unreachablezNo snap store connectivity�lxdz1:zlxd is installedz#Connection to the Snap Store faileda�You have the package lxd installed but your system is unable to reach the Snap Store. lxd is now provided via a snap and the release upgrade will fail if snapd is not functional. Please make sure you're connected to the Internet and update any firewall or proxy settings as needed so that you can reach api.snapcraft.io. If you are an enterprise with a firewall setup you may want to configure a Snap Store proxy.zConnection to Snap Store failedz�Your system does not have a connection to the Snap Store. For the best upgrade experience make sure that your system can connect to api.snapcraft.io.
Do you still want to continue with the upgrade?zerror: unknown commandrz snap debug command not availablezOutdated snapd packagez�Your system does not have the latest version of snapd. Please update the version of snapd on your system to improve the upgrade experience.
Do you still want to continue with the upgrade?zerror: access deniedzNot running as root!z-Unhandled error connecting to the snap store.)r<rs�copyrrrr�r�r�rr!r�rr8r;�	candidaterb�
startswithrxr
ryrw)rr|�snap_env�	connected�old_lxd_deb_installedr8r�r�rrrr?XsX

��

�
�
�
�z)DistUpgradeQuirks._checkStoreConnectivitycCs0ddl}ddl}ddlm}|��|j�td��|j�	�D]v\}}|ddkr*qdd|d|d	d
�}g|gd�}|j
jdt|�
|�d
d�d�}|�dd�|�dd�|�d|j�z|j
�|���}	|�|	�}
t|
ddddd�}Wnt|tfy�t�d|�Yqw|j|7_qdS)Nr)�URLErrorz"Calculating snap size requirements�command�installzupgrade-size-check�download�snap-id�channel)zinstance-key�actionr�r�)�context�actionsz)https://api.snapcraft.io/v2/snaps/refresh�utf-8��encoding)�url�datazSnap-Device-Series�16zContent-typezapplication/jsonzSnap-Device-Architecture�resultsr��sizezFailed fetching size of snap %s)�json�urllib.request�urllib.errorr��_prepare_snap_replacement_datar
�updateStatusrxr�items�request�Request�bytes�dumps�
add_headerr�urlopenr��loads�int�KeyErrorr�r!r%r)rr��urllibr�r��snap_objectr�r��req�responser"r�rrrr@�sB���
 ��z0DistUpgradeQuirks._calculateSnapSizeRequirementsc	Cs>|j�td��|j��D]�\}}|d}|dkr-|j�td|��d|d|d|g}n'|dkrA|j�td	|��d||g}n|j�td
|��d|d|d|g}z|j��tj|tjdd�}|j��Wntj	y|t
�d
||f�Yq
w|jdkr�t
�d||f�|dkr�|dr�|j
j�|d�q
dS)z? install a snap and mark its corresponding package for removal zProcessing snap replacementsr��refreshzrefreshing snap %sr�z	--channelr�r�zremoving snap %szinstalling snap %sT)r
�checkz%s of snap %s failedrz%s of snap %s succeededr��debN)r
r�rxrr�r�rWr+r�CalledProcessErrorr!r%�
returncoder�forced_obsoletesr�)rr�r�r��	popenargs�procrrrrC�sB
�
�
��
��z&DistUpgradeQuirks._replaceDebsAndSnapscCs�t�d�d}td��}|��}Wd�n1swYt�d|tj�r)d}|sFt�d�td�}td	�}|j	�||�|j
��dSdS)
z check PAE in /proc/cpuinfo �	_checkPaerr�Nz^flags\s+:.* pae rzno pae in /proc/cpuinfozPAE not enabledz�Your system uses a CPU that does not have PAE enabled. Ubuntu only supports non-PAE systems up to Ubuntu 12.04. To upgrade to a later version of Ubuntu, you must enable PAE (if this is possible) see:
http://help.ubuntu.com/community/EnablingPAE)r!r%rur�r�r�r�r�rxr
rry)r�paer�r�r�r�rrrr�s


�
�zDistUpgradeQuirks._checkPaecCs�d}tj�|�s
dSt|��}|��}Wd�n1swY|D]}|�d�d��}|���d�r@|�	d|�r@dSq$dS)	z2 check if the given driver is in use in xorg.conf z/etc/X11/xorg.confFN�#r�driverz"%s"T)
r<r=r>ru�	readlinesrYr�lowerr��endswith)rr��XORGr��linesr\�srrrr��s

���z#DistUpgradeQuirks._checkVideoDriver�	./patchesc
	Csntj�|�s
t�d�dSt�|�D]�}d|vr t�d|�qt�d|�|�dd�\}}}|�dd�}t�d	|||f�tj�|�sNt�d
|�qt�	�}t
|d��}|�|���Wd�n1siwY|�
�|kr|t�d|�q|�
�|kr�t�d
|�qddlm}	z|	|tj�||�|�t�d|�Wqty�t�d|�YqwdS)z�
        helper that applies the patches in patchdir. the format is
        _path_to_file.md5sum and it will apply the diff to that file if the
        md5sum matches
        zno patchdirN�.zskipping '%s' (no '.')z'check if patch '%s' needs to be appliedrUrx�/ztarget for '%s' is '%s' -> '%s'ztarget '%s' does not exist�rbz%already at target hash, skipping '%s'z(unexpected target md5sum, skipping: '%s'r)�patchzapplied '%s' successfullyzed failed for '%s')r<r=r>r!r%r��rsplit�replace�hashlib�md5ru�updater��	hexdigestr��DistUpgradePatcherrr�r"r�r�)
r�patchdirr��encoded_path�md5sum�
result_md5sumr=r�fdrrrrrIsH
�����zDistUpgradeQuirks._applyPatchesNc	Cs�|s|��}||jjvs|jj|jst�d�dS|jj|}|�|jj�D].\}}|D]'}t�	d|�}|rTd|�
d�|�
d�f}|��|vrTt�d|�dSq-q't�d	|�dS)
z�
        Check if pkgname will work on this hardware

        This helper will check with the modaliasesdir if the given
        pkg will work on this hardware (or the hardware given
        via the lspci argument)
        zcan not find '%s' in cacheFzpci:v0000(.+)d0000(.+)sv.*z%s:%srrUz%found system pciid '%s' in modaliasesTz4checking for %s support in modaliases but none found)
r]rr8r�r!r��!_parse_modaliases_from_pkg_header�recordr�r��groupr
r%)	r�pkgnamerSr��module�
pciid_list�pciid�m�matchidrrrr�3s2	�

�����z&DistUpgradeQuirks._supportInModaliasescCsdd|vrgSg}|d�d�D] }|�d�}|sq|�d�\}}|�|dd�|�d�D�f�q|S)z. return a list of (module1, (pciid, ...), ...)�
Modaliases�)r��(cS�g|]}|���qSr)r)rd�xrrr�
<listcomp>]�zGDistUpgradeQuirks._parse_modaliases_from_pkg_header.<locals>.<listcomp>r�)rYrr�)r�	pkgrecord�modulesr*r'�pciidsrrrr#Rs
 z3DistUpgradeQuirks._parse_modaliases_from_pkg_headercCs�t�d�|jj}d|vrt�d�dS|djs%|djs%t�d�dSz4ddl}|j��}|D]}d|j	vrAt�d�WdSq1t�
d�|�d	d
|jjdgd�|�
�WdStyht�d
�YdSw)N�_add_extras_repositoryzubuntu-extras-keyringz-no ubuntu-extras-keyring, no need to add repoz2ubuntu-extras-keyring not installed/marked_installrzextras.ubuntu.comz*found extras.ubuntu.com, no need to add itz/no extras.ubuntu.com, adding it to sources.listrzhttp://extras.ubuntu.com/ubuntu�mainz!Third party developers repositoryzerror adding extras.ubuntu.com)r!r%rr8r��	installed�aptsources.sourceslist�sourceslist�SourcesList�urir"rZri�saver�r�)rr8�
aptsources�sources�entryrrrr6`s6


�



�

��z(DistUpgradeQuirks._add_extras_repositorycCspz(|jj}d|vr |djr#d|vr&t�d�|�dd�WdSWdSWdSWdSty7t�d�YdSw)z� foomatic-db-gutenprint get removed during the upgrade,
            replace it with the compressed ijsgutenprint-ppds
            (context is foomatic-db vs foomatic-db-compressed-ppds)
        zfoomatic-db-gutenprintzijsgutenprint-ppdszinstalling ijsgutenprint-ppdsz1foomatic-db-gutenprint -> ijsgutenprint-ppds rulez_gutenprint_fixup failedN)rr8�
marked_deleter!r"�mark_installr�r�rArrr�_gutenprint_fixupzs �

���z#DistUpgradeQuirks._gutenprint_fixupr�cCstd}tj�|�s8zt�d�Wn	tyYnwt|d��}|�d|�Wd�dS1s1wYdSdS)z5 enable multiarch via /etc/dpkg/dpkg.cfg.d/multiarch z/etc/dpkg/dpkg.cfg.d/multiarchz/etc/dpkg/dpkg.cfg.d/rrzforeign-architecture %s
N)r<r=r>�makedirsrXru�write)r�foreign_arch�cfgr�rrr�_enable_multiarch�s�"��z#DistUpgradeQuirks._enable_multiarchcCszt�d�}|�|�}|�|�}|r+|r+d|�d�|�d�f}d|�d�|�d�f}t�d||f�tj�||�dkS)z# copied from ubuntu-drivers common z(.+)-([0-9]+)-(.+)�%s-%srrUzComparing %s with %sr)	r�r�r�r%r!r%�apt�apt_pkg�version_compare)r�term1�term2r��match1�match2rrr�_is_greater_than�s



�
�z"DistUpgradeQuirks._is_greater_thanc
Cs�|rdpd}t�d�}t�d�}d}d}|D]V}d|jvrld|jvrl|js(|jrl|�|j�}	|	rl|jjd}
d|	�d	�|	�d
�f}|�	||�rl|}|�|
�}d|
vrc|rcd||	�d
�|�d	�f}qd||	�d
�f}q|S)zb Get the linux headers or linux metapackage
            copied from ubuntu-drivers-common
        z-headersr�zlinux-image-(.+)-([0-9]+)-(.+)z
linux-(.+)zlinux-image�extra�SourcerIrrUz-lts-z
linux%s-%s-%s�z
linux%s-%s)
r�r�r�r;r�r�r�r$r%rQ)
rr8�headers�suffixr��source_pattern�metapackagerbr�r��source�current_version�match_sourcerrr�_get_linux_metapackage�sD

��
��
	���z(DistUpgradeQuirks._get_linux_metapackagecCs^|jj}|�|d�}||vrt�d|�dS||js-t�d|�d}|�||�dSdS)zo Ensure the linux metapackage is installed for the newest_kernel
            installed. (LP: #1509305)
        Fz$linux metapackage (%s) not availableNz installing linux metapackage: %sz8linux metapackage may have been accidentally uninstalled)rr8r\r!r"r;rB)rr8�linux_metapackage�reasonrrrrQ�s�
��z,DistUpgradeQuirks._install_linux_metapackagec
s�d}|jj�dD]U}|D]P\}}t�d||f�|�vr\�|jr\|rAt�d||f�d|}�j||d|d�sAt�d|�t�d	||f�d
|}�j||dd�s\t�d|�qqtj���}|D]^\}}|�vrĈ|jr�|r�|�vr��fd
d�|D�}t	d�}t	d||d�
|�f�}	t�|����|j�
||	�|j��n|��|�|��|�|��|�|��|�qf|��dS)z�
        Ensure python is removed, before it can produce a conflict with any
        other package and the python-is-python2 package is installed instead,
        if python-minimal was installed.
        ))z
python-dbgzpython2-dbg)z
python-doczpython2-doc)zpython-minimalzpython-is-python2)z
python-devzpython-dev-is-python2)z
libpython-devN)zlibpython-stdlibN)z
libpython-dbgN)FTzchecking for %s (auto_inst=%s)z&installing %s because %s was installedz%s was installed on the systemF)�auto_fix�	auto_instzfailed to install %sz)removing %s because %s is being installedz#%s is being installed on the system)r_zfailed to remove %scs&g|]\}}|�vr�|jr|�qSr)r;)rd�old�new�r8rrr1s
�
�z@DistUpgradeQuirks._install_python_is_python2.<locals>.<listcomp>zuniverse component not enableda�You have the package %s installed which is a python2 package. python2 has been deprecated in Ubuntu 20.04 LTS and is now available from the universe component of the Ubuntu archive. To ensure any existing third party code you have installed continues to work the release upgrade process would install %s for you. However, the universe component of the archive is not enabled on this system. For the upgrade process to proceed you should either enable the universe component in /etc/apt/sources.list or remove %sr�N)rr8r!r"r;rB�mark_removerJ�ProblemResolverrxr��_stopAptResolverLogr
r�ry�clear�protectr��resolve)
r�replacementsr`rarbr^�solver�old_instr�r�rrcr�_install_python_is_python2�sZ��
����
�
�z,DistUpgradeQuirks._install_python_is_python2cCsH|jjs tjj�d�s"d}|d7}t�|�tjj�dd�dSdSdS)z] ensure that on a desktop install recommends are installed
            (LP: #759262)
        zApt::Install-Recommendsz%Apt::Install-Recommends was disabled,z! enabling it just for the upgrade�1N)	r�
serverModerJrKr�find_br!r�rV)rr�rrr�+ensure_recommends_are_installed_on_desktops3s
�z=DistUpgradeQuirks.ensure_recommends_are_installed_on_desktopscCsT|�dd�}t|t�s|g}|D]}||jjvrq|r%|jj|jdur%qdSdS)z� Helper function that checks if the given deb2snap entry
            has at least one metapkg which is installed on the system.
        �metapkgNFT)r#�
isinstance�listrr8r;)r�deb2snap_entry�metapkg_listrrrrr�_is_deb2snap_metapkg_installed>s
z0DistUpgradeQuirks._is_deb2snap_metapkg_installedc
CsBddl}i|_d|j}d|j}i}i}zmtj�tj�t��}t	|dd�}|�
|�}|��|dD]'}	|d|	}
|�|
�sBq4|
�
dd�}|
�
d|�}|
�
d	|�}
|||
f||	<q4|d
D] }	|d
|	}|�
dd�}|�|�stq`|�
d|�}||f||	<q`Wnty�}z
t�d|�WYd}~nd}~wwd}tjd
dgdtjd���}|r�dd�|d�d�dd�D�}|D]}	|	|vs�|	|vr�q�d||f||	<q�|j�td��|��D]�\}	\}}}i}tjd
d|	gdtjd���}|j��t�d|dtj��r&t�d|	�t�d||dtj��s!t�d|	�q�d|d<n=|jj }|�rB||v�s8||j!�sBt�d||	f�q�t�d|d�}|�sUt�d |	�q�d!|d<||d<|d|d"<||d#<||j|	<q�|��D]�\}	\}}i}tjd
d|	gdtjd���}|j��t�d|dtj��rt�d|	�t�d||dtj��s�t�d|	��qqd$|d<tjd
d%|	gdtjd���}|j��|d�d�D]D}|��}t"|�d&k�r�q�|d}|d'}|�#|	d(��r|�d(�d}|d)k�r||v�rt�d*|	|f�d|d<d+|d#<n�q�||j|	<�qq|jS),z� Helper function fetching all required info for the deb-to-snap
            migration: version strings for upgrade (from and to) and the list
            of snaps (with actions).
        rNzstable/ubuntu-%sz/deb2snap.jsonre�seededr�from_channel�
to_channel�unseededz%error reading deb2snap.json file (%s)r�r�rtT)rr
cSsg|]}|��d�qS)r)rY�rdr\rrrr1}s�zDDistUpgradeQuirks._prepare_snap_replacement_data.<locals>.<listcomp>rTr���zChecking for installed snapsr"z^installed: zSnap %s is installedz^tracking:.*%sz+Snap %s is not tracking the release channelrr�zFDeb package %s is not installed. Skipping snap package %s installationzsnap-id:\s*(\w*)z'Could not parse snap-id for the %s snapr�r�r�r��connections�rU�:�-z9Snap %s is being used by %s. Switching it to stable track�stable)$r�rrrr<r=�dirname�abspath�__file__ru�load�closerwr#r�r!r�rWrrrrYr
r�rxr�r�r�r�r�r%rr8r;�lenr�)rr�ryrz�seeded_snaps�unseeded_snaps�current_path�d2s_file�d2sr��seedr�	from_chan�to_chan�unseedr��	snap_list�snaps_installedr��	snap_infor8r��conns�conn�	conn_cols�plug�slot�	plug_snaprrrr�Qs




���
�����


��
����


����


��
�z0DistUpgradeQuirks._prepare_snap_replacement_data�/boot/firmwarec	
Cs�d}z$tj�|d�}t|ddd��}|��}Wd�n1s wYWnty7t�d||�YdSwd�dd	�|jd
d�D��}||krRt�	d|�dSz%tj�|d
�}t|ddd��
}|�
|�Wd�n1sqwYWnty�}zt�d|||�WYd}~dSd}~wwz!t|ddd��}|�
|�Wd�WdS1s�wYWdSty�}zt�d|||�WYd}~dSd}~ww)NzfYou may need to replace the vc4-fkms-v3d overlay with vc4-kms-v3d in config.txt on your boot partition�
config.txtrer�r��+failed to open boot configuration in %s; %sr�cssP�|]#}|�d�rd||�dd�n|�d�s|��dkr"d|n|VqdS)zdtoverlay=vc4-fkms-v3dz0# changed by do-release-upgrade (LP: #1923673)
#zdtoverlay=vc4-kms-v3dzgpu_mem=z	start_x=1z1# disabled by do-release-upgrade (LP: #1923673)
#N)r�r�rstripr|rrrrf�s�
��
���
�z:DistUpgradeQuirks._replace_fkms_overlay.<locals>.<genexpr>T)�keependsz3no fkms overlay or camera firmware line found in %szconfig.txt.distUpgraderr�0unable to write boot config backup to %s: %s; %s�-unable to write new boot config to %s: %s; %s)r<r=r�rur��FileNotFoundErrorr!r��
splitlinesr�rE�IOError)	r�boot_dir�failure_action�boot_config_filenamer��boot_config�
new_config�boot_backup_filename�excrrrrD�s^�
����


��������&����z'DistUpgradeQuirks._replace_fkms_overlayc
s�d�d�d}|j�d�}d�d�d�z$tj��d�}t|d	d
d��}|��}Wd�n1s0wYWntyGt�d||�YdSw����fd
d�}��fdd�}dd�|�	�D�}|||��}d�dd�|D��}	|	|kr}t�
d|�dSz"|d}
t|
dd
d��
}|�|�Wd�n1s�wYWnty�}zt�d|
||�WYd}~dSd}~wwz!t|dd
d��}|�|	�Wd�WdS1s�wYWdSty�}zt�d|||�WYd}~dSd}~ww)Nzkernel=vmlinuzz!initramfs initrd.img followkernelz�You may need to replace u_boot_* with vmlinuz, and add {initramfs_line!r} to config.txt on your boot partition; see LP: #1936401 for further details)�initramfs_linez0# commented by do-release-upgrade (LP: #1936401)z,# added by do-release-upgrade (LP: #1936401)z5# merged from {} by do-release-upgrade (LP: #1936401)r�rer�r�r�cs�g}d}}|D]J}|dkr'|�|�|s&|���|���|���d}q|�d�r9|���|�d|�q|�d�rMd}|���|�d|�q|�|�q|rm|sk|���|�d�|���|���|S|S)NFz[all]Tzdevice_tree_address=r
zkernel=uboot_rpi_)r�r�)r�result�
removed_uboot�added_kernelr\)�added_prefix�
change_prefixr��kernel_linerr�
replace_uboots6



�







z=DistUpgradeQuirks._remove_uboot_on_rpi.<locals>.replace_ubootc	s&g}d}d}|D]�}|�d�r|rqd}|dvr�d}|jdd�d}|���|��tj��|�}d}t|ddd	��}|D]}|�d�rG|rGq=d}|�|���q=Wd�n1s[wY|d
}zt�	||�Wqt
y�}zt�d|||�WYd}~qd}~ww|�|�q|r�|S|S)NTFr
)zinclude syscfg.txtzinclude usercfg.txtr)�maxsplitrer�r��.distUpgradez7failed to move included configuration from %s to %s; %s)
r�rYr��formatr<r=r�rur��renamer�r!r�)	rr��
skip_comments�found_includesr\�included_filenamer��target_filenamer�)r��merge_prefixrr�merge_includesJsJ������z>DistUpgradeQuirks._remove_uboot_on_rpi.<locals>.merge_includescSr/r)r�r|rrrr1vr2z:DistUpgradeQuirks._remove_uboot_on_rpi.<locals>.<listcomp>r�css�|]}|dVqdS)rTNrr|rrrrfxs�z9DistUpgradeQuirks._remove_uboot_on_rpi.<locals>.<genexpr>z!no u-boot removal performed in %sr�rrr�r�)
r�r<r=r�rur�r�r!r�r�r�rEr�)rr�r�r�r�r�r�r�rr�r�r�r)r�r�r�r�r�r�rrE	sj�
����,,������&����z&DistUpgradeQuirks._remove_uboot_on_rpi�/etc/netplanc
Cs"d}zddl}Wntyt�d|�YdSwt�d|�D]�}z,tj�||�}t|ddd��}|�	�}|j
||jd�}Wd�n1sHwYWnty`t�d	||�YdSwd
}	z!|dd�
�D]}
|
d
ddkr�d}	|
d
=d|
vr�|
d=qlWn	ty�Yq w|	s�q z"|d}t|ddd��
}|�|�Wd�n1s�wYWnty�}zt�d|||�WYd}~dSd}~wwz!t|ddd��}|j||d
d�Wd�n1s�wYWq t�y}zt�d|||�WYd}~dSd}~wwdS)Nz�You may need to manually edit your netplan config and remove the line "driver: bcmgenet smsc95xx lan78xx". See LP: #1970761 for further detailsrz!failed to import yaml library. %sz	%s/*.yamlrer�r�)�Loaderz.failed to open netplan configuration in %s; %sF�network�	ethernetsr�rzbcmgenet smsc95xx lan78xxTzset-namer�rrz3unable to write netplan config backup to %s: %s; %s)�default_flow_stylez0unable to write new netplan config to %s: %s; %s)�yaml�ImportErrorr!r�r�r<r=r�rur�r��
SafeLoaderr��valuesr�rEr��dump)
r�netplan_dirr�r��netplan_config_file�netplan_config_filenamer��orig_content�netplan_yaml�
file_modified�eth�netplan_backup_filenamer�rrrrF�s������������������������z+DistUpgradeQuirks._remove_netplan_match_rpic

Cs�t�d�|jj}d|vrt�d�dS|djs t�d�dSzddlm}WntyB}zt�d|�WYd}~dSd}~ww|�}|j	�
�}|D]}d�|�}||vrh||jrht�d	�|��dSqMd}|D]"}d
�|�}	|	|vr�||	jr�||	jr�|}t�d�|	|��nqm|dur�t�d�dSd�|�}
|
|vr�t�d
�|
��t
d�}t
d||f�}|j�||�|j��dSt�d�|
��||
��|�dd�dS)Nz7running Quirks._test_and_fix_missing_nvidia_metapackagezubuntu-drivers-commonz&ubuntu-drivers-common not be availablez#ubuntu-drivers-common not installedr)�NvidiaDetectionz&NvidiaDetection can not be imported %sznvidia-driver-{}zpackage {} detected, exit.zlibnvidia-gl-{}zGFound autoremovable package {}, assuming we're missing nvidia-driver-{}z-No autoremovable libnvidia-gl found, exiting.z*Package {} not available in the APT cache!z%NVIDIA driver metapackage unavailableaYour system has the package libnvidia-gl-%s installed but the corresponding metapackage nvidia-driver-%s is not installed and is not available to be installed. The upgrade process was not able to automatically fix this issue and consequently the upgrade will now exit.z/Installing missing nvidia driver metapackage {})r!r%rr8r�r;�NvidiaDetector.nvidiadetectorr�r��drivers�keysr��is_auto_removablerxr
ryrB�commit)
rr8r�r��nv�versionsrbr�version_to_fix�	nvidia_gl�missing_metapackager�r�rrrr:�sn



��

�
���

��
�z1DistUpgradeQuirks._fix_missing_nvidia_metapackage)rr_)r�)r�)r�)8�__name__�
__module__�__qualname__�__doc__rr+r/rBrGrHrOrPrRr]r3r}r�r�r4r�r5r7r6r�r9r�r�r�rNrKrLrMr�rJr?r@rCrr�rIr�r#r6rCrHrQr\rQrmrqrwr�rDrErFr:rrrrr&sp.
!)&/


@(!

/
0J

3
;r)rJr�rjr�r!r<r�rrWrr�utilsr�DistUpgradeGettextrrxrhrrrrr�<module>s

Spamworldpro Mini