v_c@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddl mZddlZ ddlmZmZmZddlZddlZddlZddlTddlmZddlZddlZejjddd lmZmZy)ddl Z e!e d  rde"Z nWne#k r~e"Z nXddl$Z$ddl%Z%d Z&d Z'e(d Z)dde"dZ*dfdYZ+dfdYZ,de-fdYZ.e,dZ/de/_0de.fdYZ1de-fdYZ2dfdYZ3de.e2fdYZ4d Z5d!e4fd"YZ6d#fd$YZ7d%fd&YZ8d'd>Z9d'd'>Z:d'd(>Z;d'd)>Z<d'd*>Z=d'd+>Z>d'd,>Z?d'd->Z@d'd.>ZAd'd/>ZBd0e-fd1YZCd2eCfd3YZDd4fd5YZEiaFd6eEfd7YZGe,d8ZHdeH_0d9e6fd:YZId;e6fd<YZJd=eJfd>YZKdS(?sA Classes and functions dealing with rpm package representations. iN(tPopentPIPE(t RpmUtilsError(t flagToStringtstringToVersiontcompareVerOnly(t*(t itemgettertmedia(t URLGrabbert URLGrabErrortgetcCs_|j|j|j}}}|j|j|j}}}tjj|||f|||fS(s4 Compare two Package or PackageEVR objects. (tepochtversiontreleasetrpmUtilst miscutilst compareEVR(tpo1tpo2te1tv1tr1te2tv2tr2((s0/usr/lib/python2.7/site-packages/yum/packages.pyt comparePoEVR9scCsn|j|j|j}}}|j|j|j}}}||krJtS||krZtS||krjtStS(sA Compare two Package or PackageEVR objects for equality. (R R RtFalsetTrue(RRRRRRRR((s0/usr/lib/python2.7/site-packages/yum/packages.pytcomparePoEVREQ@s   cCsIi}x<|D]4}|j\}}}}}|sp|j}|j}|j}|j}|j}n|} d||f} d||||f} d||f} d|||f} d|||||f}d|||||f}xM| | | | | ||gD]0}||kr,g||s( RRRSRTRcRNRfRhRiRjtpropertytui_id(((s0/usr/lib/python2.7/site-packages/yum/packages.pyRUs      t PackageObjectcBsreZdZdZdZeddZdZeddZdZ eddZ d Z edd Z d Z edd Zd ZeddZdZeddZdZeddZdZeddZdZeddZdZeddZdZeddZdZeddZdZeddZ dZ!edd Z"d!Z#edd"Z$d#Z%d$Z&d%Z'd&Z(d'Z)d(Z*d)Z+d*Z,d+Z-d,Z.d-Z/d.Z0d/Z1d0Z2d1Z3d2Z4edd3Z5d4Z6RS(5sZBase Package Object - sets up the default storage dicts and the most common returnscCs:d|_d|_d|_d|_d|_g|_dS(N(R:R*R RR tarcht _checksums(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRNs      cCs!|jdkr|jS|jSdS(Nt0(R tnvraR/(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt _ui_envrasRkcCs |jS(N(Rt(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCs!|jdkr|jS|jSdS(NRr(R RsR0(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt _ui_nevrascCs |jS(N(Ru(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCs!|jdkr|jS|jSdS(NRr(R tvrtevr(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_ui_evrscCs |jS(N(Rx(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl scCs!|jdkr|jS|jSdS(NRr(R tvratevra(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_ui_evrascCs |jS(N(R{(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCs!|jdkr|jS|jSdS(NRr(R tnvrtnevr(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_ui_nevrscCs |jS(N(R~(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCsd|j|jfS(Ns%s.%s(R*Rp(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_nascCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCsd|j|jfS(Ns%s-%s(R R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_vr!scCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl#scCsd|j|j|jfS(Ns%s-%s.%s(R RRp(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_vra%scCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl'scCsd|j|j|jfS(Ns%s:%s-%s(R R R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_evr)scCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl+scCs d|j|j|j|jfS(Ns %s:%s-%s.%s(R R RRp(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_evra-scCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl/scCsd|j|j|jfS(Ns%s-%s-%s(R*R R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_nvr1scCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl3scCs d|j|j|j|jfS(Ns %s-%s-%s.%s(R*R RRp(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_nvra5scCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl7scCs d|j|j|j|jfS(Ns %s-%s:%s-%s(R*R R R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_nevr9scCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRl;scCs&d|j|j|j|j|jfS(Ns%s-%s:%s-%s.%s(R*R R RRp(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_nevra=s cCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlAscCs d|j|j|j|jfS(Ns %s:%s-%s-%s(R R*R R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_envrCscCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlEscCs&d|j|j|j|j|jfS(Ns%s:%s-%s-%s.%s(R R*R RRp(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_envraGs cCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlKscCs|jS(N(tui_envra(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRiMscCsH|jdkr.d|j|j|jf}nd|j|jf}|S(sAreturns a printable version string - including epoch, if it's setRrs%s:%s-%ss%s-%s(R R R(RMtver((s0/usr/lib/python2.7/site-packages/yum/packages.pytprintVerPscCsA|s dSt|j|j}|dkr=t||}n|S(s< Compare package to another one, only rpm-version ordering. ii(tcmpR*R(RMRetret((s0/usr/lib/python2.7/site-packages/yum/packages.pytverCMPYs  cCs|j|}|dkr3t|j|j}n|dkrt|drt|drt|j|j}|r|jdkrdS|r|jdkrdSn|S(s4 Compare packages, this is just for UI/consistency. iR_t installedii(RRRpthasattrR_(RMReR((s0/usr/lib/python2.7/site-packages/yum/packages.pyRfbs *cCs[|s tS|j|jkr tSt|drWt|drW|j|jkrWtSntS(se Compare packages for yes/no equality, includes everything in the UI package comparison. R_(RRRR_R(RMRe((s0/usr/lib/python2.7/site-packages/yum/packages.pyt__eq__oscCs||kstStS(N(RR(RMRe((s0/usr/lib/python2.7/site-packages/yum/packages.pyt__ne__zs cCs t||S(N(tgetattr(RMtkey((s0/usr/lib/python2.7/site-packages/yum/packages.pyt __getitem__scCs<|s dSt|j|j}|dkr/tSt||S(s< Compare package to another one, only rpm-version equality. iN(R:RR*RR(RMReR((s0/usr/lib/python2.7/site-packages/yum/packages.pytverEQs  cCs|s dS|j| S(s> Compare package to another one, only rpm-version inequality. N(R:R(RMRe((s0/usr/lib/python2.7/site-packages/yum/packages.pytverNEscCs|j|dkS(s; Uses verCMP, tests if the other _rpm-version_ is < ours. i(R(RMRe((s0/usr/lib/python2.7/site-packages/yum/packages.pytverLTscCs|j|dkS(s; Uses verCMP, tests if the other _rpm-version_ is <= ours. i(R(RMRe((s0/usr/lib/python2.7/site-packages/yum/packages.pytverLEscCs|j|dkS(s; Uses verCMP, tests if the other _rpm-version_ is > ours. i(R(RMRe((s0/usr/lib/python2.7/site-packages/yum/packages.pytverGTscCs|j|dkS(s; Uses verCMP, tests if the other _rpm-version_ is >= ours. i(R(RMRe((s0/usr/lib/python2.7/site-packages/yum/packages.pytverGEscCs)d|jjt|tt|fS(Ns<%s : %s (%s)>(t __class__RRtstrthexR4(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt__repr__scCs&tjdtjddt||S(Ns8returnSimple() will go away in a future version of Yum. t stackleveli(twarningstwarntErrorstYumFutureDeprecationWarningR(RMtvarname((s0/usr/lib/python2.7/site-packages/yum/packages.pyt returnSimples cCs|jS(N(Rq(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pytreturnChecksumsscCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCs1x*|jD]\}}}|r ||fSq WdS(N(t checksums(RMtcsumtypetcsumtcsumid((s0/usr/lib/python2.7/site-packages/yum/packages.pyt returnIdSums(7RRRSRTRNRtRmRRutui_nevraRxtui_evrR{tui_evraR~tui_nevrRtnaRRvRRyRRwRRzRR|RRsRR}RR0RtenvrRR/RiRRRfRRRRRRRRRRRRRR(((s0/usr/lib/python2.7/site-packages/yum/packages.pyRosh                            t-tYumNotFoundPackagecBs5eZdZdZeddZdZRS(cCsu|d|_|d|_|d|_|d|_|d|_||_d|_g|_t|_ tj |_ dS(Niiiii( R*RpR R RRtsizeRqt_not_found_repoR3R4R_(RMR((s0/usr/lib/python2.7/site-packages/yum/packages.pyRNs         cCs|jS(s This just returns '-' (R_(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt _ui_from_reposRkcCs |jS(N(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCstS(s^check the package checksum vs the localPkg return True if pkg is good, False if not(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pytverifyLocalPkgs(RRRSRNRRmt ui_from_repoR(((s0/usr/lib/python2.7/site-packages/yum/packages.pyRs  tRpmBasecBsEeZdZdZdZdZdZdZedZ dZ dZ d Z d Z d Zd ed ZedZdZdZddZeddZeddZeddZeddZeddZeddZeddZeddZeddZeddZeddZeddZ edd Z!edd!Z"edd"Z#edd#Z$edd$Z%edd%Z&edd&Z'edd'Z(d(Z)edd)Z*d*Z+d+d,Z,RS(-s2return functions and storage for rpm-specific datacCsi|_g|jdq(n|jtj|q(W|S|S(s9return list of provides, requires, conflicts or obsoletesi(RR R R=tprco_tuple_to_string(RMtprcotypet printabletprcostresultsR((s0/usr/lib/python2.7/site-packages/yum/packages.pyt returnPrcos  c Cs>||jkrdSt|j|dkrF||j|krdSn~t|ds}id d6d d6d d6d d6|_n|j|d krt|j||j| i( RR0RRtpackagerR=t to_unicodetencodetfind(RMtvaltix((s0/usr/lib/python2.7/site-packages/yum/packages.pyt _committerWs   cCsSt|dr|jSt|js8|j|_|jS|jdd|_|jS(s5Returns the time of the last commit to the changelog.t_committime_reti(RR;RRt buildtime(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt _committimens cCs|jddS(sReturns the 'default' checksumii(R(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt _checksum~scCsd|jdkrdStj|j\}}}}}|dkr`t|dkrVdSt|SdS(NRi(R)R:R*turlsplitRtint(RMtschemetnetlocRZtquerytfragid((s0/usr/lib/python2.7/site-packages/yum/packages.pyt getDiscNums!  cCs_|j}tjj}ytjj||}Wn$tjk rZtjd|nX|S(Ns"Package Header %s: RPM Cannot open( tlocalPkgRt transactiontinitReadOnlyTransactionRthdrFromPackageRRt RepoError(RMtrpmfilettsthdr((s0/usr/lib/python2.7/site-packages/yum/packages.pytreturnHeaderFromPackages cCstjj|jrky#tj|j}|d}Wq{tjtfk rgtj d|q{Xntj d||S(sTreturns an rpm header object from the package object's local header cacheisPackage Header %s: Cannot opens Package Header %s: Not Available( RYRZtexiststlocalHdrtrpmtreadHeaderListFromFileterrort IndexErrorRRJ(RMthlistRM((s0/usr/lib/python2.7/site-packages/yum/packages.pytreturnLocalHeaderscCsEt|ds>tjj|j}|jjd||_n|jS(sBreturn path to local package (whether it is present there, or not)t localpathRV(RRYRZR[R,R3tpkgdirRW(RMtrpmfn((s0/usr/lib/python2.7/site-packages/yum/packages.pyRFscCsSt|dsLtjj|j}|d d}|jjd||_n|jS(sWreturn path to local cached Header file downloaded from package byte rangesthdrpathis.hdrRV(RRYRZR[R,R3thdrdirRZ(RMtpkgnamethdrname((s0/usr/lib/python2.7/site-packages/yum/packages.pyRPs c Cs ytj|j}Wntk r/}tSXt|dr|jr|j}|j|jkr|j|jkr|j |j kr|j |j krt Sn|j \}}y%t j||jd|j}Wntjk rtSX||krtS||_t S(s^check the package checksum vs the localPkg return True if pkg is good, False if notRtdatasize(RYtstatRFtOSErrorRRRtst_inotst_devtst_mtimetst_sizeRRR=tchecksumR%Rt MiscError(RMtnstR'tostt csum_typeRtfilesum((s0/usr/lib/python2.7/site-packages/yum/packages.pyRs,    cCswtdkrdSt|dr,t|dS|js<dSytj|jd}WndSXt|d||S(s Get the user.xdg.origin.url value from the local pkg. ... if it's present. We cache this so we can access it after the file has been deleted (keepcache=False). t__cached_localXattrUrlsuser.xdg.origin.urlN(txattrR:RRRR RFR(RMR((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_localXattrUrls   cCs |jS(N(Rm(tx((s0/usr/lib/python2.7/site-packages/yum/packages.pyRlscCs&tjdtjddtj|S(s1convert the prco tuples into a nicer human strings9prcoPrintable() will go away in a future version of Yum. Ri(RRRRR=R(RMt prcoTuple((s0/usr/lib/python2.7/site-packages/yum/packages.pyt prcoPrintables cCs|jS(s.return a list of requires in normal rpm format(R (RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyt requiresListscCs|j|jdfgS(Ni(t checksum_typetpkgId(RM((s0/usr/lib/python2.7/site-packages/yum/packages.pyRscCst|drW|j\}}}}}||_||_||_||_||_nt|dr|jd|_|jd|_ nt|dr|j d|_ |j d|_ |j d|_ nt|d r|jjd }|d krd-}n||_|jd |_nt|d rO|jd|_|jd|_nt|drx=ddddddddgD]}t|||j|q}W|jjdd |_|jj|jdnt|dr6xT|jD]F} |j| } | |jkrg|j| tattrib(RYRZtdirnamet remote_urlR[R=tto_xmlR(RMR.Rytmsg((s0/usr/lib/python2.7/site-packages/yum/packages.pyt_return_remote_locationSs +cCsd}}|jr(tj|j}n|jrFtj|j}n|jd\}}}d|j|j|j|j|j ||tj|j tj|j |||j |j |j|j|jf}||j7}|S(NRXis3 %s %s %s %s %s %s %s