9_f=ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z ddl mZddlmZGddeZy)N)PIPEPopen)get_arch)gettextceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!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/Z0d0Z1d1Z2d2Z3d3Z4d4Z5d5Z6dBd6Z7dBd7Z8dBd8Z9d9Z:d:Z;d;Zd>Z?y()CDistUpgradeQuirksz This class collects the various quirks handlers that can be hooked into to fix/work around issues that the individual releases have c2||_|j|_||_tddgtdj dj |_t|_ d|_ d|_ d|_ d|_ d|_d|_d|_y)Nunamez-rTstdoutuniversal_newlinesrF) controller_viewconfigrr communicatestripr rarchextra_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$%%  GT?4.244?KM!EEJUW J ! $)!! %c|jjrtjdy|jj dd}|jj dd}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 modeNSourcesToFrom%szquirks: running %sfrom_)r_partialUpgradelogginginforgetgetattrdebug)r quirksName to_release from_releasefuncnamefuncs rrunzDistUpgradeQuirks.runBs$ ?? * * LLD E [[__Y5 {{y&9 *$tXt,   MM.9 : F(4tXt,   MM.9 : F#/ ;tXt,   MM.9 : F rcNtjd|jy)z3 run before the apt cache is opened the first time zrunning Quirks.PreCacheOpenN)r'r+_add_apport_ignore_listrs r PreCacheOpenzDistUpgradeQuirks.PreCacheOpenps 34 $$&rctjd|j|j|j |j |j |j|jj}|j||jd|vrtjdy|djrNtjjdstjjdr|j!|j"r|j%yy)z2 run after the apt cache is opened the first time z%running Quirks.noblePostInitialUpdatesnapd'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_fdercache_test_and_warn_if_ros_installed#_maybe_prevent_flatpak_auto_removal is_installedospathexists_checkStoreConnectivityr_calculateSnapSizeRequirementsrr?s rnoblePostInitialUpdatez(DistUpgradeQuirks.noblePostInitialUpdatevs  => %%' ##% ##% %%' **, &&(%% ,,U3 002 %  MMC D  > & & 34 89  ( ( *  $ $  / / 1 %rctjd|jj}d|vrtjdy|djr|j r|j d|vr|djr|jd|vr|djr|jd|vr!|djr|jyyy)Nzrunning Quirks.noblePostUpgrader7r8zubuntu-desktop-raspizubuntu-server-raspizlinux-firmware-raspi2) r'r+rr?rBr_replaceDebsAndSnaps_replace_fkms_overlay_add_kms_overlay_remove_uboot_on_rpirHs rnoblePostUpgradez"DistUpgradeQuirks.noblePostUpgrades 78%% %  MMC D  > & &  % % ' !U *+,99**, E )*+88%%' "e +,-::))+; ,rcNtjd|jy)z run after cleanup zrunning Quirks.PostCleanupN)r'r+_remove_apport_ignore_listr4s r PostCleanupzDistUpgradeQuirks.PostCleanups 23 '')rctjd|j|j|j |j |j |j|jy)Nzrunning Quirks.StartUpgrade) r'r+ _applyPatches_removeOldApportCrashes_killUpdateNotifier_killKBluetooth_pokeScreensaver_stopDocvertConverter_set_generic_fontr4s r StartUpgradezDistUpgradeQuirks.StartUpgradesc 34  $$&   "   ""$  rctjd|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 rPreDistUpgradeCachez%DistUpgradeQuirks.PreDistUpgradeCaches3 :; ))+ ..0 !rcNtjd|jy)z( run after calculating the dist-upgrade z#running Quirks.PostDistUpgradeCacheN)r'r+_install_linux_metapackager4s rPostDistUpgradeCachez&DistUpgradeQuirks.PostDistUpgradeCaches ;< '')rc&t} tjddgtjd}|j dj dD]'}|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 subprocessrrOSErrorrsplitadd)rreplines r _get_pci_idszDistUpgradeQuirks._get_pci_idss   '448:AMMOA&,,T2 +D $**,q/* +  L s(B BBc~tj} |jdjjzj d_|jdjjzj d_y#t$rtfd|jdDjjj d_tfd|jdDjjj d_YywxYw)Nr$rc3|K|]3}|jjjk(r|j5ywN)seriesrfromDistversion.0rrs r z=DistUpgradeQuirks._get_from_and_to_version..s2:qHH 8 88:9<objectc3|K|]3}|jjjk(r|j5ywrr)rsrtoDistrurvs rryz=DistUpgradeQuirks._get_from_and_to_version..s28qHH 6 668rz) distro_infoUbuntuDistroInforurrtrkrr}rAttributeErrornextget_all)rdis` rr9z*DistUpgradeQuirks._get_from_and_to_versions   ) ) + 3 4$//":"::;AACAF   4$//"8"889??A!D   3!%:BJJx$8:(("*+0%'!"5D  $8BJJx$88&& (). 3D   3sA12+  oo /RZZ8MO !  MMG I  oo'9&:;  "K 1 2 ! **--"#DE C%%' rcgd}|j}t|j|rL|jj t dt d}|s|j jyyy)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.zThe 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 intersectionrrrrr)r I8XX_PCI_IDSrers r_test_and_warn_on_i8xxz(DistUpgradeQuirks._test_and_warn_on_i8xx sy !!# |  ) )% 0**--&'>? C%%' 1rc|jdr|jds|jjt dt 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.zThis 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, DistroPostUpgradePurge,N)_checkVideoDriver_supportInModaliasesrrrrrr'r+joinrgetlistappendrh)rrremovalspostupgradepurgeremoves r'_test_and_warn_on_dropped_fglrx_supportz9DistUpgradeQuirks._test_and_warn_on_dropped_fglrx_support!s  " "7 +--g6**---. /C%%'H MM+ ((;; <#55==" $ # 0 ''/ 0 OO " " & &x1C'*xx0@'A C=7 ,rcN|jdk(rd}n|jdk(rd}|jdk(rstjdt d}t d|jd d }|j j|||j jy y ) z} Test and fail if the package architecture is i386 as we have dropped support for this architecture. z18.04z April 2023z19.04z January 2020i386zapt 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'errorrrrr)r updates_endsummarymsgs rr:z(DistUpgradeQuirks._test_and_fail_on_i386Js    (&K   7 *(K 99  MM4 5ABG''67C JJ  Wc * OO ! ! # rc|jdk(rZ|jsI|jjt dt 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 CPUzYour 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 _checkArmCPUrrrrrr4s r_test_and_fail_on_non_arm_v6z.DistUpgradeQuirks._test_and_fail_on_non_arm_v6^s_ 99 $$&   n%,-.%%'' rcdD]}tjj|s#tjdt d}t d|z}|j j |||jjy)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 releaseszThere 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'rrrrr)raufs_dirrrs rr;z(DistUpgradeQuirks._test_and_fail_on_aufsps~1 (Hx( 78<=, /7 78    #.%%' (rc|jdk7ryd}|jdk(rd}n|jdk(rd}td5}|j}t j d |tj rrtjd td }td |jd |d}|jj|||jjdddy#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. ppc64elNz20.04z April 2025z21.10z July 2022 /proc/cpuinfoz^cpu\s*:\s*POWER8zPOWER8 processor detectedrzfThere will not be any further Ubuntu releases for this system's POWER8 processor. Updates for Ubuntu rr) rrrreadresearch MULTILINEr'rrrrr)rrfcpuinforrs rr<z*DistUpgradeQuirks._test_and_fail_on_power8s 99 !     (&K   7 *%K / " (affhGyy-w E 9:EF++[:;   #.%%' ( ( (s B(C22C;cB tjddy#t$r|tjd|j j tdtd}|s|jj|j jYywxYw)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) rCkillrjr'warningrrrrr processEventsrrs r_test_and_warn_if_vserverz+DistUpgradeQuirks._test_and_warn_if_vservers~  ' GGAqM ' OOO ,**--%&789C%%' JJ $ $ & 'sBBBct}dD])}|jtjd|z+d}|D]D}|rn@|D]9}|j |j s|j s |jrd}DF|rL|jjtdtd}|s|jjyyy)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-cfgroscleanzros-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) rhrlrcompilematchnamerBmarked_installrrrrr)rr?ros_package_patterns package_nameros_is_installedpkgpatternrs rr@z1DistUpgradeQuirks._test_and_warn_if_ros_installeds #u! =L ! $ $ +l:; =  =! C/ ==*''3+=+=+/(     **--AB 7 8 9C%%' rcd}d|jjvry|jjdjsytjj dsydD]V}t jd|gt j}|jjdjsTd}ntjd j|rd nd |sy|jjdjd d D]}||jjvr|jj|js@tjdj||jj|jd |jjj!|j"j%|j"j'|jjy)z If flatpak is installed, and there are either active remotes, or flatpak apps installed, prevent flatpak's auto-removal on upgrade. FflatpakNz/usr/bin/flatpak)remoteslistrutf-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_autocommitrgetAcquireProgressgetInstallProgress)rprevent_auto_removalsubcmdrxrs rrAz5DistUpgradeQuirks._maybe_prevent_flatpak_auto_removals % DOO11 1 $$Y/<< ww~~01 ) F'0%??Axxw'--/'+$   Ev%9cwG I$  i(222>5 =C$/////??((-:: MMC!6#; ( OO ! !# & 0 0e 0 < = $$ JJ ) ) + JJ ) )$//*?*? @ rcVddg}d} tjtjj|dt |d5}|D]}|j |d dddy#1swYyxYw#t $r%}tjd|d |Yd}~yd}~wwxYw) Nz/usr/libexec/tracker-extract-3z!/usr/sbin/update-apt-xapian-index2/etc/apport/blacklist.d/upgrade-quirks-ignore-listTexist_okrrfzFailed to create : ) rCmakedirsrDdirnamerwrite Exceptionr'r+)r ignore_listrDrbines rr3z)DistUpgradeQuirks._add_apport_ignore_lists , / D ; KK- =dC (A&(CGGse2J'( ( ( ( ; MM-dV2aS9 : : ;s6AA:A.%A:.A73A:7A:: B(B##B(cd} tj|y#t$r%}tjd|d|Yd}~yd}~wwxYw)NrzFailed to remove r)rCrrr'r+)rrDrs rrQz,DistUpgradeQuirks._remove_apport_ignore_list+sDC ; IIdO ; MM-dV2aS9 : : ;s AAAcDtjdtjj dstj dyt d5}|j}dddtjdtjryy#1swY0xYw)zE parse /proc/cpuinfo and search for ARMv6 or greater zchecking for ARM CPU versionrzcannot open /proc/cpuinfo ?!?FNz^Processor\s*:\s*ARMv[45]T) r'r+rCrDrErrrrrr)rrrs rrzDistUpgradeQuirks._checkArmCPU3sy  45ww~~o. MM9 : / " affhG  9917\\ #   s BBctjdtjj dstj dyt d5}|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_vendorrN)r'r+rCrDrErrr)rrvendors r_readDMIVendorz DistUpgradeQuirks._readDMIVendorBsb  23ww~~<= MMD E 0 1 QVVXF    s A11A;ctjjdr-tjdt j ddgyy)z, /etc/init.d/apparmor stop (see bug #559433)z/etc/init.d/apparmorz/etc/init.d/apparmor stopstopNrCrDrEr'r+rirr4s r _stopApparmorzDistUpgradeQuirks._stopApparmorOs7 77>>0 1 MM5 6 OO3V< = 2rctjjdr-tjdt j ddgyy)z5 /etc/init.d/docvert-converter stop (see bug #450569)z/etc/init.d/docvert-converterz"/etc/init.d/docvert-converter stoprNrr4s rrYz'DistUpgradeQuirks._stopDocvertConverterUs7 77>>9 : MM> ? OO>, - MM3 4 OO@ A .rctjjdr-tjdt j gdyy)z3killall kblueplugd kbluetooth (riddel requested it)rzkilling kblueplugd kbluetooth4)rr kblueplugd kbluetooth4Nrr4s rrWz!DistUpgradeQuirks._killKBluetoothbs2 77>>, - MM: ; OOJ K .rctjjdr~tjj dr^t j dd}|dz }|dz } tj|d|_ tj|jyyy#ttf$rt jd YywxYw) Nz/usr/bin/xdg-screensaverrz$setup poke timer for the screensaverz while true;z3 do /usr/bin/xdg-screensaver reset >/dev/null 2>&1;z sleep 30; doneT)shellz failed to setup screensaver poke)rCrDrErr)r'r+rirratexitregister_stopPokeScreensaverrj ValueError exception)rcmds rrXz"DistUpgradeQuirks._pokeScreensaverhs GGNN5 6 y) MM@ AC H HC $ $C F'--c>  9 9:* 7Z( F!!"DE Fs!;B$CCcd}|j< |jj|jj}d|_|S#t$rt j dY)wxYw)NFzfailed to stop screensaver poke)r terminatewaitrjr'rrs rrz&DistUpgradeQuirks._stopPokeScreensaverusg :: ! E $$&jjoo'DJ  E!!"CD Es4A A.-A.c   dD]P}tjd|zD]3}tjd|d|dtj|5Ry#t $r"}tj d|zYd}~yd}~wwxYw)z: remove old apport crash files and whoopsie control files )z.crashz.uploadz .uploadedz/var/crash/*%sz removing old z file 'rz+error during unlink of old crash files (%s)N)globr'r+rCunlinkrr)rextrrs rrUz)DistUpgradeQuirks._removeOldApportCrashessz O9 !#3c#9:!AMMa"HIIIaL! ! O OOIAM N N OsAA B!A>>Bcd}tjj}d|d<tgdtt|dj }t jd|dt jrd|_ y t jd |dt jrtjd d}|jj}d |vrN|d jr?|d jj j#d stjdd}|rMt%d}t%d}|j&j|||jj)n|j&j+t%dt%d}nd|dvrDtjd|j&j+t%dt%d}n4d|dvrd}tjdntjd|s|jj)y y )z: check for connectivity to the snap store to install snapsFzC.UTF-8LANG)snapr+ connectivityT)r stderrenvrz ^ \* PASSrNz^ \*.*unreachablezNo snap store connectivitylxdz1:zlxd is installedz#Connection to the Snap Store failedaYou 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 failedzYour 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 packagezYour 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.)rCrcopyrrrrrrrr'rrr?rB candidateru startswithrrrr)rrsnap_env connectedold_lxd_deb_installedr?rrs rrFz)DistUpgradeQuirks._checkStoreConnectivitys::??$$;D!%8-133>;=  99\9Q< >(,D %  YY+Yq\2<< H MM6 7$) !OO))E~<,,e ..66AA$GMM"45,0)$AB .    #.%%'jj1178HI&1 5 MM< =**--*+DEC$y| 3C MM0 1 MMI J OO ! ! #rc (ddl}ddl}ddlm}|j |j j td|jjD]\}}|ddk7rdd|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|zY3wxYw)Nr)URLErrorz"Calculating snap size requirementscommandinstallzupgrade-size-checkdownloadsnap-idchannel)z instance-keyactionr!r")contextactionsz)https://api.snapcraft.io/v2/snaps/refreshrencoding)urldatazSnap-Device-Series16z Content-typezapplication/jsonzSnap-Device-ArchitectureresultsrsizezFailed fetching size of snap %s)jsonurllib.request urllib.errorr_prepare_snap_replacement_datar updateStatusrritemsrequestRequestbytesdumps add_headerrurlopenrloadsintKeyErrorrr'r+r) rr-urllibrr snap_objectr#r)reqresponser(r,s rrGz0DistUpgradeQuirks._calculateSnapSizeRequirementss) ++- "F GH!%!6!6!8 * D+9%2 4$&y1&y1 F"8D..((?4::d+g>)@C NN/ 6 NN>+= > NN5tyy A !>>11#6;;=zz(+4 ?1-f5jA&IJ  ! !T ) !5 *.h 3  ?$FG s8AE%%(FFc|jjtd|jj D]`\}}|d}|dk(r2|jjtd|zd|d|d|g}nc|dk(r-|jjtd |zd||g}n1|jjtd |zd|d|d|g} |jj t j|t jd }|jj |jdk(rtj|d |d|dk(s2|ds9|jjj|dcy#t j$rtj|d |dYwxYw)z? install a snap and mark its corresponding package for removal zProcessing snap replacementsrswitchzrefreshing snap %srz --channelr"rzremoving snap %szinstalling snap %sT)r checkz of snap z failedrz succeededrdebN)rr1rrr2rrir1rCalledProcessErrorr'r+ returncoderforced_obsoletesr)rrr=r popenargsprocs rrKz&DistUpgradeQuirks._replaceDebsAndSnapss "@ AB"&!6!6!8 L D+!),G(" ''*>*E(FG#W(+i*@$H H$ ''**E(FG#W(+i*@$H   ((*!~~%??  ((*!# 7DIJ)# E(:0077 E8JK9 L,00  FG s&AF$$.GGctjdd}td5}|j}dddt j dtj rd}|sbtjdtd}td }|jj|||jjyy#1swYxYw) z check PAE in /proc/cpuinfo _checkPaerrNz^flags\s+:.* pae rzno pae in /proc/cpuinfozPAE not enabledzYour 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+rrrrrrrrrr)rpaerrrrs rrJzDistUpgradeQuirks._checkPaes  k" / " affhG  99)7BLL AC MM3 4)*GCDC JJ  Wc * OO ! ! #   s CCcfd}tjj|syt|5}|j }dddD]Z}|j ddj }|jjdsE|jd|zsZyy#1swYixYw) z2 check if the given driver is in use in xorg.conf z/etc/X11/xorg.confFN#rdriverz"%s"T) rCrDrEr readlinesrkrlowerrendswith)rrXORGrlinesrnss rrz#DistUpgradeQuirks._checkVideoDriver)s#ww~~d# $Z "1KKME " D 3"((*A $$X.JJv}-    " "s B''B0c Htjj|stjdytj |D]}d|vrtjd|z!tjd|z|j dd\}}}|jdd}tjd |d |d |d tjj|stjd |ztj}t|d5}|j|jddd|j|k(rtjd|z-|j|k7rtjd|zZddlm}  | |tjj#|||tj$d|zy#1swYxYw#t&$rtj(d|zYwxYw)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 z no patchdirNrzskipping '%s' (no '.')z'check if patch '%s' needs to be appliedrgr/z target for 'z' is 'z' -> 'rztarget '%s' does not existrbz%already at target hash, skipping '%s'z(unexpected target md5sum, skipping: '%s'r)patchzapplied '%s' successfullyzed failed for '%s')rCrDrEr'r+listdirrsplitreplacehashlibmd5rupdater hexdigestrDistUpgradePatcherrXrr(rr) rpatchdirr encoded_pathmd5sum result_md5sumrDr]fdrXs rrTzDistUpgradeQuirks._applyPatches8s ww~~h' MM- ( H%$ >$' :TAB ++-CdD! &R 2779% &}}-/ ELMF* J"&!'( 1 <dBGGLL15}E 81<=E$ <* & & <!!"6":; ? @s;1D-DADD65D6c |jj}d|vr=|djr-d|vr(tjd|j ddyyyy#t $rtjdYywxYw)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_installrrrHs r_gutenprint_fixupz#DistUpgradeQuirks._gutenprint_fixups :OO))E(E123AA(E1 <=""(GI2B2 :   8 9 :sAAA;:A;cd}tjj|s@ tjdt |d5}|j d|zdddyy#t$rY6wxYw#1swYyxYw)z5 enable multiarch via /etc/dpkg/dpkg.cfg.d/multiarch z/etc/dpkg/dpkg.cfg.d/multiarchz/etc/dpkg/dpkg.cfg.d/rzforeign-architecture %s N)rCrDrErrjrr)r foreign_archcfgrs r_enable_multiarchz#DistUpgradeQuirks._enable_multiarchs.ww~~c"  34c3 D13lBC D D #   D DsA#A2# A/.A/2A;ctjd}|j|}|j|}|rL|rJ|jdd|jd}|jdd|jd}t j d|d|t jj||dkDS)z# copied from ubuntu-drivers common z(.+)-([0-9]+)-(.+)r-rgz Comparing z with r) rrrrjr'r+aptapt_pkgversion_compare)rterm1term2rmatch1match2s r_is_greater_thanz"DistUpgradeQuirks._is_greater_thans**12u%u% f%||A%||A0E%||A%||A0E  u=>{{**5%81<L1 # ;C)gSXX.E%%);); chh/ ]]11(;F16Q16Q'AO,,_-46"1'5';';F'C "f,,2+0;;q>+7+=+=a+@+BK,2+0;;q>+;KC# ;Hrc|jj}|j|d}||vrtjd|zy||j s-tjd|zd}|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?rr'r(rBr)rr?linux_metapackagereasons rrbz,DistUpgradeQuirks._install_linux_metapackage s%% 77uE E ) LL?*+ , &'44 LL;*+ ,OF   0& 9 5rc d}|jj}dD]}|D]\}}tjd|d|d||vs'||js7|rNtjd|d|dd |z}|j ||d | stjd |ztjd |d|dd|z}|j ||d rtjd|tjj|}|D]#\}}||vs ||js|r||vr|Dcgc]\}}||vs ||jr|}}}td} tddddj|} tj| |j|jj| | |jjn(|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-dbgz python2-dbg)z python-docz python2-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=rsz installing z because z was installedz%s was installed on the systemFauto_fix auto_instzfailed to install %sz removing z is being installedz#%s is being installed on the systemrzfailed 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 rN)rr?r'r(rBr mark_removerProblemResolverrr_stopAptResolverLogrrrclearprotectrresolve) r replacementsr?roldnewrsolverold_instrrs r_install_python_is_python2z,DistUpgradeQuirks._install_python_is_python2sD1 %%% AI( AS !9./%L# Gdoo333OO))'2??5H 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+dddDcgc]}|j+d}}|D]} | |vs| |vr d||f|| <|j,j/t1d|j3D]\} \} }}i}t#j$d d| gdt"j&j)}|j,j5t7j8d|dt6j:rbtj<d| zt7j8d|z|dt6j:stj<d| zd|d<n|j>j@}| r1| |vs|| jBstj<d| d| d1t7j8d|d}|stj<d | zfd!|d<| |d<|d|d"<||d#<||j| <|j3D]\} \} }i}t#j$d d| gdt"j&j)}|j,j5t7j8d|dt6j:stj<d| zt7j8d|z|dt6j:stj<d| zd$|d<t#j$d d%| gdt"j&j)}|j,j5|dj+dD]}|j+}tE|d&k7r"|d}|d'}|jG| d(zsA|j+d(d}|d)k7s[||vs`tj<d*| d+|d,d|d<d-|d#<n||j| <|jS#t$r#}tj d |zYd}~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.jsonrxseededrC from_channel to_channelunseededz%error reading deb2snap.json file (%s)rrrT)rr rfrzChecking 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 connectionsrgrgrzSnap z is being used by z. Switching it to stable trackstable)$r-rrrrCrDrabspath__file__rloadcloserr)rr'rrirrrrkrr1rr2rrrrr+rr?rBlenr)rr-rr seeded_snapsunseeded_snaps current_pathd2s_filed2srseedrC from_chanto_chanunseedr snap_listrnsnaps_installedr= snap_infor?rconnsconn conn_colsplugslot plug_snaps rr0z0DistUpgradeQuirks._prepare_snap_replacement_datas )D,>,>> '$*:*::   I77??277??8+DELL+;;SAH))H%C NN H  ?8}T*::4@hhud+ HH^\B ((<<&)9g%> T" ?J 8Z.jj-::6B"JJ~|D (+Y'7t$  8 $$ff%58<,6OO==H[]  ,5Q<+=+=d+CAb+IK#' $zz|AKOK( J<'4>+A*. j)IL&  J "@ AB5A5G5G5I! 0 1D13 jK"((&&$)?<@0:AAL  JJ $ $ &yy)A, E 4t;<yy!2\!A!*1r||=MM"O$(#)*)1 I&--S-U3Z5L5LMMDG#OP "5y|DMM"K$(#)*)2 I&%( E").q I&%/K "$/DOOD !C! 0D*8)=)=)?* 4 %D%3 K"((&&$)?<@0:AAL  JJ $ $ &yy)A, E 4t;<yy!2\!A!*1r||=MM"O$(#)*)1 I&#((&-)F<@0:AAL ((*!!HNN40"D $ I9~* $Q?6>K 25=K 2!!"$)4%U* 4VC I OOCaG H H IKsD!V$W  W 'WW c |dz}t|dd5}|j|ddd t|dd5}|j|dddy#1swY3xYw#t$r"}tjd||Yd}~yd}~wwxYw#1swYyxYw#t$r"}tjd|||Yd}~yd}~wwxYw)N .distUpgraderrr&z0unable to write boot config backup to %s: %s; %sz-unable to write new boot config to %s: %s; %s)rrIOErrorr'r)r old_config new_configboot_config_filenamefailure_actionboot_backup_filenamerexcs r_replace_pi_boot_configz)DistUpgradeQuirks._replace_pi_boot_config s #7.#H *C'B $a # $  E*C'B $a # $ $ $ $  MML.^ E    $ $ E MMI.^ E E EsaA%AA%BBBA"A%% B.B  BBBB C (CC cd} tjj|d}t|dd5}|j }ddddjdjd D}||k(rt jd |y|j||||y#1swYbxYw#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.txtrxrr&+failed to open boot configuration in %s; %src3K|]X}|jdrd|z|jddzn*|jds|jdk(rd|zn|Zyw)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[rstriprwrns rryz:DistUpgradeQuirks._replace_fkms_overlay..)ss 78 @$ F LL13J K Lz*dkkm{.J A4 G   sAA T)keependsz3no fkms overlay or camera firmware line found in %s) rCrDrrrFileNotFoundErrorr'r splitlinesrr)rboot_dirrrr boot_configrs rrLz'DistUpgradeQuirks._replace_fkms_overlays ?  #%77<<,#G *C'B 'affh  'WW $...=   $ OO$%9 ;  $$ %9> K7 ' '   MMG. @  s(.B0B$B0$B-)B00 CCc d}gd tjj|d}t|dd5}|j }dddd fd }jDcgc]}|j}}||}d jd |D} | |k(rt jd |y|j|| ||y#1swYxYw#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)rzdisable_fw_kms_setup=1rz[pi3+]dtoverlay=vc4-kms-v3d,cma-128rz[pi02]rr[all]rrxrr&rc d}d}t|D]p\}}|j}|rT|}|jdr|cS|jdr|jdr|dk(}W|jdsid}l|dk(}r|S) NTrr[]rzinclude F) enumeraterrrQ)rSin_alllastindexrns rfind_insertion_pointz@DistUpgradeQuirks._add_kms_overlay..find_insertion_pointZsFD(/ - t{{} D'>?# -$--2D!%4"'!W_F - Krcp|} ||jdr|S ||||S#t$rYwxYw)Nr)r IndexError)rS insert_point added_linesrs radd_kms_overlayz;DistUpgradeQuirks._add_kms_overlay..add_kms_overlayrsX/6L &112IJ LK 0;E,| ,L   s ) 55rc3&K|] }|dz ywrfNrs rryz5DistUpgradeQuirks._add_kms_overlay..;TTD[;z)no addition of KMS overlay required in %s) rCrDrrrrr'rrrrr) rrrrrrrrnrSrrrs @@rrMz"DistUpgradeQuirks._add_kms_overlay@s  3    #%77<<,#G *C'B 'affh  ' 0 ,7+A+A+CD4DD&WW;U;;  $ OOG0 2  $$ %9> Ke ' '   MMG. @  PEs..C"C C",DCC"" DDch dd d}|j }d d d tjjd}t |d d 5}|j }ddd fd }fd}jDcgc]}|j} }||| } djd| D} | |k(rtjd|y|j|| ||y#1swYxYw#t $rtjd |YywxYwcc}w)Nzkernel=vmlinuzz!initramfs initrd.img followkernelzYou 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)rrxrr&rcVg}dx}}|D]}|dk(rJ|j||r|j|j|jd}R|jdr&|j|jd|z|jdr(d}|j|jd|z|j||rH|sD|j|jd|j|j|S|S)NFrTzdevice_tree_address=rMzkernel=uboot_rpi_)rr) rSresult removed_uboot added_kernelrn added_prefix change_prefixr kernel_lines r replace_ubootz=DistUpgradeQuirks._remove_uboot_on_rpi..replace_uboots F+0 0ML (7?MM$'' l3 k2 n5'+ __%;<MM-0MM#*-__%89%)MMM-0MM#*-MM$'1 (>#MM,/MM'*MM+.MM.1  rcg}d}d}|D]}|jdr|rd}|dvrd}|jdd}|j j|tj j |}d}t|dd 5}|D]7}|jdr|rd}|j|j9 ddd|d z} t j|||j||r|S|S#1swY?xYw#t$r#}tjd |||Yd}~3d}~wwxYw) NTFrM)zinclude syscfg.txtzinclude usercfg.txtr)maxsplitrxrr&rz7failed to move included configuration from %s to %s; %s) rrkrrrCrDrrrrenamerr'r) rSr skip_commentsfound_includesrnincluded_filenamertarget_filenamerr merge_prefixs rmerge_includesz>DistUpgradeQuirks._remove_uboot_on_rpi..merge_includess^F M"N (??3'M % HH &*N(, A (>q(A%MM,"5"56G"HI(* X5F)H%$(M/wG91$%9D#s3 (,1M"MM$++-8 99 '8.&HO< "3_E MM$'A (F  )99#< ':;L&5s<<.r r z!no u-boot removal performed in %s) rrCrDrrrrr'rrrrr)rrrrrrrr rnrSrrrrrrs ` @@@@@rrNz&DistUpgradeQuirks._remove_uboot_on_rpis:& < > (..n.MJ E N  #%77<<,#G *C'B 'affh  '* X* X,7+A+A+CD4DDnU34WW;U;;  $ OO?0 2  $$ %9> KO ' '   MMG. @  zEs/.D C=%D D/=DD D,+D,c& d}|jrytjdddvryddhjtjst j dy ttjdtjd}tj|}d }tjd djd }d |vsd|vrd}nd|vrd}ttgdt|z}tjddd|j ddddddd|dg tj"d}|j$j'd j)d!\}} } |xsd"} t| t j d$|d!| d%|d!| d& tjddd|j ddddddd'|dd(|d!| d(g }|j*d)k7rt j d*|d!| yd+|_tj,j/|j0d,} tj2tj,j5| d+-t7j8| j;d./tj<| |j>|j@|rod0} tj2tj,j5| d+-d1} tC| d25}|jEd3| d4|d5|d!| d6| d7 dddyd8}tj2tj,j5|d+-tC|d25}|jEd9|d:|d!| d;dddtjdtj,jG|g}|j*d)k7r7t j d?tj,jG|d@yy#t$rt j d YywxYw#t$rd#} YwxYw#1swYyxYw#1swYxYw)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 SansNXDG_SESSION_TYPEr)rttySUDO_UID PKEXEC_UIDzFCannot determine how root privileges were gained, will not change fontz3Cannot determine non-root UID, will not change fontzorg.gnome.desktop.interfaceXDG_CURRENT_DESKTOPrgMATEUKUIzorg.mate.interface X-Cinnamonzorg.cinnamon.desktop.interface)BudgieLXQtr)r*r+XFCEz systemd-runz--userz-Mz@.hostz--waitz--piperz--z/usr/bin/gsettingsr)z font-namer)r r'z' rUbuntu11zSetting generic font z& during the upgrade. Original font is rrh"rzFailed to change font to Tz!.config/upgrade-need-font-restoreri)modez//etc/xdg/autostart/upgrade-restore-font.desktopz'$HOME/.config/upgrade-need-font-restorerz[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-reloadenablezFailed to enable z%. Font will not be restored on reboot)$rrCgetenvrrr'r+r:pwdgetpwuidrrkboolrhrir1pw_namerr r rpartitionrErDrpw_dirrrpathlibPathtouchchownpw_uidpw_gidrrbasename)r temp_fontuidpwuidschemadesktops use_autostartrxfontrr,need_font_restore_fileautostart_fileflagr unit_files rrZz#DistUpgradeQuirks._set_generic_fonts    99' , ; L)66rzzB MM"   bii BIIl,CDECLL%E/992B7==cB X 8!3)F X %5F H I(m  NN Hdu}}oV,D xt !5x+ '??  ((..0;;C@q$x  I  -i[$@337&$qB C NN 8Temm_F+C hd %F8 1YKqa0    <<1  MM5i[$H I  $"$ LL="  BGGOO$:;dK +,222> 'u||D NN KK7$ G )S ! Q GG4(-vQtf566  &   du}}oV4   NN  du}}oV4 bgg&&y1   <<1  MM-bgg.>.>y.I-JK@@ A m  MME    H D >    s=!AQ7 Q)"Q;.RQ&%Q&) Q87Q8;RRc6|jjj} |djsy|dj}|Dcgc]\}}}|j jr| }}}t|stjd|jjdjdtj|jjj|jjdyycc}}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_deleterrr)rr? provides_mtarver installed_mtas rr]z.DistUpgradeQuirks._maybe_remove_gpg_wks_servers%%,, )*66 !78FFL%1!1c>>--M=! LL5  OO ! !"2 3 ? ? ? O    5 5 6 > >%%&67 "   s(D D #D)D D DDc|jdk7ryd|jjvr#|jjdjrt j dt j}|jdDcic]}|j|}}|j|jj}|8|jjd}td|jd|d }nd }|j j td 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 rrrz.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'rr~rrrsr)rteolstrftimerrurr)rrrxreleasesr.rupdates_end_msgs rr=z/DistUpgradeQuirks._test_and_fail_on_armhf_raspisL 99   4??#8#8 8 OO ! !"5 6 C C MMA B--/BH-! H$<<(@(@AL'*..77@ "#),*>*>)?@&&1]!5##% JJ  DC$ $  OO ! ! #A D 9 s Ec&|jjD]}|js|jr|jjr4t j d|j|jjDcgc]}|j|jf}}|jjDcgc]\}}}| }}}|D] }d|f|vr d|f|vrd|f|vrtj|jj|j}|jY|jj |k7rst j d|jd|j|j" }|j%dd| |j'd tj(|jjj+|t j d |jycc}wcc}}w) z LP: #2061175 zSearching for replacement for ReplacesBreaks ConflictsNzFound replacement z for F)rr from_userrz!Failed to find a replacement for )rr?rBr downloadabler'r+r_pkgrev_depends_listdep_type_untranslated parent_verrQrPackagerR_candis_auto_installedrrTrr) rpackagedepreverse_depends_listrrVrQ replacementrbs rr^z3DistUpgradeQuirks._install_t64_replacement_packagess,,; G''  W%6%6%C%C MM:7<<.I J#<<88$**CNN;$ $ 3:,,2L2LMYQ3SMMM$( $,@@sO+?? #&.BB!kkOO))NN ((0((..#5 ()9)9(:;"<<.* !( 9 99 ((%53<)>##U#3##DOO$9$9:BB7KE( L 7 ~Fs; $ Ns H? H c|jjdk7ry |jjd}|jsyd}dD]W} |jj|}|js*t j d|d|jddd }Y|rK|jd tj|jjj|yy#t$rYywxYw#t$rYwxYw) z LP: #2061891 jammyNufwF)znetfilter-persistentziptables-persistentzKeeping z, and removing ufw as a result.rTr) rrtr?r;rBr'r(rrTrrr)rrq remove_ufwrrs rr_z$DistUpgradeQuirks._handle_ufw_breaks#s  ?? # #w .  //''.C  C "D oo++D1 tf$CD  %5 A!  "  OOUO +    5 5 6 > >s C +     s#C. C=. C:9C:= D D c tjddg}|jDcgc]#}|jj d%}}d|vrd|j jvr|j jdjrtjdtj}|j|j jxsd}|jj!t#d |t#d |j j%yyyycc}w#t $rYywxYw) z LP: #2065229 rrrNz pc-kernelzubuntu-desktop-minimalzDetected TPM FDE systemz next releasez%Sorry, cannot upgrade this system to zUpgrades for desktop systems running TPM FDE are not currently supported. Please see https://launchpad.net/bugs/2065229 for more information.)ri check_outputrrrkrrr?rBr'r+r~rrur}rrrr)rrrTsnapsrrus rr>z+DistUpgradeQuirks._test_and_fail_on_tpm_fdeGs& "//0@AI4=4H4H4JKqQXXZ%%'*KEK 5 $(=(= = OO ! !": ; H H MM3 4--/Bjj!7!78JNG JJ  ;G9E,  OO ! ! #' I > ! L    s")D:(D5D:5D:: EE)z ./patchesrr)r)z/boot/firmware)@__name__ __module__ __qualname____doc__rr1r5rIrOrRr[r`rcror9rrrr:rr;r<rr@rAr3rQrrrrYrVrWrXrrUrFrGrKrJrrTrrhrzrrrrrbrrrr0rrLrMrNrZr]r=r^r_r>r rrr r (s\ &&+\' 2:,(* !"* 3$(B(0'CR$(($(,(:',-(^0 d;";  > G BL F O>$@&*P!LF$( -<^> @4:" D= .`:&HT G&CJE"#KJFKPvKpPAd!F+$Z?B"DH!$rr )rrr~r r'rCr6rr\rir<rrutilsrDistUpgradeGettextrrr{r r rrr|s?,   ",@$@$r