%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/DistUpgrade/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/DistUpgrade/__pycache__/DistUpgradeQuirks.cpython-312.pyc

�

9_f�=���ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddl	mZmZddl
mZddlmZGd�de�Zy)�N)�PIPE�Popen�)�get_arch)�gettextc��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d?d'�Z)d@d)�Z*d*�Z+d+�Z,d,�Z-dAd-�Z.d.�Z/d/�Z0d0�Z1d1�Z2d2�Z3d3�Z4d4�Z5d5�Z6dBd6�Z7dBd7�Z8dBd8�Z9d9�Z:d:�Z;d;�Z<d<�Z=d=�Z>d>�Z?y()C�DistUpgradeQuirksz�
    This class collects the various quirks handlers that can
    be hooked into to fix/work around issues that the individual
    releases have
    c�2�||_|j|_||_tddgtd��j�dj
�|_t�|_	d|_
d|_d|_d|_
d|_d|_d|_y)N�unamez-rT��stdout�universal_newlinesrF)�
controller�_view�configrr�communicate�striprr�arch�extra_snap_space�_poke�_snapstore_reachable�
_snap_list�
_from_version�_to_version�_did_change_font)�selfrrs   �?/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeQuirks.py�__init__zDistUpgradeQuirks.__init__/s���$����%�%��
�����G�T�?�4�.2�4�4?�K�M�!�E�EJ�U�W�	
�
��J��	� !�����
�$)��!����!������ %���c��|jjrtjd�y|jjdd�}|jjdd�}d|z}t
||d�}|�tjd|z�|�|�|��}t
||d�}|�tjd|z�|�d|�|��}t
||d�}|� tjd|z�|�yy)	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 %s�from_)r�_partialUpgrade�logging�infor�get�getattr�debug)r�
quirksName�
to_release�from_release�funcname�funcs      r�runzDistUpgradeQuirks.runBs���$�?�?�*�*��L�L�D�E���[�[�_�_�Y��5�
��{�{���y�&�9���*�$���t�X�t�,�����M�M�.��9�:��F�(��4���t�X�t�,�����M�M�.��9�:��F��#/�
�;���t�X�t�,�����M�M�.��9�:��F�rc�N�tjd�|j�y)z3 run before the apt cache is opened the first time zrunning Quirks.PreCacheOpenN)r'r+�_add_apport_ignore_list�rs r�PreCacheOpenzDistUpgradeQuirks.PreCacheOpenps���
�
�3�4��$�$�&rc��tjd�|j�|j�|j	�|j�|j
�|j�|jj}|j|�|j�d|vrtjd�y|djrNtjjd�stjjd�r|j!�|j"r|j%�yy)z2 run after the apt cache is opened the first time z%running Quirks.noblePostInitialUpdate�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_armhf_raspi�_test_and_fail_on_tpm_fder�cache�_test_and_warn_if_ros_installed�#_maybe_prevent_flatpak_auto_removal�is_installed�os�path�exists�_checkStoreConnectivityr�_calculateSnapSizeRequirements�rr?s  r�noblePostInitialUpdatez(DistUpgradeQuirks.noblePostInitialUpdatevs���	�
�
�=�>��%�%�'��#�#�%��#�#�%��%�%�'��*�*�,��&�&�(����%�%���,�,�U�3��0�0�2��%���M�M�C�D����>�&�&������ 3�4������ 8�9��(�(�*��$�$��/�/�1�%rc��tjd�|jj}d|vrtjd�y|djr|j
r|j
�d|vr|djr|j�d|vr|djr|j�d|vr!|djr|j�yyy)Nzrunning Quirks.noblePostUpgrader7r8zubuntu-desktop-raspizubuntu-server-raspizlinux-firmware-raspi2)
r'r+rr?rBr�_replaceDebsAndSnaps�_replace_fkms_overlay�_add_kms_overlay�_remove_uboot_on_rpirHs  r�noblePostUpgradez"DistUpgradeQuirks.noblePostUpgrade�s����
�
�7�8����%�%���%���M�M�C�D����>�&�&�����%�%�'�!�U�*��+�,�9�9��*�*�,� �E�)��*�+�8�8��%�%�'�"�e�+��,�-�:�:��)�)�+�;�,rc�N�tjd�|j�y)z run after cleanup zrunning Quirks.PostCleanupN)r'r+�_remove_apport_ignore_listr4s r�PostCleanupzDistUpgradeQuirks.PostCleanup�s���
�
�2�3��'�'�)rc��tjd�|j�|j�|j	�|j�|j
�|j�|j�y)Nzrunning Quirks.StartUpgrade)	r'r+�
_applyPatches�_removeOldApportCrashes�_killUpdateNotifier�_killKBluetooth�_pokeScreensaver�_stopDocvertConverter�_set_generic_fontr4s r�StartUpgradezDistUpgradeQuirks.StartUpgrade�sc���
�
�3�4������$�$�&�� � �"����������"�"�$���� rc��tjd�|j�|j�|j	�y)z/ run right before calculating the dist-upgrade z"running Quirks.PreDistUpgradeCacheN)r'r+�_maybe_remove_gpg_wks_server�!_install_t64_replacement_packages�_handle_ufw_breaksr4s r�PreDistUpgradeCachez%DistUpgradeQuirks.PreDistUpgradeCache�s3���
�
�:�;��)�)�+��.�.�0����!rc�N�tjd�|j�y)z( run after calculating the dist-upgrade z#running Quirks.PostDistUpgradeCacheN)r'r+�_install_linux_metapackager4s r�PostDistUpgradeCachez&DistUpgradeQuirks.PostDistUpgradeCache�s���
�
�;�<��'�'�)rc�&�t�}	tjddgtjd��}|j�dj
d�D]'}|s�|j|j
�d��)|S#t$r|cYSwxYw)z8 return a set of pci ids of the system (using lspci -n) �lspciz-nTrr�
�)�set�
subprocessrr�OSErrorr�split�add)rre�p�lines    r�_get_pci_idszDistUpgradeQuirks._get_pci_ids�s������	�� � �'�4�����48�:�A��M�M�O�A�&�,�,�T�2�	+�D���	�	�$�*�*�,�q�/�*�	+�����	��L�	�s�(B�B�Bc�~��tj�}	|jd�jjz�j�d�_|jd�jjz�j�d�_y#t$r�t�fd�|jd�D��jj�j�d�_t�fd�|jd�D��jj�j�d�_YywxYw)Nr$rc3�|�K�|]3}|j�jjk(r|j���5y�w�N)�seriesr�fromDist�version��.0�rrs  �r�	<genexpr>z=DistUpgradeQuirks._get_from_and_to_version.<locals>.<genexpr>�s2�����:�q��H�H���� 8� 8�8����:���9<�objectc3�|�K�|]3}|j�jjk(r|j���5y�wrr)rsr�toDistrurvs  �rryz=DistUpgradeQuirks._get_from_and_to_version.<locals>.<genexpr>�s2�����8�q��H�H���� 6� 6�6����8�rz)�distro_info�UbuntuDistroInforurrtrkrr}r�AttributeError�next�get_all)r�dis` rr9z*DistUpgradeQuirks._get_from_and_to_version�s���
�
)�
)�
+��	3��
�
�4�$�/�/�":�":�:�;�A�A�C�A�F�
���
�
�4�$�/�/�"8�"8�8�9�?�?�A�!�D�
����	3�!%�:�B�J�J�x�$8�:����(�(�"*�+0�%�'�!�"5�D�� $�8�B�J�J�x�$8�8����&�&� (�).���� 3�D��	3�s�A<B�B%D<�;D<c�
�d}tjj|�rdtjvryt	j
gd�t
tjd���}|dk7rtjd�yt	j
|g�}tjd|�d	|�d
��|dk7rL|jjtd�td��}|s|jj�yyy)
Nz/usr/lib/nux/unity_support_test�DISPLAY)�psz-Czunity-panel-service�w�r
rz5_test_and_warn_for_unity_3d_support: no unity runningz%_test_and_warn_for_unity_3d_support 'z' returned '�'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?)rCrDrE�environri�call�open�devnullr'r+r�askYesNoQuestion�_r�abort)r�UNITY_SUPPORT_TEST�return_code�ress    r�#_test_and_warn_for_unity_3d_supportz5DistUpgradeQuirks._test_and_warn_for_unity_3d_support�s���>�������1�2�����+�� �o�o�/��R�Z�Z��8M�O���!���M�M�G�
I�� �o�o�'9�&:�;���
�
�"�K�
1�	2��!���*�*�-�-��"�#��D�E��C�����%�%�'��rc��gd�}|j�}t|�j|�rL|jj	td�td��}|s|jj�yyy)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?)rorh�intersectionrr�r�rr�)r�I8XX_PCI_IDSrer�s    r�_test_and_warn_on_i8xxz(DistUpgradeQuirks._test_and_warn_on_i8xx	sy�����!�!�#���|��)�)�%�0��*�*�-�-��&�'��>�?�	�C�����%�%�'��1rc��|jd�r�|jd�s�|jjt	d�t	d��}|s|j
j
�gd�}tjddj|�z�|j
jjdd�}|D]}|j|��|j
jjddd	j|��y
y
y
)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�_supportInModaliasesrr�r�rr�r'r+�joinr�getlist�appendrh)rr��removals�postupgradepurge�removes     r�'_test_and_warn_on_dropped_fglrx_supportz9DistUpgradeQuirks._test_and_warn_on_dropped_fglrx_support!s���
�"�"�7�+��-�-�g�6��*�*�-�-�����-�.�
/�C�����%�%�'��H�
�M�M�+��	�	�(�(;�;�<�#���5�5�=�=��"� $��#�
0�� �'�'��/�
0��O�O�"�"�&�&�x�1C�'*�x�x�0@�'A�
C�=7�
,rc�N�|jdk(rd}n|jdk(rd}|jdk(rstjd�t	d�}t	d|j�d	�d
��}|j
j||�|jj�yy)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 systemziThere will not be any further Ubuntu releases for this system's 'i386' architecture.

Updates for Ubuntu � will continue until �.N)rrr'�errorr�rrr�)r�updates_end�summary�msgs    rr:z(DistUpgradeQuirks._test_and_fail_on_i386Js���
����(�&�K�
�
�
�7�
*�(�K��9�9����M�M�4�5��A�B�G���'�'��6�7�C�
�J�J���W�c�*��O�O�!�!�#�rc���|jdk(rZ|j�sI|jjt	d�t	d��|j
j
�yyy)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�_checkArmCPUrr�r�rr�r4s r�_test_and_fail_on_non_arm_v6z.DistUpgradeQuirks._test_and_fail_on_non_arm_v6^s_��
�9�9����$�$�&��
�
� � ��n�%��,�-�.����%�%�'�'� rc��dD]�}tjj|�s�#tjd�td�}td|z�}|jj	||�|jj���y)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)	rCrDrEr'r�r�rrr�)r�aufs_dirr�r�s    rr;z(DistUpgradeQuirks._test_and_fail_on_aufsps~��1�
	(�H������x�(��
�
�7�8��<�=���,�
/7�7�8���
�
� � ��#�.����%�%�'�
	(rc��|jdk7ryd}|jdk(rd}n|jdk(rd}td�5}|j�}t	j
d	|tj�rrtjd
�td�}td|j�d
|�d��}|jj||�|jj�ddd�y#1swYyxYw)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�zfThere will not be any further Ubuntu releases for this system's POWER8 processor.

Updates for Ubuntu r�r�)
rrr��read�re�search�	MULTILINEr'r�r�rrr�)rr��f�cpuinfor�r�s      rr<z*DistUpgradeQuirks._test_and_fail_on_power8�s����9�9�	�!��������(�&�K�
�
�
�7�
*�%�K�
�/�
"�	(�a��f�f�h�G��y�y�-�w����E��
�
�9�:��E�F����+�+�[�:�;���
�
� � ��#�.����%�%�'�	(�	(�	(�s
�B(C2�2C;c�B�	tjdd�y#t$r|tjd�|j
j
td�td��}|s|jj�|j
j�YywxYw)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)rC�killrjr'�warningrr�r�rr��
processEvents�rr�s  r�_test_and_warn_if_vserverz+DistUpgradeQuirks._test_and_warn_if_vserver�s~��	'��G�G�A�q�M���	'��O�O�O�,��*�*�-�-��%�&��7�8�9�C�����%�%�'��J�J�$�$�&�	'�s��BB�Bc��t�}dD])}|jtjd|z���+d}|D]D}|rn@|D]9}|j	|j
�s�|js|jrd}�D�F|rL|jjtd�td��}|s|jj�yyy)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)
rhrlr��compile�match�namerB�marked_installrr�r�rr�)rr?�ros_package_patterns�package_name�ros_is_installed�pkg�patternr�s        rr@z1DistUpgradeQuirks._test_and_warn_if_ros_installed�s��� #�u��!�	=�L�
!�$�$��
�
�+�l�:�;�
=�
	=�!���	�C���/�
���=�=����*��'�'�3�+=�+=�+/�(��	
�		���*�*�-�-��A�B��7�8�
9�C�����%�%�'��rc��d}d|jjvry|jjdjsytjjd�sydD]V}t
jd|gtj��}|jjd�j�s�Td}ntjd	j|rd
nd��|sy|jjdjd��d
D]�}||jjvr�|jj|js�@tjdj|��|jj|jd����|jjj!|j"j%�|j"j'|jj��y)z�
        If flatpak is installed, and there are either active remotes, or
        flatpak apps installed, prevent flatpak's auto-removal on upgrade.
        F�flatpakNz/usr/bin/flatpak)�remotes�listr��utf-8Tz-flatpak will{}be marked as manually installed� z NOT )�auto)zplasma-discover-backend-flatpakzgnome-software-plugin-flatpakz'{} will be marked as manually installed)rr?rBrCrDrErir1rr
�decoderr'r+�format�	mark_auto�commitr�getAcquireProgress�getInstallProgress)r�prevent_auto_removal�subcmdrxr�s     rrAz5DistUpgradeQuirks._maybe_prevent_flatpak_auto_removal�s���
 %���D�O�O�1�1�1�����$�$�Y�/�<�<���w�w�~�~�0�1��)�	�F����'��0�%�?�?��A��x�x���w�'�-�-�/�'+�$��	�	�
�
�E��v�%9�c�w�G�	I�$�������i�(�2�2��2�>�5�
	=�C��$�/�/�/�/�/���?�?�(�(��-�:�:���M�M�C�!�6�#�;�
(��O�O�!�!�#�&�0�0�e�0�<�
	=�	
�����$�$��J�J�)�)�+��J�J�)�)�$�/�/�*?�*?�@�	
rc�V�ddg}d}	tjtjj|�d��t	|d�5}|D]}|j|�d���	ddd�y#1swYyxYw#t$r%}tjd|�d	|���Yd}~yd}~wwxYw)
Nz/usr/libexec/tracker-extract-3z!/usr/sbin/update-apt-xapian-index�2/etc/apport/blacklist.d/upgrade-quirks-ignore-listT��exist_okr�rfzFailed to create �: )	rC�makedirsrD�dirnamer��write�	Exceptionr'r+)r�ignore_listrDr��bin�es      rr3z)DistUpgradeQuirks._add_apport_ignore_lists���,�/�
��
D��	;��K�K�������-��=��d�C��
(�A�&�(�C��G�G�s�e�2�J�'�(�
(�
(�
(���	;��M�M�-�d�V�2�a�S�9�:�:��	;�s6�AA:�A.�%A:�.A7�3A:�7A:�:	B(�B#�#B(c��d}	tj|�y#t$r%}tjd|�d|���Yd}~yd}~wwxYw)Nr�zFailed to remove r�)rCr�r�r'r+)rrDr�s   rrQz,DistUpgradeQuirks._remove_apport_ignore_list+sD��C��	;��I�I�d�O���	;��M�M�-�d�V�2�a�S�9�:�:��	;�s��	A�A�Ac�D�tjd�tjj	d�stj
d�yt
d�5}|j�}ddd�tjdtj�ryy#1swY�0xYw)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+rCrDrEr�r�r�r�r�r�)rr�r�s   rr�zDistUpgradeQuirks._checkArmCPU3sy��	�
�
�4�5��w�w�~�~�o�.��M�M�9�:��
�/�
"�	�a��f�f�h�G�	�
�9�9�1�7��\�\�#���	�	�s�B�Bc��tjd�tjj	d�stj
d�yt
d�5}|j�}ddd�|S#1swYSxYw)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+rCrDrEr�r�r�)rr��vendors   r�_readDMIVendorz DistUpgradeQuirks._readDMIVendorBsb��
	�
�
�2�3��w�w�~�~�<�=��M�M�D�E��
�0�
1�	�Q��V�V�X�F�	��
�	��
�s�A1�1A;c��tjjd�r-tjd�tjddg�yy)z, /etc/init.d/apparmor stop (see bug #559433)z/etc/init.d/apparmorz/etc/init.d/apparmor stop�stopN�rCrDrEr'r+rir�r4s r�
_stopApparmorzDistUpgradeQuirks._stopApparmorOs7��
�7�7�>�>�0�1��M�M�5�6��O�O�3�V�<�=�2rc��tjjd�r-tjd�tjddg�yy)z5 /etc/init.d/docvert-converter stop (see bug #450569)z/etc/init.d/docvert-converterz"/etc/init.d/docvert-converter stopr�Nr�r4s rrYz'DistUpgradeQuirks._stopDocvertConverterUs7��
�7�7�>�>�9�:��M�M�>�?��O�O�<�f�E�F�;rc��tjjd�r-tjd�tjgd��yy)zkill update-notifier�/usr/bin/killallzkilling update-notifier)�killall�-qzupdate-notifierNr�r4s rrVz%DistUpgradeQuirks._killUpdateNotifier[s4���7�7�>�>�,�-��M�M�3�4��O�O�@�A�.rc��tjjd�r-tjd�tjgd��yy)z3killall kblueplugd kbluetooth (riddel requested it)r�zkilling kblueplugd kbluetooth4)r�r��
kblueplugd�kbluetooth4Nr�r4s rrWz!DistUpgradeQuirks._killKBluetoothbs2��
�7�7�>�>�,�-��M�M�:�;��O�O�J�K�.rc��tjjd�r~tjj	d�r^tjd�d}|dz
}|dz
}	tj|d��|_	tj|j�yyy#ttf$rtjd	�YywxYw)
Nz/usr/bin/xdg-screensaverr�z$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)rCrDrEr�r)r'r+rirr�atexit�register�_stopPokeScreensaverrj�
ValueError�	exception)r�cmds  rrXz"DistUpgradeQuirks._pokeScreensaverhs����G�G�N�N�5�6��
�
���y�)��M�M�@�A��C��H�H�C��$�$�C�
F�'�-�-�c��>��
����� 9� 9�:�*�
7���Z�(�
F��!�!�"D�E�
F�s�!;B�$C�Cc���d}|j�<	|jj�|jj�}d|_|S#t$rt	j
d�Y�)wxYw)NFzfailed to stop screensaver poke)r�	terminate�waitrjr'rr�s  rrz&DistUpgradeQuirks._stopPokeScreensaverusg�����:�:�!�
E��
�
�$�$�&��j�j�o�o�'���D�J��
���
E��!�!�"C�D�
E�s�4A
�
A.�-A.c	��	dD]P}tjd|z�D]3}tjd|�d|�d��tj|��5�Ry#t
$r"}tjd|z�Yd}~yd}~wwxYw)z: remove old apport crash files and whoopsie control files )z.crashz.uploadz	.uploadedz/var/crash/*%sz
removing old z file 'r�z+error during unlink of old crash files (%s)N)�globr'r+rC�unlinkr�r�)r�extr�r�s    rrUz)DistUpgradeQuirks._removeOldApportCrashes�sz��	O�9�
!�����#3�c�#9�:�!�A��M�M��a�"H�I��I�I�a�L�!�
!���	O��O�O�I�A�M�N�N��	O�s�AA�	B�!A>�>Bc��d}tjj�}d|d<tgd�tt|d��j�}t
jd|dtj�rd|_	y	t
jd
|dtj�r�tjd�d}|jj}d|vrN|djr?|djj j#d
�stjd�d}|rMt%d�}t%d�}|j&j||�|jj)�n�|j&j+t%d�t%d��}nd|dvrDtjd�|j&j+t%d�t%d��}n4d|dvrd}tjd�ntjd�|s|jj)�y	y	)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.)rCr��copyrrrr�r�r�rr'r�rr?rB�	candidateru�
startswithr�rr�r�)rr��snap_env�	connected�old_lxd_deb_installedr?r�r�s        rrFz)DistUpgradeQuirks._checkStoreConnectivity�s������:�:�?�?�$��$�����;�D�!%�8�-1�3�3>�;�=�	��9�9�\�9�Q�<����>�(,�D�%��
�Y�Y�+�Y�q�\�2�<�<�
H��M�M�6�7�$)�!��O�O�)�)�E���~���<�,�,��e��.�.�6�6�A�A�$�G��M�M�"4�5�,0�)�$��A�B���	.�
���
�
� � ��#�.����%�%�'��j�j�1�1��7�8��H�I���&��1��
5��M�M�<�=��*�*�-�-��*�+��D�E��C�$�y��|�
3��C��M�M�0�1��M�M�I�J���O�O�!�!�#�rc	�(�ddl}ddl}ddlm}|j	�|j
j
td��|jj�D�]\}}|ddk7r�dd|d|d	d
�}g|gd�}|jjdt|j|�d
����}|jdd�|jdd�|jd|j�	|jj!|�j#�}	|j%|	�}
t'|
ddddd�}|xj0|z
c_��y#t(|t*f$rt-j.d|z�Y��3wxYw)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/refreshr���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�updateStatusr�r�items�request�Request�bytes�dumps�
add_headerr�urlopenr��loads�int�KeyErrorrr'r+r)rr-�urllibrr�snap_objectr#r)�req�responser(r,s            rrGz0DistUpgradeQuirks._calculateSnapSizeRequirements�s�����)�
	
�+�+�-�	
�
�
����"F� G�H�!%���!6�!6�!8�	*��D�+��9�%��2�� 4�$�&�y�1�&�y�1�	�F��"�8��D��.�.�(�(�?��4�:�:�d�+�g�>�)�@�C�
�N�N�/��6��N�N�>�+=�>��N�N�5�t�y�y�A�
�!�>�>�1�1�#�6�;�;�=���z�z�(�+���4�	�?�1�-�f�5�j�A�&�I�J��
�!�!�T�)�!�5	*��.�h�
�3�
��
�
�?�$�F�G��
�s�8AE%�%(F�Fc��|jjtd��|jj	�D�]`\}}|d}|dk(r2|jjtd|z��d|d|d|g}nc|dk(r-|jjtd	|z��d||g}n1|jjtd
|z��d|d|d|g}	|jj�t
j|tjd��}|jj�|jdk(rtj|�d
|�d��|dk(s��2|ds��9|jjj|d���cy#tj$rtj|�d
|�d��Y���wxYw)z? install a snap and mark its corresponding package for removal zProcessing snap replacementsr�switchzrefreshing snap %srz	--channelr"r�zremoving snap %szinstalling snap %sT)r
�checkz	 of snap z failedrz
 succeededr�debN)rr1r�rr2r�rir1r�CalledProcessErrorr'r+�
returncoder�forced_obsoletesr�)rrr=r�	popenargs�procs      rrKz&DistUpgradeQuirks._replaceDebsAndSnaps�s����
�
����"@� A�B�"&���!6�!6�!8�	L��D�+�!�)�,�G��(�"��
�
�'�'��*>��*E�(F�G�#�W�(�+�i�*@�$�H�	��H�$��
�
�'�'��*<�t�*C�(D�E�#�W�d�3�	��
�
�'�'��*>��*E�(F�G�#�W�(�+�i�*@�$�H�	�	
��
�
�(�(�*�!�~�~��%�?�?�� ���
�
�(�(�*����!�#��
�
�7�D�I�J��)�#��E�(:����0�0�7�7��E�8J�K�9	L��,�0�0�
��
�
���F�G��
�s�&AF$�$.G�Gc��tjd�d}td�5}|j�}ddd�t	j
dtj�rd}|sbtjd�td�}td	�}|jj||�|jj�yy#1swY��xYw)
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+r�r�r�r�r�r�r�rrr�)r�paer�r�r�r�s      rrJzDistUpgradeQuirks._checkPaes���	�
�
�k�"���
�/�
"�	�a��f�f�h�G�	�
�9�9�)�7�B�L�L�A��C���M�M�3�4��)�*�G��C�D�C�

�J�J���W�c�*��O�O�!�!�#��		�	�s�C�Cc�f�d}tjj|�syt|�5}|j	�}ddd�D]Z}|jd�dj
�}|j�jd�s�E|jd|z�s�Zyy#1swY�ixYw)	z2 check if the given driver is in use in xorg.conf z/etc/X11/xorg.confFN�#r�driverz"%s"T)
rCrDrEr��	readlinesrkr�lowerr�endswith)rr��XORGr��linesrn�ss       rr�z#DistUpgradeQuirks._checkVideoDriver)s���#���w�w�~�~�d�#��
�$�Z�	"�1��K�K�M�E�	"��	�D��
�
�3���"�(�(�*�A����	�$�$�X�.��J�J�v��}�-��	��	"�	"�s�B'�'B0c
�H�tjj|�stjd�ytj
|�D�]�}d|vrtjd|z��!tjd|z�|j
dd�\}}}|jdd�}tjd	|�d
|�d|�d��tjj|�stjd
|z���tj�}t|d�5}|j|j��ddd�|j�|k(rtjd|z���-|j�|k7rtjd|z���Zddlm}		|	|tjj#||�|�tj$d|z����y#1swY��xYw#t&$rtj(d|z�Y���wxYw)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 patchdirNr�zskipping '%s' (no '.')z'check if patch '%s' needs to be appliedrgr��/ztarget for 'z' is 'z' -> 'r�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')rCrDrEr'r+�listdir�rsplit�replace�hashlib�md5r��updater��	hexdigestr��DistUpgradePatcherrXr�r(r�r)
r�patchdirr��encoded_path�md5sum�
result_md5sumrDr]�fdrXs
          rrTzDistUpgradeQuirks._applyPatches8s����w�w�~�~�h�'��M�M�-�(�����H�%�$	<�A��!�|��
�
�6��:�;���M�M�C�a�G�H�45�H�H�S�!�4D�1�\�6�=� �'�'��S�1�D��M�M��<��'�
(��7�7�>�>�$�'��
�
�:�T�A�B��
�+�+�-�C��d�D�!�
&�R��
�
�2�7�7�9�%�
&��}�}��-�/��
�
�E��L�M������F�*���� J�"&�!'�(��1�
<��d�B�G�G�L�L��1�5�}�E����8�1�<�=�E$	<�*
&�
&���
<��!�!�"6��":�;�
<�s�# G0�,AG<�0G9	�<!H!� H!Nc�j�|s|j�}||jjvs#|jj|jst	j
d�y|jj|}|j
|jj�D]w\}}|D]m}tjd|�}|s�|jd��d|jd���}|j�|vs�Tt	jd|z�y�yt	jd	|z�y)
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.*r�:rgz%found system pciid '%s' in modaliasesTz4checking for %s support in modaliases but none found)
rorr?rr'r��!_parse_modaliases_from_pkg_header�recordr�r��grouprPr+)	r�pkgnamerer��module�
pciid_list�pciid�m�matchids	         rr�z&DistUpgradeQuirks._supportInModaliasesgs
����%�%�'�E��4�?�?�0�0�0��O�O�)�)�'�2�<�<��O�O�8�9���o�o�#�#�G�,���6�6�s�}�}�7K�7K�L�		$� �V�Z�#�
$���H�H�9�5�A���)*�����Q�W�W�Q�Z�@�G��}�}��%�/��
�
�&M�(/�'0�1�#�
$�		$�	�
�
�L�� �	!�rc	��d|vrgSg}|djd�D]h}|jd�}|s�|jd�\}}|j||jd�D�cgc]}|j���c}f��j|Scc}w)z. return a list of (module1, (pciid, ...), ...)�
Modaliases�)r��(r�)rkrr�)r�	pkgrecord�modulesrorl�pciids�xs       rrhz3DistUpgradeQuirks._parse_modaliases_from_pkg_header�s����y�(��I����<�(�.�.�s�3�	M�A�����
�A��� �w�w�s�|��V�V��N�N�F����S�8I�$J�1�Q�W�W�Y�$J�K�L�	M����%Ks�'B
c�r�tjd�|jj}d|vrtjd�y|djs%|dj
stjd�y	ddl}|jj�}|D]'}d|jvs�tjd�ytjd�|jd	d
|jjdgd�|j�y#t$rtjd
�YywxYw)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.listrCzhttp://extras.ubuntu.com/ubuntu�mainz!Third party developers repositoryzerror adding extras.ubuntu.com)r'r+rr?r��	installed�aptsources.sourceslist�sourceslist�SourcesList�urir(rlr}�saver�r)rr?�
aptsources�sources�entrys     rrzz(DistUpgradeQuirks._add_extras_repository�s���
�
�.�/����%�%��"�%�/��M�M�I�J���-�.�=�=��-�.�8�8��M�M�N�O��	@�)� �,�,�8�8�:�G� �	
��&�%�)�)�3��M�M�"N�O��	
�
���N�O����E�#D� �O�O�2�2�V�H�?�A�������	@����>�?�	@�s�;1D�-D�AD�D6�5D6c��	|jj}d|vr=|djr-d|vr(tjd�|jdd�yyyy#t$rtjd�YywxYw)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)rr?�
marked_deleter'r(�mark_installr�rrHs  r�_gutenprint_fixupz#DistUpgradeQuirks._gutenprint_fixup�s���

	:��O�O�)�)�E�(�E�1��2�3�A�A�(�E�1����<�=��"�"�(�G�I�2�B�2���	:����8�9�	:�s�AA�A;�:A;c��d}tjj|�s@	tjd�t|d�5}|j
d|z�ddd�yy#t$rY�6wxYw#1swYyxYw)z5 enable multiarch via /etc/dpkg/dpkg.cfg.d/multiarch z/etc/dpkg/dpkg.cfg.d/multiarchz/etc/dpkg/dpkg.cfg.d/r�zforeign-architecture %s
N)rCrDrEr�rjr�r�)r�foreign_arch�cfgr�s    r�_enable_multiarchz#DistUpgradeQuirks._enable_multiarch�s���.���w�w�~�~�c�"�
����3�4��c�3��
D�1����3�l�B�C�
D�
D�#���
��
��
D�
D�s�A#�A2�#	A/�.A/�2A;c��tjd�}|j|�}|j|�}|rL|rJ|jd��d|jd���}|jd��d|jd���}t	j
d|�d|���tjj||�dkDS)z# copied from ubuntu-drivers common z(.+)-([0-9]+)-(.+)r�-rgz
Comparing z with r)	r�r�r�rjr'r+�apt�apt_pkg�version_compare)r�term1�term2r��match1�match2s      r�_is_greater_thanz"DistUpgradeQuirks._is_greater_than�s����*�*�1�2�����u�%�����u�%���f�%�|�|�A��%�|�|�A��0�E�%�|�|�A��%�|�|�A��0�E�	�
�
��u�=�>��{�{�*�*�5�%�8�1�<�<rc	��|xrdxsd}tjd�}tjd�}d}d}|D�]}d|jvs�d|jvs�"|js
|js�;|j|j�}	|	s�Y|jjd}
|	jd��d	|	jd
���}|j||�s��|}|j|
�}d|
vr,|r*d|�d	|	jd
��d	|jd���}��d|�d	|	jd
���}��|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�Sourcerr�rgz-lts-�linux�)
r�r�r�rBr�r�rrirjr�)
rr?�headers�suffixr��source_pattern�metapackagerur�r��source�current_version�match_sources
             r�_get_linux_metapackagez(DistUpgradeQuirks._get_linux_metapackage�s6���'�Z�-�2���*�*�=�>�����L�1�������#	;�C�����)�g�S�X�X�.E��%�%��);�);��
�
�c�h�h�/��� �]�]�1�1�(�;�F�16���Q��16���Q��'A�O��,�,�_�-4�6�"1��'5�';�';�F�'C��"�f�,��,2�+0�;�;�q�>�+7�+=�+=�a�+@�+B�K��,2�+0�;�;�q�>�+;�K�C#	;�H�rc��|jj}|j|d�}||vrtjd|z�y||j
s-tjd|z�d}|j
||�yy)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)rr?r�r'r(rBr�)rr?�linux_metapackage�reasons    rrbz,DistUpgradeQuirks._install_linux_metapackage
s������%�%�� �7�7��u�E���E�)��L�L�?�*�+�
,���&�'�4�4��L�L�;�*�+�
,�O�F����0�&�9�	5rc��d}|jj}dD]�}|D]�\}}tjd|�d|�d��||vs�'||js�7|rNtjd|�d|�d��d	|z}|j||d
|��stjd|z�tjd
|�d|�d��d|z}|j
||d
��r��tjd|�����tjj|�}|D�]#\}}||vs�||js�|r�||vr�|D��cgc]\}}||vs�||jr|��}}}td�}	td�d�ddj|����}
tj|	�|j�|jj|	|
�|jj�n(|j||�|j!||�|j||�|j#||���&|j%�ycc}}w)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)FTz
checking for z (auto_inst=rszinstalling z	 because z was installedz%s was installed on the systemF��auto_fix�	auto_instzfailed to install %sz	removing z is being installedz#%s is being installed on the system�r�zfailed to remove %szuniverse component not enabledzYou have the package a 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 z� 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 r�N)rr?r'r(rBr��mark_remover��ProblemResolverr�r��_stopAptResolverLogrr�r��clear�protectr��resolve)r�replacementsr?r��old�newr��solver�old_instr�r�s           r�_install_python_is_python2z,DistUpgradeQuirks._install_python_is_python2sD��1�����%�%��%�	A�I�(�
A���S����!�9�.�/��%�<�E�#�J�$;�$;�����&)�3�&0�1�!A�C�!G��$�1�1�#�v��<E� 2� G�#�L�L�)?�#�)E�F��L�L�"%�s�",�-�B�S�H�F� �,�,�S�&�5�,�I����%:�C�@�
A�	A�$���*�*�5�1��$� 	*�H�C���e�|��c�
� 7� 7���%�'�8D�$J�H�C���',�I-�16�s��1H�1H�%(�$J��$J�"#�$D�"E���$'��T�Y�Y�x�-@�
!B�"�� ���W�-��1�1�3��
�
�(�(��#�6����-�-�/����U�3�Z�0����u�S�z�2����U�3�Z�(��
�
�e�C�j�)�A 	*�D	�����=$Js�?I�Ic��|jjsqtjjjd�sGd}|dz
}t
j|�tjjjdd�yyy)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�
serverModer�r�r�find_br'r�rh)rr�s  r�+ensure_recommends_are_installed_on_desktopsz=DistUpgradeQuirks.ensure_recommends_are_installed_on_desktopsgsl�����)�)��;�;�%�%�,�,�-F�G�=���:�:������$����"�"�&�&�'@�#�F�	H�*rc���|jdd�}t|t�s|g}|D]D}||jjvr�|r&|jj|j
dur�Dyy)z� Helper function that checks if the given deb2snap entry
            has at least one metapkg which is installed on the system.
        �metapkgNFT)r)�
isinstancer�rr?rB)r�deb2snap_entry�metapkg_listr�s    r�_is_deb2snap_metapkg_installedz0DistUpgradeQuirks._is_deb2snap_metapkg_installedrsv��&�)�)�)�T�:���,��-�(�>�L�#�	�G��d�o�o�3�3�3����O�O�)�)�'�2�?�?�5�H���	�rc	��ddl}i|_d|jz}d|jz}i}i}	tj
j
tj
jt��}t|dzd�}|j|�}|j�|dD]Z}	|d|	}
|j|
�s�|
jdd�}|
jd|�}|
jd	|�}
|||
f||	<�\|d
D]G}	|d
|	}|jdd�}|j|�s�/|jd|�}||f||	<�I	d}t#j$d
dgdt"j&��j)�}|rM|dj+d�ddD�cgc]}|j+�d��}}|D]}	|	|vs|	|vr�d||f||	<�|j,j/t1d��|j3�D�]�\}	\}}}i}t#j$d
d|	gdt"j&��j)�}|j,j5�t7j8d|dt6j:�rbtj<d|	z�t7j8d|z|dt6j:�stj<d|	z���d|d<n�|j>j@}|r1||vs||jBstj<d|�d|	�d����1t7j8d|d�}|stj<d |	z���fd!|d<||d<|d|d"<||d#<||j|	<���|j3�D�]�\}	\}}i}t#j$d
d|	gdt"j&��j)�}|j,j5�t7j8d|dt6j:�s��tj<d|	z�t7j8d|z|dt6j:�stj<d|	z���d$|d<t#j$d
d%|	gdt"j&��j)�}|j,j5�|dj+d�D]�}|j+�}tE|�d&k7r�"|d}|d'}|jG|	d(z�s�A|j+d(�d}|d)k7s�[||vs�`tj<d*|	�d+|�d,��d|d<d-|d#<n||j|	<���|jS#t$r#}tj d|z�Yd}~��td}~wwxYwcc}w).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.jsonrx�seededrC�from_channel�
to_channel�unseededz%error reading deb2snap.json file (%s)r�rr�T)rr
rfr���zChecking for installed snapsr(z^installed: zSnap %s is installedz^tracking:.*%sz+Snap %s is not tracking the release channelrArzDeb package z) is not installed. Skipping snap package z
 installationzsnap-id:\s*(\w*)z'Could not parse snap-id for the %s snaprr!r"r��connections�rgrgr�zSnap z is being used by z. Switching it to stable track�stable)$r-rrrrCrDr��abspath�__file__r��load�closer�r)r�r'r�rirrrrkrr1r�r2r�r�r�r�r+rr?rB�lenr)rr-r�r��seeded_snaps�unseeded_snaps�current_path�d2s_file�d2sr�seedrC�	from_chan�to_chan�unseedr��	snap_listrn�snaps_installedr=�	snap_infor?r��conns�conn�	conn_cols�plug�slot�	plug_snaps                             rr0z0DistUpgradeQuirks._prepare_snap_replacement_data�s���
	����)�D�,>�,>�>��'�$�*:�*:�:�
�����	I��7�7�?�?�2�7�7�?�?�8�+D�E�L��L�+;�;�S�A�H��)�)�H�%�C��N�N���H�
�
?���8�}�T�*���:�:�4�@���h�h�u�d�+�� �H�H�^�\�B�	��(�(�<��<��&)�9�g�%>��T�"�
?��J��
8���Z���.���j�j���-���:�:�6�B��"�J�J�~�|�D�	�(+�Y�'7��t�$�

8��	��$�$�f�f�%5�8<�,6�O�O�=�=H�[�]�	��,5�Q�<�+=�+=�d�+C�A�b�+I�K�#'� $�z�z�|�A��K�O�K�(�
J���<�'�4�>�+A��*.��j�)I�L��&�	
J�	
�
�
����"@� A�B�5A�5G�5G�5I�!	0�1�D�1�3��j��K�"�(�(�&�&�$�)?�<@�0:���A�AL���
�
�J�J�$�$�&��y�y��)�A�,����E��
�
�4�t�;�<��y�y�!2�\�!A�!*�1��r�|�|�=��M�M�"O�$(�#)�*��)1��I�&����-�-���S��-�U�3�Z�5L�5L��M�M�DG��#O�P���	�	�"5�y��|�D����M�M�"K�$(�#)�*��)2��I�&�%(��E�"�).�q���I�&�%/�K�	�"�$/�D�O�O�D�!�C!	0�D*8�)=�)=�)?�*	4�%�D�%�3���K�"�(�(�&�&�$�)?�<@�0:���A�AL���
�
�J�J�$�$�&��y�y��)�A�,����E��
�
�4�t�;�<��y�y�!2�\�!A�!*�1��r�|�|�=��M�M�"O�$(�#)�*��)1��I�&�#�(�(�&�-��)F�<@�0:���A�AL�����
�
�(�(�*�!�!�H�N�N�4�0�"�D� $�
�
��I��9�~��*� �$�Q�<�D�$�Q�<�D����t�c�z�2�$(�J�J�s�O�A�$6�	�$��+�$�N�:�#�M�M�-1�9�+>�?�6>�K�	�2�5=�K�	�2�!�!"�$)4�����%�U*	4�V�����C�	I��O�O�C�a�G�H�H��	I��Ks�D!V�$W
�	W
�'W�W
c��	|dz}t|dd��5}|j|�ddd�	t|dd��5}|j|�ddd�y#1swY�3xYw#t$r"}tjd||�Yd}~yd}~wwxYw#1swYyxYw#t$r"}tjd|||�Yd}~yd}~wwxYw)N�.distUpgrader�r�r&z0unable to write boot config backup to %s: %s; %sz-unable to write new boot config to %s: %s; %s)r�r��IOErrorr'r�)r�
old_config�
new_config�boot_config_filename�failure_action�boot_backup_filenamer��excs        r�_replace_pi_boot_configz)DistUpgradeQuirks._replace_pi_boot_config
s���	�#7�.�#H� ��*�C�'�B�
$�a����
�#�
$�	E��*�C�'�B�
$�a����
�#�
$�
$�
$�
$���	��M�M�L�.��^�
E���	��

$�
$���	E��M�M�I�.��^�
E�
E��	E�sa�A%�A�A%�B�B�B�A"�A%�%	B�.B�B�B�B�B�	C
�(C�C
c��d}	tjj|d�}t|dd��5}|j	�}ddd�djd�jd	�
�D��}||k(rt
jd|�y|j||||�y#1swY�bxYw#t
$rt
jd|�YywxYw)NzfYou may need to replace the vc4-fkms-v3d overlay with vc4-kms-v3d in config.txt on your boot partition�
config.txtrxr�r&�+failed to open boot configuration in %s; %sr�c3��K�|]X}|jd�rd|z|jdd�zn*|jd�s|j�dk(rd|zn|���Zy�w)zdtoverlay=vc4-fkms-v3dz0# changed by do-release-upgrade (LP: #1923673)
#�dtoverlay=vc4-kms-v3dzgpu_mem=z	start_x=1z1# disabled by do-release-upgrade (LP: #1923673)
#N)rr[�rstrip�rwrns  rryz:DistUpgradeQuirks._replace_fkms_overlay.<locals>.<genexpr>)ss����
�����7�8�
@�$�F��L�L�1�3J�K�
L����z�*�d�k�k�m�{�.J�
A�4�G��	
�
�s�AA T)�keependsz3no fkms overlay or camera firmware line found in %s)rCrDr�r�r��FileNotFoundErrorr'r��
splitlinesr�r�)r�boot_dirr�r�r��boot_configr�s       rrLz'DistUpgradeQuirks._replace_fkms_overlays���
?�	�	�#%�7�7�<�<��,�#G� ��*�C�'�B�
'�a��f�f�h��
'��W�W�
�$�.�.��.�=�
�
�
� ��$��O�O�$�%9�
;���$�$���%9�>�	K�7
'�
'�� �	��M�M�G�.��
@��	�s(�.B0�B$�B0�$B-�)B0�0 C�Cc��
��d}gd��
	tjj|d�}t|dd��5}|j	�}ddd�d���
�fd	�}j�D�cgc]}|j���}}||�}d
jd�|D��}	|	|k(rt
jd|�y|j||	||�y#1swY��xYw#t
$rt
jd|�YywxYwcc}w)
NzbYou may need to add dtoverlay=vc4-kms-v3d to an [all] section in config.txt on your boot partition)z,# added by do-release-upgrade (LP: #2065051)r�zdisable_fw_kms_setup=1r�z[pi3+]�dtoverlay=vc4-kms-v3d,cma-128r�z[pi02]r�r��[all]r�rxr�r&r�c�
�d}d}t|�D]p\}}|j�}|rT|}|jd�r|cS|jd�r|jd�r|dk(}�W|jd�s�id}�l|dk(}�r|S)	NTrr��[�]r�zinclude F)�	enumerater�rrQ)rS�in_all�last�indexrns     r�find_insertion_pointz@DistUpgradeQuirks._add_kms_overlay.<locals>.find_insertion_pointZs����F��D�(��/�
-���t��{�{�}��� �D����'>�?�#������-�$�-�-��2D�!%��������4�"'��!�W�_�F�
-� �Krc�p���|�}	||jd�r|S	�||||S#t$rY�wxYw)Nr�)r�
IndexError)rS�insert_point�added_linesrs  ��r�add_kms_overlayz;DistUpgradeQuirks._add_kms_overlay.<locals>.add_kms_overlayrsX���/��6�L�
���&�1�1�2I�J� �L�K�
0;�E�,�|�,��L��	�
��
�s�)�	5�5r�c3�&K�|]	}|dz���y�w�rfN�r�s  rryz5DistUpgradeQuirks._add_kms_overlay.<locals>.<genexpr>�����;�T�T�D�[�;���z)no addition of KMS overlay required in %s)rCrDr�r�r�r�r'r�r�r�r�r�)rr�r�r�r�r�rrnrSr�rrs          @@rrMz"DistUpgradeQuirks._add_kms_overlay@s���
3�	�
��	�#%�7�7�<�<��,�#G� ��*�C�'�B�
'�a��f�f�h��
'�	�0		�,7�+A�+A�+C�D�4�����D��D���&���W�W�;�U�;�;�
���$��O�O�G�0�
2���$�$���%9�>�	K�e
'�
'�� �	��M�M�G�.��
@��	��PEs.�.C"�C�	C"�,D�C�C"�" D�Dc�h����
���d�d�
d}|j�
��}d�d�d�	tjj�d�}t	|d	d
��5}|j�}ddd����
�fd
�}��fd�}j�D�cgc]}|j���}	}|||	��}	djd�|	D��}
|
|k(rtjd|�y|j||
||�y#1swY��xYw#t$rtjd|�YywxYwcc}w)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�rxr�r&r�c�V��g}dx}}|D]�}|dk(rJ|j|�|r�|j��|j��|j��d}�R|jd�r&|j��|jd|z���|jd�r(d}|j��|jd|z���|j|���|rH|sD|j��|jd�|j��|j��|S|S)NFr�Tzdevice_tree_address=rMzkernel=uboot_rpi_)r�r)	rS�result�
removed_uboot�added_kernelrn�added_prefix�
change_prefixr�kernel_lines	     ����r�
replace_ubootz=DistUpgradeQuirks._remove_uboot_on_rpi.<locals>.replace_uboot�s����F�+0�0�M�L��
(���7�?��M�M�$�'�'��
�
�l�3��
�
�k�2��
�
�n�5�'+���_�_�%;�<��M�M�-�0��M�M�#��*�-��_�_�%8�9�%)�M��M�M�-�0��M�M�#��*�-��M�M�$�'�1
(�>�#��M�M�,�/��M�M�'�*��M�M�+�.��M�M�.�1��
��rc���g}d}d}|D]�}|jd�r|r�d}|dvr�d}|jd��d}|j�
j|��tj
j
�	|�}d}t|dd�	�5}|D]7}|jd�r|r�d}|j|j���9	ddd�|d
z}	t	j||���|j|���|r|S|S#1swY�?xYw#t$r#}tjd|||�Yd}~��3d}~wwxYw)NTFrM)zinclude syscfg.txtzinclude usercfg.txtr)�maxsplitrxr�r&r�z7failed to move included configuration from %s to %s; %s)
rrkr�r�rCrDr�r�r��renamer�r'r�)rSr�
skip_comments�found_includesrn�included_filenamer��target_filenamer�r��merge_prefixs         ��r�merge_includesz>DistUpgradeQuirks._remove_uboot_on_rpi.<locals>.merge_includes�s^����F� �M�"�N�� 
(���?�?�3�'�M�� %�
��H�H�
&*�N�(,�
�
�A�
�(>�q�(A�%��M�M�,�"5�"5�6G�"H�I�(*�����X�5F�)H�%�$(�M��/��w�G�9�1�$%�9�D�#���s�3�
� (�,1�M�"�M�M�$�+�+�-�8�	9�9�'8�.�&H�O�<��	�	�"3�_�E��M�M�$�'�A 
(�F��
���)9�9��#�<��
�
�':�;L�&5�s�<�<��<�s$�=D
�D�
D	�	E�D=�=Er�c3�&K�|]	}|dz���y�wr
rr�s  rryz9DistUpgradeQuirks._remove_uboot_on_rpi.<locals>.<genexpr>�rr
z!no u-boot removal performed in %s)
r�rCrDr�r�r�r�r'r�r�r�r�r�)rr�r�r�r�r�rr rnrSr�rrrrrs `         @@@@@rrNz&DistUpgradeQuirks._remove_uboot_on_rpi�s:���&��<��
>�	�(�.�.�n�.�M��J�
�E��N��	�#%�7�7�<�<��,�#G� ��*�C�'�B�
'�a��f�f�h��
'�*	�X*	�X,7�+A�+A�+C�D�4�����D��D��n�U�3�4���W�W�;�U�;�;�
���$��O�O�?�0�
2���$�$���%9�>�	K�O
'�
'�� �	��M�M�G�.��
@��	��zEs/�.D	�C=�%D	�
D/�=D�D	�	 D,�+D,c�&	�d}|jrytjdd�dvryddhjtj�stjd�y	ttjdtjd���}tj|�}d
}tjdd�jd�}d
|vsd|vrd}nd|vrd}ttgd��t|�z�}tjddd|j �d�dddddd|�dgtj"d��}|j$j'd �j)d!�\}}	}
|xsd"}	t|
�tjd$|�d!|
�d%|�d!|
�d&�	�tjddd|j �d�dddddd'|�dd(|�d!|
�d(�g
�}|j*d)k7rtjd*|�d!|
���yd+|_tj,j/|j0d,�}tj2tj,j5|�d+�-�t7j8|�j;d.�/�tj<||j>|j@�|rod0}tj2tj,j5|�d+�-�d1}
tC|d2�5}|jEd3|
�d4|�d5|�d!|
�d6|
�d7��ddd�yd8}tj2tj,j5|�d+�-�tC|d2�5}|jEd9|�d:|�d!|
�d;��ddd�tjd<dd|j �d�d=g�tjd<dd|j �d�d>tj,jG|�g�}|j*d)k7r7tjd?tj,jG|��d@��yy#t$rtjd	�YywxYw#t$rd#}
Y���wxYw#1swYyxYw#1swY��xYw)Az� Due to changes to the Ubuntu font we enable a generic font
            (in practice DejaVu or Noto) during the upgrade.
            See https://launchpad.net/bugs/2034986
        �SansN�XDG_SESSION_TYPEr�)r��tty�SUDO_UID�
PKEXEC_UIDzFCannot determine how root privileges were gained, will not change fontz3Cannot determine non-root UID, will not change fontzorg.gnome.desktop.interface�XDG_CURRENT_DESKTOPrg�MATE�UKUIzorg.mate.interface�
X-Cinnamonzorg.cinnamon.desktop.interface)�Budgie�LXQtr)r*r+�XFCEzsystemd-runz--userz-Mz@.hostz--waitz--piper�z--z/usr/bin/gsettingsr)z	font-namer�)r
r'z'
r��Ubuntu�11zSetting generic font z& during the upgrade. Original font is r�rh�"rzFailed to change font to Tz!.config/upgrade-need-font-restorer�i�)�modez//etc/xdg/autostart/upgrade-restore-font.desktopz'$HOME/.config/upgrade-need-font-restorer�z�[Desktop Entry]
Name=Restore font after upgrade
Comment=Auto-generated by ubuntu-release-upgrader
Type=Application
Exec=sh -c 'if [ -e "z" ]; then gsettings set z font-name "z	";rm -f "z"; fi'
NoDisplay=true
z2/usr/lib/systemd/user/upgrade-restore-font.servicez�# Auto-generated by ubuntu-release-upgrader
[Unit]
Description=Restore font after upgrade
After=graphical-session.target dconf.service
ConditionPathExists=%h/.config/upgrade-need-font-restore

[Service]
Type=oneshot
ExecStart=/usr/bin/gsettings set z font-name 'zm'
ExecStart=/usr/bin/rm -f %h/.config/upgrade-need-font-restore

[Install]
WantedBy=graphical-session.target
�	systemctlz
daemon-reload�enablezFailed to enable z%. Font will not be restored on reboot)$rrC�getenvr�r�r'r+r:�pwd�getpwuidrrk�boolrhrir1�pw_namerr
r�
rpartitionrErDr��pw_dirr�r��pathlib�Path�touch�chown�pw_uid�pw_gidr�r��basename)r�	temp_font�uid�pwuid�schema�desktops�
use_autostartrx�fontr�r,�need_font_restore_file�autostart_file�flagr��	unit_files                rrZz#DistUpgradeQuirks._set_generic_fonts���
�	�� � ��
�9�9�'��,��;�
��L�)�6�6�r�z�z�B��M�M�"�
�
�	��b�i�i�
�B�I�I�l�,C�D�E�C��L�L��%�E�/���9�9�2�B�7�=�=�c�B���X���8�!3�)�F�
�X�
%�5�F���H�I��(�m�
�
�
�

�N�N�
�H�d�u�}�}�o�V�,D�
�x��t�
!�5��x�+�
'��?�?��

���(�(�.�.��0�;�;�C�@���q�$���x��	���I�	�
�
�-�i�[��$��@3�37�&��$��q�B�	C�
�N�N��8�T�e�m�m�_�F�+C��h��d� �%�F�8��1�Y�K�q���a�0�	
�
��
�<�<�1���M�M�5�i�[��$��H�I�� $���"$������L�L�=�"
��	���B�G�G�O�O�$:�;�d�K����+�,�2�2��2�>�
���'����u�|�|�D��N�N��K�K�������7�$�G�<�D��n�c�*�

�a����-�.2�F�2J��h�l�4�&��$��8�"�V�$'�
'�	�

�
�I�	�
���B�G�G�O�O�I�.��>�
�)�S�
!�	�Q�
�G�G�4��(�-��v�Q�t�f�56�6�
�	�&	�����d�u�}�}�o�V�4��
�	�

�N�N���d�u�}�}�o�V�4��b�g�g�&�&�y�1�
�
��

�<�<�1���M�M�-�b�g�g�.>�.>�y�.I�-J�K@�@�
A���m�	��M�M�E�
�
�		��H�	��D�	��>

�
��	�	�s=�!AQ�7Q)�"Q;�.R�Q&�%Q&�)Q8�7Q8�;R�Rc�6�|jjj}	|djsy|dj}|D��cgc]\}}}|j
jr|�� }}}t|�s�tjd�|jjdjd��tj|jj�j|jjd�yycc}}w#t$rYywxYw)z}
        Prevent postfix from being unnecessarily installed, and leading to a
        debconf prompt (LP: #2060578).
        zgpg-wks-serverNzmail-transport-agentzENo mail-transport-agent installed, marking gpg-wks-server for removalFr�)rr?�_cache�current_ver�
provides_list�
parent_pkgr;�anyr'r(�mark_deleter�r�r�)rr?�provides_mtar��ver�
installed_mtas      rr]z.DistUpgradeQuirks._maybe_remove_gpg_wks_server�s�����%�%�,�,��	��)�*�6�6�� �!7�8�F�F�L�%1��!��1�c��>�>�-�-���M���=�!��L�L�5�
�

�O�O�!�!�"2�3�?�?��?�O������� 5� 5�6�>�>����%�%�&6�7�
�"�����	��	�s(�D�D�#D�)D�D�	D�Dc��|jdk7ryd|jjv�r#|jjdjr�t	j
d�t
j�}|jd�D�cic]}|j|��}}|j|jj�}|�8|jjd�}td|j�d|�d	��}nd
}|j jtd�td�|z�|jj#�yyycc}w)
z�
        Test and fail if running armhf on a Raspberry Pi. Starting with Ubuntu
        24.04, armhf is not well supported on Raspberry Pi. Hence, prevent
        upgrades on such platforms. LP: #2060220.
        �armhfNzlinux-image-raspiz%Detected Raspberry Pi kernel on armhfr{z%B %YzUpdates for Ubuntu r�r�r�z.Sorry, cannot upgrade this system to 24.04 LTSzWThe Raspberry Pi kernel for Ubuntu 24.04 LTS does not support the armhf architecture.

)rrr?rBr'r�r~rr�rsr)rt�eol�strftimer�rurr�)rr�rx�releasesr.r��updates_end_msgs       rr=z/DistUpgradeQuirks._test_and_fail_on_armhf_raspi�sL���9�9����
 �4�?�?�#8�#8�8��O�O�!�!�"5�6�C�C��M�M�A�B��-�-�/�B����H�-������!���H��$�<�<����(@�(@�A�L��'�*�.�.�7�7��@��"#�)�,�*>�*>�)?�@&�&1�]�!�5�#��#%���J�J����D���C��$�	$�		
�
�O�O�!�!�#�A
D�
9��s�	Ec�&�|jjD�]�}|js�|jr|jjr�4tjd|j���|jjD�cgc]}|j|jf��}}|jjD��cgc]\}}}|��
}}}|D�]
}d|f|vr�d|f|vrd|f|vr�tj|jj|j�}|j��Y|jj |k7r�stjd|j�d|j���|j"}|j%dd|�	�|j'd�
�tj(|jj�j+|����tjd|j������ycc}wcc}}w)z
        LP: #2061175
        zSearching for replacement for �Replaces�Breaks�	ConflictsNzFound replacement z for F)r�r��	from_userr�z!Failed to find a replacement for )rr?rBr�downloadabler'r+r��_pkg�rev_depends_list�dep_type_untranslated�
parent_verrQr��PackagerR�_cand�is_auto_installedr�rTr�r�)	r�package�dep�reverse_depends_listr�rVrQ�replacementrbs	         rr^z3DistUpgradeQuirks._install_t64_replacement_packages�s������,�,�;	�G��'�'��� � �W�%6�%6�%C�%C��

�M�M�:�7�<�<�.�I�J�#�<�<�8�8�$���*�*�C�N�N�;�$� �$�
3:�,�,�2L�2L�M�Y�Q��3�S�M�M�M�$�(
����$�,@�@���s�O�+?�?� �#�&�.B�B��!�k�k��O�O�)�)��N�N���
�(�(�0���(�(�.�.�#�5���
�
�(��)9�)9�(:�;�"�<�<�.�*��!(� 9� 9�9�	��(�(�%�5�3<�)�>��#�#�U�#�3��#�#�D�O�O�$9�$9�:�B�B�7�K��E(
�L�
�
�7����~�F��s;	��$��
Ns�H�?
H
c��|jjdk7ry	|jjd}|jsyd}dD]W}	|jj|}|js�*tjd|�d��|jdd��d	}�Y|rK|jd�
�tj|jj�j|�yy#t$rYywxYw#t$rY��wxYw)z
        LP: #2061891
        �jammyN�ufwF)znetfilter-persistentziptables-persistentzKeeping z, and removing ufw as a result.r�Tr�)rrtr?r;rBr'r(r�rTr�r�r�)rrq�
remove_ufwr�r�s     rr_z$DistUpgradeQuirks._handle_ufw_breaks#s
���?�?�#�#�w�.��	��/�/�'�'��.�C������
�C�	"�D�
��o�o�+�+�D�1���������t�f�$C�D��� � �%�5� �A�!�
�	"���O�O�U�O�+������� 5� 5�6�>�>�s�C���+�	��	���
��
�s#�C.�
C=�.	C:�9C:�=	D	�D	c��	tjddg�}|j�D�cgc]#}|j�j	�d��%}}d|vr�d|jjvr�|jjdjr�tjd�tj�}|j|jj�xsd}|jj!t#d	|���t#d
��|jj%�yyyycc}w#t
$rYywxYw)z
        LP: #2065229
        rr�rNz	pc-kernelzubuntu-desktop-minimalzDetected TPM FDE systemznext releasez%Sorry, cannot upgrade this system to z�Upgrades for desktop systems running TPM FDE are not currently supported. Please see https://launchpad.net/bugs/2065229 for more information.)ri�check_outputr�r�rkr�rr?rBr'r+r~rrur}rr�r�r�)rr�rT�snapsr�rus      rr>z+DistUpgradeQuirks._test_and_fail_on_tpm_fdeGs&��	�"�/�/���0@�A�I�4=�4H�4H�4J�K�q�Q�X�X�Z�%�%�'��*�K�E�K�
�5� �$����(=�(=�=��O�O�!�!�":�;�H�H��M�M�3�4��-�-�/�B��j�j����!7�!7�8�J�N�G��J�J����;�G�9�E���,��	
�
�O�O�!�!�#�'
I�
>�
!��
L�� �	��	�s"�)D:�(D5�D:�5D:�:	E�E)z	./patchesrr)r�)z/boot/firmware)@�__name__�
__module__�__qualname__�__doc__rr1r5rIrOrRr[r`rcror9r�r�r�r:r�r;r<r�r@rAr3rQr�r�r�rYrVrWrXrrUrFrGrKrJr�rTr�rhrzr�r�r�r�rbr�r�r�r0r�rLrMrNrZr]r=r^r_r>rrrr	r	(s\���
&�&+�\'�2�:,�(*�!�"�*��3�$(�B(�0'C�R$�((�$(�,(�:'�,-(�^0
�d;�";�
��>�G�B�L�F�	�O�>$�@&*�P!L�F$�(
�-<�^�>�@�4:�"	D�=� .�`:�&H�T	G��&C�JE�"#K�JFK�PvK�pPA�d!�F+$�Z?�B"D�H!$rr	)r�rr~rr'rCr6r�r\rir<rr�utilsr�DistUpgradeGettextrr�r{r	rrr�<module>r|s?��,�
����	�
�	����"��,�@$��@$r

Zerion Mini Shell 1.0