v_c@sDddlZddlZddlZdZdddYZdS(iNcCstjj||S(N(trpmUtilst miscutilst compareEVR(ttup1ttup2((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt _vertup_cmpstUpdatescBseZdZdZdZdZdZdZddZ dZ dZ d Z d d Z d Zd ZdZdZdddZdddZdddZddddZddddZddddZdddZdddZdZRS(sM This class computes and keeps track of updates and obsoletes. initialize, add installed packages, add available packages (both as unique lists of name, arch, ver, rel, epoch tuples), add an optional dict of obsoleting packages with obsoletes and what they obsolete ie:: foo, i386, 0, 1.1, 1: bar >= 1.1. cCs||_||_i|_d|_i|_i|_d|_tdddddddg|_ t j j |_ t j j|j |_t j j|j |_t j j|j |_|j|jd|_|j|jd d |j|_i|_i|_d |_i|_dS( Nitkernels kernel-smptglibcskernel-hugememskernel-enterprises kernel-bigmems kernel-BOOTitfilter(t installedt availablet rawobsoletestNonet_obsoletes_by_nametobsoleted_dicttobsoleting_dictt exactarchtsett exactarchlistRtarcht canonArchtmyarchtisMultiLibArcht _is_multilibt getArchListt _archlisttgetMultiArchInfot_multilib_compat_archest makeNADictt installdictt availdictt updatesdictt updating_dicttdebugt obsoletes(tselftinstlistt availlist((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt__init__ s,           cCsUxN|D]F}||krqnt|j||||<||s||=qqWdS(N(R t__ne__(R$tdict_tkeystvaluetkey((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt _delFromDictEs    c Cs|\}}}}}xx|dfD]j}||f|kr"t|||fj|||f|||f<|||fs|||f=qq"q"WdS(N(R R R(( R$R)tpkgtuptntatetvtrtaa((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt_delFromNADictMs /cCs9||jkrdS|jj||j|j||j|j|jj|g||j|j|jj|g|||jkr|j rx@|j|D]1\}}}|j|j |g|||fqW|j|=qn|j|j |j j|g||j|j |j j|g|dS(s3remove available pkgtup that is no longer availableN( R tremoveR5RR-R!R tgetR RRR(R$R.tnametflagtversion((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt delPackageUs%% &%cCs|jr|GHndS(N(R"(R$tmsg((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt debugprinths c Cs+i}x|D]\}}}}} |r@|df|kr@q n||f|kreg|||f( R$R8tarchlistR?t returnlistt high_vertupR.R/R0R1R2R3tvertup((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt"returnHighestVerFromAllArchsByNames    cCsZxS|jD]H}t|j|dkr |j|}tjj||j|R7RRt rangeCheckR*t_reduceListNewestByNameArch(R$R?tnewestR.R#R8R9R:tobsdicttobs_flagt obs_versiont obsoletingtobslistRAtnewtold((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytcheckForObsoletes4   %$    c Cs<i}i}xJ|jD]?\}}}}}||krDg||R RRRRURIR#tmakeObsoletedDict(R$RXt obs_archesR/R0R1R2R3R.R8Rtepochtvertreltobs_nR9tobs_etobs_vtobs_rtrpm_atrpm_etrpm_vtrpm_rt willInstalltins_atins_etins_vtins_rtpkgvert installedver((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt doObsoletess<   && &    5 cCsi|_x\|jD]Q}xH|j|D]9}||jkrLg|j| [obsoleting package], this is to make it easier to look up what package obsoletes what item in the rpmdbN(RR#R>RRSRT(R$R]R^t obsoletedt obsoletingsR[((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyR`s   c" s g}g}i}|j}|j}x9|jD]+\}}||kr1|||f=q1q1q1Wx|D]\}}|j|||f\}} } xc|||fD]P\} } } || | f| | | fkr|||fj| | | fqqWqgWx|D]\}}||f|jkrx|j||fD]\}}}y&|j|||f\} } } Wntjk rq;q;Xtjj | | | f|||f}|dkr;y$|||fj| | | fWqt k rqXq;q;WqqWxS|jD]Et fd|}|j dd fgj|qWx4|jD]&}t||dkrf||=qfqfWx|D]\}}|d krqn|d f|jkrg}g}x1||d fD]\}} } } |j|qWx4|j|d fD]\}} } } |j|qWt|dkset|dkr|jd||j|q|jd||j||fqqWx1|D])\}}||jkr||f|jkr|j|j||f\}}}||f|kr|j|||f\} } } tjj | | | f|||f}|dkr|||||f|krg||||||fQsisputting %s in complex updatesputting %s in simple updatetnoarchsprocessing %s.%ss processing %sRN( RRR*RIR6RRRCRRt ValueErrortmapRTR textendRBR>R=RRRRtmultilibArchestarchesRRRRNRtgetBestArchFromListR tmakeUpdatingDict("R$t simpleupdatet complexupdatet updatedicttnewpkgsRJR/R0RERFRGR1R2R3RjRkRlRHt all_archestnakeyt installarchst availarchsRit archliststbiarchest multicompatt multiarchlistt thisarchlistttmplistthighestinstalledpkgsthipdictthighestavailablepkgsthapdictt instarchs((Rxs4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt doUpdatess     "!+#&' $ ' #&$%"' ;##' =      &   #   ' < #    ' : cCsli|_x\|jD]Q}xH|j|D]9}||jkrLg|j| [installed package], this is to make it easier to look up what package will be updating what in the rpmdbN(R!R R>(R$R^R]((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyRs  c Csg}|s|rx|D]\}}}}} |re||kre|j||||| fqqen|r||kr|j||||| fqqqqWn|}|S(s?returns a set of pkg naevr tuples reduced based on name or arch(R>( R$R?R8RRKR/R0R1R2R3((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytreduceListByNameArchs    c CsEg}x<|jD]1}x(|j|D]}|j||fq$WqWg}|rxW|D]L\\}}} } } }||krX|j||| | | f|fqXqXWn|r xW|D]L\\}}} } } }||kr|j||| | | f|fqqWnx3|D]+} y|j| Wqtk r<qXqW|S(s`returns updates for packages in a list of tuples of: (updating naevr, installed naevr)(R R>R6R{( R$R8RRKtoldtuptnewtupRR/R0R1R2R3titem((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytgetUpdatesTupless&" ," ,  cCsXg}x6|jD]+}x"|j|D]}|j|q$WqW|j|||}|S(s5returns updating packages in a list of (naevr) tuples(R R>R(R$R8RRKRR((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytgetUpdatesList,s ic Cs(g}|jj}|r-|j|}nx9|D]1}x(|j|D]}|j||fqHWq4Wg}|s{|rx|D]\}\} } } } } |r|| kr|j|| | | | | ffqqn|r|| kr|j|| | | | | ffqqqqWn|}|S(sAreturns obsoletes for packages in a list of tuples of: (obsoleting naevr, installed naevr). You can specify name and/or arch of the installed package to narrow the results. You can also specify newest=1 to get the set of newest pkgs (name, arch) sorted, that obsolete something(R#R*RVR>(R$RWR8RRR\tobstuptrpmtupRKR/R0R1R2R3((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytgetObsoletesTuples:s(  " "  "cCs(g}|jj}|r-|j|}nx9|D]1}x(|j|D]}|j||fqHWq4Wg}|s{|rx|D]\\} } } } } }|r|| kr|j| | | | | f|fqqn|r|| kr|j| | | | | f|fqqqqWn|}|S(sBreturns obsoletes for packages in a list of tuples of: (obsoleting naevr, installed naevr). You can specify name and/or arch of the obsoleting package to narrow the results. You can also specify newest=1 to get the set of newest pkgs (name, arch) sorted, that obsolete something(R#R*RVR>(R$RWR8RRR\RRRKR/R0R1R2R3tinsttup((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytgetObsoletersTuples]s(  " "  "cCs@|jj}|r'|j|}n|j|||}|S(s^returns obsoleting packages in a list of naevr tuples of just the packages that obsolete something that is installed. You can specify name and/or arch of the obsoleting packaging to narrow the results. You can also specify newest=1 to get the set of newest pkgs (name, arch) sorted, that obsolete something(R#R*RVR(R$RWR8RRRK((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytgetObsoletesLists c Csjg}x]|jD]R}xI|j|D]:}|\}}}} } ||kr$|j|q$q$q$WqW|S(s:returns a list of pkgtuples obsoleting the package in name(R#R>( R$RWR8RKR]RR/R0R1R2R3((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pytgetObsoletedLists  cCsi}i}g}x|jD]}d||R(R$R8RtupdatestinstRR.RK((s4/usr/lib/python2.7/site-packages/rpmUtils/updates.pyt getOthersListscCsi}t}x|D]}|\}}}}} ||f|krS||||fs