ó š v_c@s.dZddlZddlmZmZmZmZddlmZddl m Z ddl m Z m Z mZddl mZddlZddlZddlZddlmZed „Zd efd „ƒYZd efd „ƒYZd„Zdefd„ƒYZd„Ze dkr*eƒndS(s+ Update metadata (updateinfo.xml) parsing. i’’’’N(tutf8_text_wraptto_utf8t to_unicodet_(t YumRepository(tFakeRepository(tto_xmlt decompresstrepo_gen_decompress(tcElementTree_iterparse(t ArchStorageccsvy,x%t|ƒD]\}}||fVqWWnCtk rq|r[|jtdƒ|ƒqrtjdI|IJnXdS(s@ Works like iterparse, but hides XML errors (prints a warning). s$Updateinfo file is not valid XML: %ss!Updateinfo file is not valid XML:N(t iterparset SyntaxErrortcriticalRtsyststderr(tfilenametloggerteventtelem((s1/usr/lib/python2.7/site-packages/yum/update_md.pytsafe_iterparse's tUpdateNoticeExceptioncBseZdZRS(s0 An exception thrown for bad UpdateNotice data. (t__name__t __module__t__doc__(((s1/usr/lib/python2.7/site-packages/yum/update_md.pyR2st UpdateNoticecBs”eZdZdddd„Zd„Zd„Zd„Zd„Zd„Z dd „Z d „Z d „Z d„Z d„Zd„Zd„Zd„Zd„ZRS(s@ A single update notice (for instance, a security fix). cCs³idd6dd6dd6dd6dd6dd6dd6dd 6dd 6dd 6dd 6dd 6dd6dd6dd6gd6gd6td6|_|r|j|ƒn||_||_dS(Nttfromttypettitletreleasetstatustversiont pushcountt update_idtissuedtupdatedt descriptiontrightstseveritytsummarytsolutiont referencestpkglisttreboot_suggested(tFalset_mdt_parset_repoidt_vlogger(tselfRtrepoidtvlogger((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt__init__=s.  cCsNt|ƒtkr#t|jƒ|S|jj|ƒ}|dkrJd}n|S(s: Allows scriptable metadata access (ie: un['update_id']). RN(RtinttsortedR.tgettNone(R2titemtret((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt __getitem__Ys   cCs ||jkS(s% Allows quick tests for foo in blah. (R.(R2R:((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt __contains__bscCs||j|(thasattrR0R9(tun((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt_ridmscs ˆjdkrdStdƒ}|ˆjd;}|dˆˆƒ|f7}|dˆj|ˆj|f7}|dˆˆƒ|f7}ˆjjtj|ƒdS(s=Log the mismatched data similarly to conflict markers in git.Ns(Duplicate of %s differs in some fields: R"s<<<<<<< %s:%s s%r ======= %r s >>>>>>> %s:%s(R1R9RR.tlogt logginglevelstDEBUG_3(tdatatmsg(RBtotherR2(s1/usr/lib/python2.7/site-packages/yum/update_md.pyt _log_failuress "R.RR"RR&R'RR#R$R R!RRR(R%R)tstablettesting(stypes update_idsstatussrightssseveritysreleasesissuedsupdatedsversions pushcountsfromstitlessummarys descriptionssolution(RJRK(RJRK(R@R-R.tTrue(R2RHRIRF((RBRHR2s1/usr/lib/python2.7/site-packages/yum/update_md.pyt__eq__is0        cCs ||k S(N((R2RH((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt__ne__œstfilesR(R&R)cCsŒd|j}|jdrL|jd|jdkrL|d|jd7}ntd„|jdƒ}t|ƒrįd|krįd}x@|D]8}|d |d d |kr·d |d pŗd f7}qŠW||d jƒd7}ntd„|jdƒ}t|ƒrVd|krVd}x |D]}|d|d 7}qW||d jƒd7}n|jdrØd|krØt|jddddd+ƒ} |ddj| ƒ7}n|jdrśd|krśt|jddddd-ƒ} |ddj| ƒ7}n|jdrLd|krLt|jddddd/ƒ} |ddj| ƒ7}n|jd ržd |kržt|jd dddd1ƒ} |d!dj| ƒ7}n|jd"ršd"|kršt|jd"dddd3ƒ} |d#dj| ƒ7}nd$|kr|d Sttjj ƒƒ} d%} xR|jd&D]C} x:| d'D].}|d(| krZq>n| d|d)7} q>Wq-W|| d jƒ7}|S(4Ns, =============================================================================== %(title)s =============================================================================== Update ID : %(update_id)s Release : %(release)s Type : %(type)s Status : %(status)s Issued : %(issued)s R$R#s Updated : %scSs|ddkS(NRtbugzilla((tr((s1/usr/lib/python2.7/site-packages/yum/update_md.pytÆsR*tbugss Bugs :s %s%s :tidRs - %sRi’’’’s cSs|ddkS(NRtcve((RQ((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRRøstcvess CVEs :s %s :R(twidthi@tsubsequent_indentt i s: s Summary : %s R%sDescription : %s R)s Solution : %s R&s Rights : %s R's Severity : %s ROs Files :R+tpackagestarchRs s : s s : s s : s s : s s : ( R.tfiltertlentrstripRtjointsettrpmUtilsR[t getArchList(R2t skip_datatheadtbzstbuglisttbzRVtcvelistRURFtdesctarchestfilelisttpkgtfile((s1/usr/lib/python2.7/site-packages/yum/update_md.pyttextŸs^ '        cCst|jƒƒS(N(RRn(R2((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt__str__źscCst|jƒƒS(N(RRn(R2((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt __unicode__ģscCs|jS(s Return the metadata dict. (R.(R2((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt get_metadataļscCs>|jdkr.x'dD]}|jj|ƒ|j| tupdateRRRR RTsNo id element foundR"R!R#tdateR$R*R%R&R'R(R)R+RRsNo update element foundN(sfromstypesstatussversion(ttagtattribR8R.RnRt_parse_referencest_parse_pkglist(R2RRutchild((s1/usr/lib/python2.7/site-packages/yum/update_md.pyR/ósB    cCstxm|D]e}|jdkr`i}x$d D]}|jj|ƒ|| t referenceRTthrefRRR*sNo reference element foundN(sidRzstypestitle(RtRuR8R.tappendR(R2RRyRFt refattrib((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRv"s  cCsŗx³|D]«}igd6}d|jkrB|jjdƒ|d RZtshorttnametpackageR+N(RuR8RtRnR{t_parse_packageR.(R2Rt collectionRFR:((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRw6s   !cCsŻi}x$d D]}|jj|ƒ|| R[tepochR~R Rtsrcit 0123456789RtsumRR,(sarchR‚snamesversionsreleaseRƒN(RuR8R9RtRnRLR.(R2RRtpkgfieldRx((s1/usr/lib/python2.7/site-packages/yum/update_md.pyR€Ks   "cCs‘dt|jdƒt|jdƒt|jdƒt|jdƒt|jdƒt|jdƒt|jdƒt|jd d tƒt|jd ƒf }|jd rŃ|d t|jd d tƒ7}n|jdrü|dt|jdƒ7}n|jdr'|dt|jdƒ7}n|jdrR|dt|jdƒ7}n|jdr}|dt|jdƒ7}n|jdrg|d7}xĆ|jdD]“}|dr|dt|dd tƒt|dd tƒt|dd tƒt|dd tƒf7}q¢|dt|dd tƒt|dd tƒt|dd tƒf7}q¢W|d7}n|jdrƒ|d7}xõ|jdD]ę}|dt|d d tƒt|d!ƒf7}x„|d"D]™}|d#t|d$d tƒt|d!d tƒt|dd tƒt|d%d tƒt|dd tƒt|d&pFd'd tƒt|d(ƒf7}qĖW|d)7}qŒW|d*7}n|d+7}|S(,s.Generate the xml for this update notice objects§ %s %s %s %s RRRR R"RRR#RuR%R$s R(s %s R)s %s R&s %s R's %s R*s s8 RzRTs. s R+s s2 %s R}R~RZsƒ %s R[RƒR‚t0Rs s s (RR.RL(R2RGtreftcollRl((s1/usr/lib/python2.7/site-packages/yum/update_md.pytxmlms\    $       &1&     N(sfilesssummarysrightsssolution(RRRR9R5R<R=R?RMRNRnRoRpRqR/RvRwR€RŠ(((s1/usr/lib/python2.7/site-packages/yum/update_md.pyR7s    3  K    /   "cCs=tjj|d|d|df|d|d|dfƒS(s- Compare two "std." tuples, (n, a, e, v, r). iii(Rat miscutilst compareEVR(ttup1ttup2((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt_rpm_tup_vercmp«s!tUpdateMetadatacBs}eZdZgd d d„Zd d„ZeeƒZd„Zd„Z d„Z dd„Z d„Z d „Z d d „ZRS( s* The root update metadata object. cCs‘i|_i|_i|_g|_||_||_x9|D]1}y|j|ƒWq=tjk rmq=q=Xq=Wt ƒ|_ |j j |_ dS(N( t_noticest_cachet _no_cachet_repost_loggerR1taddtErrorst RepoMDErrorR t arch_storagetarchlist(R2treposRR4trepo((s1/usr/lib/python2.7/site-packages/yum/update_md.pyR5¶s         cCs9|dkr|jjƒS||jkr5|j|p8gS(s Return all notices. N(R9R‘tvaluesR“(R2R~((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt get_noticesČs  cCsLt|ƒtgƒtdƒfkr6dj|ƒ}n|jj|ƒpKdS(si Retrieve an update notice for a given (name, version, release) string or tuple. t-(N(RR_R’R8R9(R2tnvr((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt get_noticeŠs$c Cs¹|}|d}|d}g}g}tƒ}x+|j|ƒD]}x|dD]} xü| dD]š} t} | d|ks| d|krĖ||kra| d|kra| d|jkrat} qĖqan| d| d| dpęd| d | d f}t||ƒdkrqan| r1|j||fƒqa|j||fƒ|j|ƒqaWqPWq?Wx6|D].\}}||krd|j||fƒqdqdW|jd td d „dtƒ|S(s Retrieve any update notices which are newer than a given std. pkgtup (name, arch, epoch, version, release) tuple. Returns: list of (pkgtup, notice) that are newer than the given pkgtup, in the order of newest pkgtups first. iiR+RZR~R[R‚R‡R RtcmptkeycSs|dS(Ni((tx((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRRstreverse( R`RžR-RšRLRR{R–tsort( R2tpkgtupt oldpkgtupR~R[R;tother_arch_listtnoticestnoticetupkgRlt other_arch((s1/usr/lib/python2.7/site-packages/yum/update_md.pytget_applicable_noticesįs6    /  c CsŁ| s|d rtS|d|jkrK|j|d}||krJtStƒ}x#|dD]}|j|dƒq^WxJ|dD]>}|d|kr q„n|j|dƒ|dj|ƒq„Wtƒ}x#|dD]}|j|dƒqŚWxJ|dD]>}|d|krqn|j|dƒ|dj|ƒqW|}n||j|d s (twriteR‘RRŠ(R2tfileobjRGR«tend((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRŠus N(RRRR9R5RžtpropertyRŖR”R®R“R–RpRoRŠ(((s1/usr/lib/python2.7/site-packages/yum/update_md.pyR°s    % 2 5  cCsĪddl}|jjƒd„}ttjƒdkrA|ƒnyItjdGHtƒ}x"tjdD]}|j|ƒqgWt|ƒGHWn=t k rÉtj dtjdtjdfIJ|ƒnXdS(s update_md test function. i’’’’NcSs)tjdtjdIJtjdƒdS(NsUsage: %s ...ii(RRtargvtexit(((s1/usr/lib/python2.7/site-packages/yum/update_md.pytusage‘siis%s: No such file:'%s'i( tyum.misctmisct setup_localeR]RRÉRR–RÄtIOErrorR(tyumRĖtumtsrcfile((s1/usr/lib/python2.7/site-packages/yum/update_md.pytmainŒs       t__main__(!RRtyum.i18nRRRRt yum.yumRepoRt yum.packagesRRĢRRRR R R—RDtrpmUtils.miscutilsRat rpmUtils.archR R9Rt ExceptionRtobjectRRRRÓR(((s1/usr/lib/python2.7/site-packages/yum/update_md.pyts& "    ’u Ü