HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/DistUpgrade/__pycache__/DistUpgradeQuirks.cpython-38.pyc
U

٪zc���@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#dadCdD�Z$dbdFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dcdOdP�Z)dQdR�Z*dSdT�Z+dUdV�Z,dWdX�Z-dYdZ�Z.d[d\�Z/d]d^�Z0d_d`�Z1dES)d�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�}|dk	rbt�d|�|�d||f}t||d�}|dk	r�t�d|�|�d	||f}t||d�}|dk	r�t�d|�|�dS)
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 modeNZSourcesZToZFrom�%szquirks: running %sz%s%sz	from_%s%s)rZ_partialUpgrade�logging�infor�get�getattr�debug)rZ
quirksNameZ
to_releaseZfrom_release�funcname�funcrrr�run?s(
zDistUpgradeQuirks.runcCst�d�dS)z3 run before the apt cache is opened the first time zrunning Quirks.PreCacheOpenN)rr!�rrrr�PreCacheOpenmszDistUpgradeQuirks.PreCacheOpencCsft�d�|��|��|jj}|�|�d|krBt�d�dS|djrT|��|j	rb|�
�dS)z2 run after the apt cache is opened the first time z%running Quirks.focalPostInitialUpdate�snapd�'package required for Quirk not in cacheN)rr!�_get_from_and_to_version�_test_and_fail_on_i386r�cache�_test_and_warn_if_ros_installed�is_installed�_checkStoreConnectivityr�_calculateSnapSizeRequirements�rr+rrr�focalPostInitialUpdaters



z(DistUpgradeQuirks.focalPostInitialUpdatecCsDt�d�|jj}d|kr(t�d�dS|djr@|jr@|��dS)Nzrunning Quirks.focalPostUpgrader'r()rr!rr+r-r�_replaceDebsAndSnapsr0rrr�focalPostUpgrade�s


�z"DistUpgradeQuirks.focalPostUpgradecCst�d�|��dS)z run after cleanup zrunning Quirks.PostCleanupN)rr!�_fipsLibgcryptHmacCleanupr%rrr�PostCleanup�s
zDistUpgradeQuirks.PostCleanupcCsNt�d�|��|��|��|��|��|��|��|�	�dS)Nzrunning Quirks.StartUpgrade)
rr!�
_applyPatches�_removeOldApportCrashes�_killUpdateNotifier�_killKBluetooth�_killScreensaver�_pokeScreensaver�_stopDocvertConverter�_fipsLibgcryptDivertr%rrr�StartUpgrade�s
zDistUpgradeQuirks.StartUpgradecCst�d�|��dS)z/ run right before calculating the dist-upgrade z"running Quirks.PreDistUpgradeCacheN)rr!�_install_python_is_python2r%rrr�PreDistUpgradeCache�s
z%DistUpgradeQuirks.PreDistUpgradeCachecCst�d�|��dS)z( run after calculating the dist-upgrade z#running Quirks.PostDistUpgradeCacheN)rr!�_install_linux_metapackager%rrr�PostDistUpgradeCache�s
z&DistUpgradeQuirks.PostDistUpgradeCachecCslt�}ztjddgtjdd�}Wntk
r8|YSX|��d�d�D]}|rL|�|��d�qL|S)z8 return a set of pci ids of the system (using lspci -n) �lspciz-nTr	r�
�)�set�
subprocessrr�OSErrorr�split�add)rrC�p�linerrr�_get_pci_ids�s�

zDistUpgradeQuirks._get_pci_idscs�t��}z<|�d�jj���d�_|�d�jj���d�_Wnlt	k
r�t
�fdd�|�d�D��jj���d�_t
�fdd�|�d�D��jj���d�_YnXdS)Nrrc3s"|]}|j�jjkr|jVqdS�N)�seriesr�fromDist�version��.0�rr%rr�	<genexpr>�s�z=DistUpgradeQuirks._get_from_and_to_version.<locals>.<genexpr>�objectc3s"|]}|j�jjkr|jVqdSrN)rOr�toDistrQrRr%rrrU�s�)�distro_infoZUbuntuDistroInforQrrPrIrrWr�AttributeError�nextZget_all)rZdirr%rr)�s&������z*DistUpgradeQuirks._get_from_and_to_versioncCs�d}tj�|�rdtjkrdStjdddgttjd�d�}|dkrPt�	d	�dSt�|g�}t�	d
||f�|dkr�|j
�td�td��}|s�|j
��dS)
Nz/usr/lib/nux/unity_support_test�DISPLAYZpsz-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?)�os�path�exists�environrG�call�open�devnullrr!r
�askYesNoQuestion�_r�abort)rZUNITY_SUPPORT_TESTZreturn_code�resrrr�#_test_and_warn_for_unity_3d_support�s8�
�����z5DistUpgradeQuirks._test_and_warn_for_unity_3d_supportcCsPdddddddg}|��}t|��|�rL|j�td�td	��}|sL|j��dS)
Nz	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?)rMrF�intersectionr
rdrerrf)rZI8XX_PCI_IDSrCrgrrr�_test_and_warn_on_i8xx�s ��
z(DistUpgradeQuirks._test_and_warn_on_i8xxcCs�|�d�r�|�d�s�|j�td�td��}|s8|j��dddddd	g}t�d
d�	|��|jj
�dd
�}|D]}|�|�qp|jj
�
dd
d�	|��dS)zi
        Some cards are no longer supported by fglrx. Check if that
        is the case and warn
        ZfglrxzhUpgrading 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-devZlibamdxvba1z	remove %s�, ZDistroZPostUpgradePurge�,N)�_checkVideoDriver�_supportInModaliasesr
rdrerrfrr!�joinrZgetlist�appendrF)rrgZremovalsZpostupgradepurge�removerrr�'_test_and_warn_on_dropped_fglrx_support
s4
��
���z9DistUpgradeQuirks._test_and_warn_on_dropped_fglrx_supportcCsh|jdkrd}n|jdkrd}|jdkrdt�d�td�}td|j|f�}|j�||�|j��d	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 i386z'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�errorrer
rrf)rZupdates_end�summary�msgrrrr*3s



�z(DistUpgradeQuirks._test_and_fail_on_i386cCs6|jdkr2|��s2|j�td�td��|j��dS)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
        Zarmelz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
rtrerrfr%rrr�_test_and_fail_on_non_arm_v6Gs
�	z.DistUpgradeQuirks._test_and_fail_on_non_arm_v6cCsbzt�dd�WnLtk
r\t�d�|j�td�td��}|sN|j�	�|j�
�YnXdS)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]�killrHr�warningr
rdrerrf�
processEvents�rrgrrr�_test_and_warn_if_vserverYs
�
z+DistUpgradeQuirks._test_and_warn_if_vservercCs�t�}dD]}|�t�d|��q
d}|D]6}|r8qd|D]$}|�|j�r<|jsX|jr\d}q,q<q,|r�|j�	t
d�t
d��}|s�|j��dS)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.
        )Zcatkinzrosboost-cfgZroscleanzros-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)
rFrJ�re�compile�match�namer-�marked_installr
rdrerrf)rr+Zros_package_patternsZpackage_nameZros_is_installed�pkg�patternrgrrrr,os*��z1DistUpgradeQuirks._test_and_warn_if_ros_installedc	CsXt�d�tj�d�s$t�d�dStd��}|��}W5QRXt�	d|tj
�rTdSdS)zE
        parse /proc/cpuinfo and search for ARMv6 or greater
        zchecking for ARM CPU version�
/proc/cpuinfozcannot open /proc/cpuinfo ?!?Fz^Processor\s*:\s*ARMv[45]T)rr!r]r^r_rtrb�readr~�search�	MULTILINE)r�f�cpuinforrrrw�s


�zDistUpgradeQuirks._checkArmCPUcCs(tj�d�r$t�d�t�ddg�dS)z, /etc/init.d/apparmor stop (see bug #559433)z/etc/init.d/apparmorz/etc/init.d/apparmor stop�stopN�r]r^r_rr!rGrar%rrr�
_stopApparmor�s
zDistUpgradeQuirks._stopApparmorcCs(tj�d�r$t�d�t�ddg�dS)z5 /etc/init.d/docvert-converter stop (see bug #450569)z/etc/init.d/docvert-converterz"/etc/init.d/docvert-converter stopr�Nr�r%rrrr<�s
z'DistUpgradeQuirks._stopDocvertConvertercCs*tj�d�r&t�d�t�dddg�dS)zkill update-notifier�/usr/bin/killallzkilling update-notifier�killall�-qzupdate-notifierNr�r%rrrr8�s
z%DistUpgradeQuirks._killUpdateNotifiercCs,tj�d�r(t�d�t�ddddg�dS)z3killall kblueplugd kbluetooth (riddel requested it)r�zkilling kblueplugd kbluetooth4r�r�Z
kblueplugdZkbluetooth4Nr�r%rrrr9�s
z!DistUpgradeQuirks._killKBluetoothcCs*tj�d�r&t�d�t�dddg�dS)zkillall gnome-screensaver r�zkilling gnome-screensaverr�r�zgnome-screensaverNr�r%rrrr:�s
z"DistUpgradeQuirks._killScreensaverc	Cs~tj�d�rztj�d�rzt�d�d}|d7}|d7}z tj|dd�|_	t
�|j�Wn"t
tfk
rxt�d	�YnXdS)
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)r]r^r_r`rrr!rGrr�atexit�register�_stopPokeScreensaverrH�
ValueError�	exception)r�cmdrrrr;�s
�
z"DistUpgradeQuirks._pokeScreensavercCsPd}|jdk	rLz|j��|j��}Wntk
rDt�d�YnXd|_|S)NFzfailed to stop screensaver poke)rZ	terminate�waitrHrr�r|rrrr��s

z&DistUpgradeQuirks._stopPokeScreensaverc
Cstz>dD]4}t�d|�D] }t�d||f�t�|�qqWn0tk
rn}zt�d|�W5d}~XYnXdS)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)�globrr!r]�unlink�	Exceptionrz)rZextr��errrr7�sz)DistUpgradeQuirks._removeOldApportCrashescCsRd}tj��}d|d<tdddgtt|dd���}t�d	|d
tj�rPd|_	dSt�d|d
tj�r�t
�d
�d}|jj
}d|kr�|djr�|djj�d�s�t
�d�d}|r�td�}td�}|j�||�|j��n|j�td�td��}nLd|dk�r"t
�d�|j�td�td��}nd|dk�r>d}t
�d�|�sN|j��dS)z: check for connectivity to the snap store to install snapsFzC.UTF-8ZLANG�snapr!ZconnectivityT)r
�stderr�envrz	^ \* PASSrNz^ \*.*unreachablezNo snap store connectivityZlxdz1: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!)r]r`�copyrrrr~r�r�rrrtrr+r-�	candidaterQ�
startswithrer
rfrd)rrgZsnap_envZ	connectedZold_lxd_deb_installedr+rurvrrrr.�sR
�


�
�
�
z)DistUpgradeQuirks._checkStoreConnectivitycCs8ddl}ddl}ddlm}|��|j�td��|j�	�D]�\}}|ddkrTq>dd|d|d	d
�}g|gd�}|j
jdt|�
|�d
d�d�}|�dd�|�dd�|�d|j�z:|j
�|���}	|�|	�}
t|
ddddd�}Wn.t|tfk
�r"t�d|�Yq>YnX|j|7_q>dS)Nr)�URLErrorz"Calculating snap size requirements�command�installzupgrade-size-checkZdownload�snap-id�channel)zinstance-key�actionr�r�)�contextZactionsz)https://api.snapcraft.io/v2/snaps/refreshzutf-8)�encoding)Zurl�datazSnap-Device-SeriesZ16zContent-typezapplication/jsonzSnap-Device-ArchitectureZresultsr��sizezFailed fetching size of snap %s)�jsonZurllib.requestZurllib.errorr��_prepare_snap_replacement_datar
�updateStatusrer�itemsZrequestZRequest�bytes�dumpsZ
add_headerrZurlopenr��loads�int�KeyErrorr�rr!r)rr�Zurllibr�r��snap_objectr�r�ZreqZresponserr�rrrr/,s>���
 
z0DistUpgradeQuirks._calculateSnapSizeRequirementsc	CsJ|j�td��|j��D�](\}}|d}|dkr\|j�td|��d|d|d|g}nN|dkr�|j�td	|��d||g}n&|j�td
|��d|d|d|g}z*|j��tj|tjdd�}|j��Wn.tj	k
�rt
�d
||f�YqYnX|jdk�r"t
�d||f�|dkr|dr|j
j�|d�qdS)z? install a snap and mark its corresponding package for removal zProcessing snap replacementsr��refreshzrefreshing snap %sr�z	--channelr�rqzremoving snap %szinstalling snap %sT)r
Zcheckz%s of snap %s failedrz%s of snap %s succeededr��debN)r
r�rerr�r{rGr$rZCalledProcessErrorrr!�
returncoderZforced_obsoletesrp)rr�r�r�Z	popenargs�procrrrr2TsD��
�
z&DistUpgradeQuirks._replaceDebsAndSnapsc	Csxt�d�d}td��}|��}W5QRXt�d|tj�r>d}|stt�d�td�}td�}|j	�||�|j
��d	S)
z check PAE in /proc/cpuinfo �	_checkPaerr�z^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/EnablingPAEN)rr!rbr�r~r�r�rtrer
rrf)rZpaer�r�rurvrrrr�us


zDistUpgradeQuirks._checkPaec	Csrd}tj�|�sdSt|��}|��}W5QRX|D]8}|�d�d��}|���d�r4|�	d|�r4dSq4dS)z2 check if the given driver is in use in xorg.conf z/etc/X11/xorg.confF�#rZdriverz"%s"T)
r]r^r_rb�	readlinesrIr�lowerr��endswith)rr�ZXORGr��linesrL�srrrrm�s
�z#DistUpgradeQuirks._checkVideoDriver�	./patchesc

Csftj�|�st�d�dSt�|�D�]:}d|krBt�d|�q$t�d|�|�dd�\}}}|�dd�}t�d	|||f�tj�|�s�t�d
|�q$t�	�}t
|d��}|�|���W5QRX|�
�|kr�t�d|�q$n|�
�|k�rt�d
|�q$ddlm}	z(|	|tj�||�|�t�d|�Wq$tk
�r^t�d|�Yq$Xq$dS)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 appliedrEre�/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_rr!�listdir�rsplit�replace�hashlib�md5rb�updater�Z	hexdigestrzZDistUpgradePatcherr�rorr�r�)
rZpatchdirr�Zencoded_pathZmd5sumZ
result_md5sumr^r��fdr�rrrr6�sF
��zDistUpgradeQuirks._applyPatchesNc	Cs�|s|��}||jjks&|jj|js4t�d�dS|jj|}|�|jj�D]\\}}|D]N}t�	d|�}|rZd|�
d�|�
d�f}|��|krZt�d|�dSqZqNt�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:%srrEz%found system pciid '%s' in modaliasesTz4checking for %s support in modaliases but none found)
rMrr+r�rrz�!_parse_modaliases_from_pkg_header�recordr~r��groupr�r!)	rZpkgnamerCr��moduleZ
pciid_listZpciid�mZmatchidrrrrn�s.	�
�
��z&DistUpgradeQuirks._supportInModaliasescCsdd|krgSg}|d�d�D]@}|�d�}|s2q|�d�\}}|�|dd�|�d�D�f�q|S)z. return a list of (module1, (pciid, ...), ...)Z
Modaliases�)rk�(cSsg|]}|���qSr)r)rS�xrrr�
<listcomp>�szGDistUpgradeQuirks._parse_modaliases_from_pkg_header.<locals>.<listcomp>rl)rIrrp)rZ	pkgrecord�modulesr�r�Zpciidsrrrr��s
 z3DistUpgradeQuirks._parse_modaliases_from_pkg_headercCs�t�d�|jj}d|kr(t�d�dS|djsJ|djsJt�d�dSzbddl}|j��}|D]}d|j	krbt�d�q�qbt�
d�|�d	d
|jjdgd�|�
�Wntk
r�t�d
�YnXdS)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.listr�zhttp://extras.ubuntu.com/ubuntu�mainz!Third party developers repositoryzerror adding extras.ubuntu.com)rr!rr+r��	installedZaptsources.sourceslistZsourceslistZSourcesListZurirrJrWZsaver�r�)rr+Z
aptsourcesZsources�entryrrrr��s4


�




�z(DistUpgradeQuirks._add_extras_repositorycCs`z<|jj}d|kr:|djr:d|kr:t�d�|�dd�Wntk
rZt�d�YnXdS)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r+�
marked_deleterr�mark_installr�r�r0rrr�_gutenprint_fixups��
�z#DistUpgradeQuirks._gutenprint_fixuprsc	Cs\d}tj�|�sXzt�d�Wntk
r2YnXt|d��}|�d|�W5QRXdS)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)r]r^r_�makedirsrHrb�write)rZforeign_archZcfgr�rrr�_enable_multiarchsz#DistUpgradeQuirks._enable_multiarchcCsvt�d�}|�|�}|�|�}|rRd|�d�|�d�f}d|�d�|�d�f}t�d||f�tj�||�dkS)z# copied from ubuntu-drivers common z(.+)-([0-9]+)-(.+)�%s-%srrEzComparing %s with %sr)	r~rr�r�rr!�apt�apt_pkg�version_compare)rZterm1Zterm2r�Zmatch1Zmatch2rrr�_is_greater_than*s



�
�z"DistUpgradeQuirks._is_greater_thanc
Cs�|rdp
d}t�d�}t�d�}d}d}|D]�}d|jkr,d|jkr,|jsP|jr,|�|j�}	|	r,|jjd}
d|	�d	�|	�d
�f}|�	||�r,|}|�|
�}d|
kr�|r�d||	�d
�|�d	�f}q,d||	�d
�f}q,|S)zb Get the linux headers or linux metapackage
            copied from ubuntu-drivers-common
        z-headers�zlinux-image-(.+)-([0-9]+)-(.+)z
linux-(.+)zlinux-imageZextraZSourcer�rrEz-lts-z
linux%s-%s-%s�z
linux%s-%s)
r~rr�r-r�r�r�r�r�r�)
rr+Zheaders�suffixr�Zsource_patternZmetapackagerQr�r��sourceZcurrent_versionZmatch_sourcerrr�_get_linux_metapackage:sB

��
��
	��z(DistUpgradeQuirks._get_linux_metapackagecCsZ|jj}|�|d�}||kr.t�d|�dS||jsVt�d|�d}|�||�dS)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r+r�rrr-r�)rr+Zlinux_metapackage�reasonrrrrAjs�
�z,DistUpgradeQuirks._install_linux_metapackagecs�d}|jj�dD]�}|D]�\}}t�d||f�|�kr�|jr|r�t�d||f�d|}�j||d|d�s�t�d|�t�d	||f�d
|}�j||dd�st�d|�qqtj���}|D]�\}}|�kr̈|jr�|�rp|�k�rT�fd
d�|D�}t	d�}t	d||d�
|�f�}	t�|����|j�
||	�|j��n|��|�|��|�|��|�|��|�q�d}
|
�k�r��|
j�r�|��|
�|��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|]\}}|�kr�|jr|�qSr)r-)rS�old�new�r+rrr��s�
�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 %srk�pythonN)rr+rrr-r�Zmark_remover�ZProblemResolverreroZ_stopAptResolverLogr
rtrf�clearZprotectrqr�Zresolve)rZreplacementsr�r�r�r�ZsolverZold_instrurv�pyrr�rr?}sZ��
��

�
z,DistUpgradeQuirks._install_python_is_python2cCs@|jjs<tjj�d�s<d}|d7}t�|�tjj�dd�dS)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Z
serverModer�r�rZfind_brrzrF)rrvrrr�+ensure_recommends_are_installed_on_desktops�s
z=DistUpgradeQuirks.ensure_recommends_are_installed_on_desktopsc
Cs�ddl}i|_d|j}d|j}i}i}�z,tj�tj�t��}t	|dd�}|�
|�}|��|dD]t}	|d|	}
|
�dd�}||j
jkr�qj|r�|j
j|jdkr�qj|
�d	d�}|
�d
|�}
|
�d|�}||
|f||	<qj|dD]l}	|d|	}|�d	d�}|�dd�}||j
jk�r q�|�r<|j
j|jdk�r<q�|�d
|�}
||
f||	<q�Wn2tk
�r�}zt�d
|�W5d}~XYnXd}tjddgdtjd���}|�rdd�|d�d�dd�D�}|D].}	|	|k�s�|	|k�r�q�nd||f||	<�q�|j�td��|��D�]$\}	\}}}i}tjdd|	gdtjd���}|j��t�d|dtj��r�t� d|	�t�d||dtj��s�t� d|	��qd|d<n~|j
j}|�r�||k�s�||j�s�t� d ||	f��qt�d!|d�}|�st� d"|	��qd#|d<||d	<|d|d$<||d%<||j|	<�q|��D�]Z\}	\}}i}tjdd|	gdtjd���}|j��t�d|dtj��rLt� d|	�t�d||dtj��s�t� d|	��qLd&|d<tjdd'|	gdtjd���}|j��|d�d�D]�}|��}t!|�d(k�r.�q|d}|d)}|�"|	d*��r|�d*�d}|d+k�r||k�rt� d,|	|f�d|d<d-|d%<�q��q||j|	<�qL|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.jsonrTZseeded�metapkgFr��from_channel�
to_channelZunseededz%error reading deb2snap.json file (%s)r�r��listT)rr
cSsg|]}|��d�qS)r)rI)rSrLrrrr�s�zDDistUpgradeQuirks._prepare_snap_replacement_data.<locals>.<listcomp>rDr���zChecking for installed snapsrz^installed: zSnap %s is installedz^tracking:.*%sz+Snap %s is not tracking the release channelr�r�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�rqZconnections�rE�:�-z9Snap %s is being used by %s. Switching it to stable trackZstable)#r�rrrr]r^�dirname�abspath�__file__rb�load�closerrr+r-r�rrzrGrrrrIr
r�rer�r{r~r�r�r!�lenr�)rr�r�r�Zseeded_snapsZunseeded_snapsZcurrent_pathZd2s_fileZd2sr�Zseedr�r�Z	from_chanZto_chanZunseedr�Z	snap_listZsnaps_installedr�Z	snap_infor+r�ZconnsZconnZ	conn_colsZplugZslotZ	plug_snaprrrr��s


�� 
�
��


��
���


���


��
z0DistUpgradeQuirks._prepare_snap_replacement_datac
Cs�t�d�|jj}d}d}d|kr0t�d�dS|djrHt�d�dS|djr�d	}|dj}|D](}tj�||j	�d
krdt�d�dSqdt�d|d
|�zt
�ddd||g�Wn8tk
r�}zt�
d|d|�W5d}~XYnXdS)z� add a dpkg-divert to correct placement of libgcrypt.so.20.hmac on
            non-usrmerged systems when the fips libgcrypt package is installed.
            (LP: #1982534)
        r=�+/lib/x86_64-linux-gnu/.libgcrypt.so.20.hmac�//usr/lib/x86_64-linux-gnu/.libgcrypt.so.20.hmac�libgcrypt20-hmacz1System is not fips enabled, no dpkg-divert neededN�usrmergez0System is usrmerged, bug has been worked around.�1.8.5-5ubuntu1.fips.1.5rz\Fixed libgcrypt20-hmac will be installed as part of upgrade process, no need for dpkg-divertz�Broken libgcrypt20-hmac will be installed, likely due to using certified fips pocket instead of fips-updates. Installing dpkg-divert for incorrect placement of z to the correct zdpkg-divertz--addz--divertzFailed to add dpkg-divert for z(%s))rr!rr+r-Zversionsr�r�r�rQrGZ
check_callr�r�)rr+r�r��
fixed_versionZcandidate_versionsr�r�rrrr=dsN





��
���
�
��z&DistUpgradeQuirks._fipsLibgcryptDivertc
CsJt�d�|jj}d}d}d|kr0t�d�dS|djrHt�d�dS|dj�rFd	}|djj}tj�	||�d
kr�t�d�dSt
j�|�s�t�d|d
�dSt
j�|�s�t�d|d
�dSt
j�
|�r�t
j�|�|kr�t�d�dSt�d�zt
�|�Wn:tk
�rD}zt�d|d|�W5d}~XYnXdS)z� cleanup the old libgcrypt.so.20.hmac from Bionic in /lib at the
            end of the upgrade, and take care to not remove the new file from
            Focal in /usr/lib by checking to ensure system is not usrmerged.
            (LP: #1982534)
        r4rrrz1System is not fips enabled, no need for hmac tidyNrz\System is usrmerged, bug has been worked around. Exiting to avoid removal of Focal hmac filer	rz^Fixed libgcrypt20-hmac was installed as part of upgrade process, no need for hmac file cleanupzMissing hmac file: z
 aborting.zYhmac files are identical, system is possibly usrmerged or symlink present. Skip removal. z*Removing old hmac file from Bionic versionzFailed to remove z (%s))rr!rr+r-r�rQr�r�r�r]r^r_�islink�realpathr�r�r�)rr+r�r�r
Zinstalled_versionr�rrrr4�sD



��


z+DistUpgradeQuirks._fipsLibgcryptHmacCleanup)r�)N)rs)2�__name__�
__module__�__qualname__�__doc__rr$r&r1r3r5r>r@rBrMr)rhrjrrr*rxr}r,rwr�r<r8r9r:r;r�r7r.r/r2r�rmr6rnr�r�r�r�r�r�rAr?r�r�r=r4rrrrr&s`.

!)/

>(!
/

0O'r)r�r�rXr�rr]r~r�rGrrZutilsrZDistUpgradeGettextrrerVrrrrr�<module>s