+eTp% @sQddlmZmZddlZejddeddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZddlmZdd d d d d ddddg ZddlmZddZddZddZddZddZddZdS) )absolute_importprint_functionNignorezAccessed deprecated)datetime) OptionParser)gettextz/binz/bootz/etcz/initrdz/libz/lib32z/lib64z/sbinz/usrz/var)DistUpgradeConfigc Cst}|jddddddddd td |jd d dd ddd td|jddddddd|jddddd|jddddd|jdddddd td|jdddddd td|jdddddddd td|jd ddddd td!|jd"dd#dd$d td%|jd&dddd'ddd td(|jS))z/ setup option parser and parse the commandline z-sz --sandboxdestZuseAufsdefaultFaction store_truehelpzSandbox upgrade using aufsz-cz--cdromZ cdromPathNzAUse the given path to search for a cdrom with upgradable packagesz--have-prerequistsZhavePrerequistsz--with-networkZ withNetworkz--without-networkZ store_falsez --frontendfrontendz_Use frontend. Currently available: DistUpgradeViewText, DistUpgradeViewGtk, DistUpgradeViewKDEz--modemodeZdesktopz(*DEPRECATED* this option will be ignoredz --partialpartialz:Perform a partial upgrade only (no sources.list rewriting)z--disable-gnu-screenzDisable GNU screen supportz --datadirdatadir.z Set datadirz--devel-releaseZ devel_releasez"Upgrade to the development release)rZ add_option_ parse_args)parserr=/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeMain.pydo_commandline;s4           rcCs|jddd}tjj|s7tj|ntj|drtj}|d|j|j |j |j |j f}tjj|stj|nxItj|dD]1}t j|tjj|tjj|qWntjj|d}|jr|d7}nt|dWd QXtjd tjd |d d ddtjd|jtjddjtjtjdtjjtjdtj|S)z setup the logging ZFilesZLogDirz/var/log/dist-upgrade/z/*.logz/%04i%02i%02i-%02i%02izmain.logz.partialaNlevelfilenameformatz%%(asctime)s %(levelname)s %(message)sfilemodewzUsing config files '%s'zuname information: '%s' zapt version: '%s'zpython version: '%s')ZgetWithDefaultospathexistsmkdirglobrnowZyearZmonthZdayZhourZminuteshutilZmovejoinbasenameropenloggingZ basicConfigDEBUGinfoZ config_filesunameaptZapt_pkgVERSIONsysversion)optionsconfiglogdirr&Z backup_dirffnamerrr setup_loggingYs0 ,2   r8cCs;yddlm}Wn#tk r9tjddSYnXtjj|d}tjd|tj d}|}|j ddd |d d d d tj |yWt j d dgdt j dd jd}ttjj|ddj|Wn6tk r6}ztjd|WYdd}~XnXdS)Nr)AptClonezfailed to import AptClonezapt-clone_system_state.tar.gzzcreating statefile: '%s'6Z sourcedir/targetZwith_dpkg_statusTZ scrub_sourcesZlspciz-nnstdoutuniversal_newlinesrz lspci.txtrzlspci failed: %s)Z apt_cloner9 ImportErrorr+errorr!r"r(debugumaskZ save_state subprocessPopenPIPE communicater*writeOSError)r5r9r<Z old_umaskZcloneserrrsave_system_statexs$     )rKc Csx|jg|jddD]}|s/qnyOddlm}|d|d}t||}|d|d|j}PWqtk r}z0tjd||ft d ||fWYd d }~XqXqWtj d t d t j d |S) z0 setup view based on the config and commandline ZViewr) import_modulerZ DistUpgrader5rzcan't import view '%s' (%s)zcan't load %s (%s)Nz!No view can be imported, abortingr) rZgetlist importlibrLgetattrr Exceptionr+Zwarningprintr@r1exit) r3r4r5Zrequested_viewrLZ view_modulZ view_classinstancerJrrr setup_views #+   rScCsd}yCtjddgdtjddjd}tjd|Wn#tk rntjd d SYnX||krtjd tj d dd dd|gndtj dTrzscreen returned: '%s'zscreen could not be runNz)found active screen session, re-attachingz/usr/bin/screenz-dz-rz-p1RELEASE_UPGRADER_NO_SCREENz-ez\0\0z-Lz-cZscreenrcz-Szre-exec inside screen: '%s') rCrDrErFr+rArHr-r!execvenvironr1argv)Z SCREENNAMEoutcmdrrr%run_new_gnu_screen_window_or_reattachs(     " r[c Cspt\}}t|j}t||}ddlm}tjd|tj d|jdksy|jdkrt j j t j d}tjd|nt|||}|jrdt jkr|j rtndd lm}|||d |j}tj|j|jrR|jsBtjdntjd nt||jrld SdS) z main method r)r0z%release-upgrader version '%s' startedzubuntu-release-upgraderNrZmorU)DistUpgradeControllerrr)rr rr8ZDistUpgradeVersionr0r+r-r textdomainr!r"r(getcwdbindtextdomainrSZ needs_screenrWZdisable_gnu_screenr[r\atexitregisterZ_enableAptCronJobrZdoPartialUpgrader1rQrKZrun) r3argsr4r5r0Z localedirZviewr\Zapprrrmains2        rc)Z __future__rrwarningsfilterwarningsDeprecationWarningr/r`rr%r+r!r'rCr1rZoptparserrZ SYSTEM_DIRSZDistUpgradeConfigParserr rr8rKrSr[rcrrrrs>                "