v_c@s.dZddlZddlmZmZmZmZddlmZddl m Z ddl m Z m Z mZddl mZddlZddlZddlZddlmZed Zd efd YZd efd YZdZdefdYZdZe dkr*endS(s+ Update metadata (updateinfo.xml) parsing. iN(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 UpdateNoticecBseZdZddddZdZdZdZdZdZ dd Z d Z d Z dZ dZdZdZdZdZRS(s@ A single update notice (for instance, a security fix). cCsidd6dd6dd6dd6dd6dd6dd6dd 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_ridmscsjdkrdStd}|jd;}|d|f7}|dj|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)cCsd|j}|jdrL|jd|jdkrL|d|jd7}ntd|jd}t|rd|krd}x@|D]8}|d |d d |krd |d pd f7}qW||d jd7}ntd|jd}t|rVd|krVd}x |D]}|d|d 7}qW||d jd7}n|jdrd|krt|jddddd+} |ddj| 7}n|jdrd|krt|jddddd-} |ddj| 7}n|jdrLd|krLt|jddddd/} |ddj| 7}n|jd rd |krt|jd dddd1} |d!dj| 7}n|jd"rd"|krt|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 j7}|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.pytsR*tbugss Bugs :s %s%s :tidRs - %sRis cSs|ddkS(NRtcve((RQ((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRRstcvess 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.pyttexts^ '        cCst|jS(N(RRn(R2((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt__str__scCst|jS(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_metadatascCs>|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  cCsx|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   !cCsi}x$d D]}|jj||| R[tepochR~R Rtsrcit 0123456789RtsumRR,(sarchRsnamesversionsreleaseRN(RuR8R9RtRnRLR.(R2RRtpkgfieldRx((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRKs   "cCsdt|jdt|jdt|jdt|jdt|jdt|jdt|jdt|jd d tt|jd f }|jd r|d t|jd d t7}n|jdr|dt|jd7}n|jdr'|dt|jd7}n|jdrR|dt|jd7}n|jdr}|dt|jd7}n|jdrg|d7}x|jdD]}|dr|dt|dd tt|dd tt|dd tt|dd tf7}q|dt|dd tt|dd tt|dd tf7}qW|d7}n|jdr|d7}x|jdD]}|dt|d d tt|d!f7}x|d"D]}|d#t|d$d tt|d!d tt|dd tt|d%d tt|dd tt|d&pFd'd tt|d(f7}qW|d)7}qW|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[RRt0Rs s s (RR.RL(R2RGtreftcollRl((s1/usr/lib/python2.7/site-packages/yum/update_md.pytxmlms\    $       &1&     N(sfilesssummarysrightsssolution(RRRR9R5R<R=R?RMRNRnRoRpRqR/RvRwRR(((s1/usr/lib/python2.7/site-packages/yum/update_md.pyR7s    3  K    /   "cCs=tjj|d|d|df|d|d|dfS(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_vercmps!tUpdateMetadatacBs}eZdZgd d dZd dZeeZdZdZ dZ ddZ dZ d Z d d ZRS( s* The root update metadata object. cCsi|_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.pyR5s         cCs9|dkr|jjS||jkr5|j|p8gS(s Return all notices. N(R9RtvaluesR(R2R~((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt get_noticess  cCsLt|tgtdfkr6dj|}n|jj|pKdS(si Retrieve an update notice for a given (name, version, release) string or tuple. t-(N(RR_RR8R9(R2tnvr((s1/usr/lib/python2.7/site-packages/yum/update_md.pyt get_notices$c Cs|}|d}|d}g}g}t}x+|j|D]}x|dD]} x| dD]} t} | d|ks| d|kr||kra| d|kra| d|jkrat} qqan| d| d| dpd| d | d f}t||dkrqan| r1|j||fqa|j||f|j|qaWqPWq?Wx6|D].\}}||krd|j||fqdqdW|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[RRR RtcmptkeycSs|dS(Ni((tx((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRRstreverse( R`RR-RRLRR{Rtsort( R2tpkgtupt oldpkgtupR~R[R;tother_arch_listtnoticestnoticetupkgRlt other_arch((s1/usr/lib/python2.7/site-packages/yum/update_md.pytget_applicable_noticess6    /  c Cs| s|d rtS|d|jkrK|j|d}||krJtSt}x#|dD]}|j|dq^WxJ|dD]>}|d|krqn|j|d|dj|qWt}x#|dD]}|j|dqWxJ|dD]>}|d|krqn|j|d|dj|qW|}n||j|d s (twriteRRR(R2tfileobjRGRtend((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRus N(RRRR9R5RtpropertyRRRRRRpRoR(((s1/usr/lib/python2.7/site-packages/yum/update_md.pyRs    % 2 5  cCsddl}|jjd}ttjdkrA|nyItjdGHt}x"tjdD]}|j|qgWt|GHWn=t k rtj dtjdtjdfIJ|nXdS(s update_md test function. iNcSs)tjdtjdIJtjddS(NsUsage: %s ...ii(RRtargvtexit(((s1/usr/lib/python2.7/site-packages/yum/update_md.pytusagesiis%s: No such file:'%s'i( tyum.misctmisct setup_localeR]RRRRRtIOErrorR(tyumRtumtsrcfile((s1/usr/lib/python2.7/site-packages/yum/update_md.pytmains       t__main__(!RRtyum.i18nRRRRt yum.yumRepoRt yum.packagesRRRRRR R RRDtrpmUtils.miscutilsRat rpmUtils.archR R9Rt ExceptionRtobjectRRRRR(((s1/usr/lib/python2.7/site-packages/yum/update_md.pyts& "    u