[c@sdZddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk l Z l Z ddk lZddkZ ddklZlZddkZddkZddkZddkTddkZddkZeiidddklZlZy+ddkZeed  o eZnWne j o eZnXddk!Z!ddk"Z"d Z#d Z$e%d Z&d ddZ'dfdYZ(dfdYZ)de*fdYZ+de*fdYZ,dfdYZ-de+e,fdYZ.dZ/de.fdYZ0dfd YZ1d!fd"YZ2d#d >Z3d#d#>Z4d#d$>Z5d#d%>Z6d#d&>Z7d#d'>Z8d#d(>Z9d#d)>Z:d#d*>Z;d#d+>Z<d,e*fd-YZ=d.e=fd/YZ>d0fd1YZ?d2e?fd3YZ@e)d4ZAd eA_Bd5e0fd6YZCd7e0fd8YZDd9eDfd:YZEdS(;sA Classes and functions dealing with rpm package representations. iN(tPopentPIPE(t RpmUtilsError(t flagToStringtstringToVersion(t*tmedia(t URLGrabbert URLGrabErrortgetcCs_|i|i|i}}}|i|i|i}}}tii|||f|||fS(s4 Compare two Package or PackageEVR objects. (tepochtversiontreleasetrpmUtilst miscutilst compareEVR(tpo1tpo2te1tv1tr1te2tv2tr2((s0/usr/lib/python2.6/site-packages/yum/packages.pyt comparePoEVR8scCst|i|i|i}}}|i|i|i}}}||jotS||jotS||jotStS(sA Compare two Package or PackageEVR objects for equality. (R R R tFalsetTrue(RRRRRRRR((s0/usr/lib/python2.6/site-packages/yum/packages.pytcomparePoEVREQ?s   cCsMh}x@|D]8}|i\}}}}}|p@|i}|i}|i}|i}|i}n|} d||f} d||||f} d||f} d|||f} d|||||f}d|||||f}xO| | | | | ||gD]2}||jog||scCsb|idjo&d|i|i|i|if}n)d|i|i|i|i|if}|S(NRps %s-%s-%s.%ss%s-%s:%s-%s.%s(R R(R R Rn(RORq((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _ui_nevras   cCs |iS((Ru(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtscCs|iS(N(tui_envra(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRkscCsE|pdSt|i|i}|djot||}n|S(s< Compare package to another one, only rpm-version ordering. ii(tcmpR(R(RORgtret((s0/usr/lib/python2.6/site-packages/yum/packages.pytverCMPs  cCs|i|}|djot|i|i}n|djo9t|do)t|dot|i|i}n|S(s4 Compare packages, this is just for UI/consistency. iRa(RyRwRnthasattrRa(RORgRx((s0/usr/lib/python2.6/site-packages/yum/packages.pyRhs  -cCsd|ptS|i|ijotSt|do,t|do|i|ijotSntS(se Compare packages for yes/no equality, includes everything in the UI package comparison. Ra(RRRzRaR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyt__eq__&s  cCs||jptStS(N(RR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyt__ne__1s cCs t||S(N(tgetattr(ROtkey((s0/usr/lib/python2.6/site-packages/yum/packages.pyt __getitem__6scCs@|pdSt|i|i}|djotSt||S(s< Compare package to another one, only rpm-version equality. iN(RmRwR(RR(RORgRx((s0/usr/lib/python2.6/site-packages/yum/packages.pytverEQ9s  cCs|pdS|i| S(s> Compare package to another one, only rpm-version inequality. N(RmR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pytverNEAscCs|i|djS(s; Uses verCMP, tests if the other _rpm-version_ is < ours. i(Ry(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pytverLTFscCs|i|djS(s; Uses verCMP, tests if the other _rpm-version_ is <= ours. i(Ry(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pytverLEIscCs|i|djS(s; Uses verCMP, tests if the other _rpm-version_ is > ours. i(Ry(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pytverGTLscCs|i|djS(s; Uses verCMP, tests if the other _rpm-version_ is >= ours. i(Ry(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pytverGEOscCs)d|iit|tt|fS(Ns<%s : %s (%s)>(t __class__RTtstrthexR2(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyt__repr__SscCs&tidtiddt||S(Ns8returnSimple() will go away in a future version of Yum. t stackleveli(twarningstwarntErrorstYumFutureDeprecationWarningR}(ROtvarname((s0/usr/lib/python2.6/site-packages/yum/packages.pyt returnSimpleVs cCs|iS(N(Ro(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pytreturnChecksums[scCs |iS((R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRt^scCs3x,|iD]!\}}}|o ||fSq WdS(N(t checksums(ROtcsumtypetcsumtcsumid((s0/usr/lib/python2.6/site-packages/yum/packages.pyt returnIdSum`s (RTRURVRPRrtpropertyRvRutui_nevraRkRyRhR{R|RRRRRRRRRRRR(((s0/usr/lib/python2.6/site-packages/yum/packages.pyRls.               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 datacCsh|_g|idscCs |idS(R(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRt?scCs |idS(R(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRt@scCs |idS(R(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtAscCs |idS(R(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtBscCs |idS(R(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtCscCs |idS(R(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtDscCs|idtS(R(RR(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtEscCs|idtS(R(RR(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtFscCs|idtS(R(RR(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtGscCs|idtS(R(RR(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtHscCs|idtS(R(RR(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtIscCs |iS((R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtJscCs |iS((R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtKscCst|do|iSt|doP|ioFtii|i\}}}}}||ijo||_|Sn|i|_|iS(s\ Return the "base name" of the package, atm. we can only look at the sourcerpm. t_base_package_name_rett sourcerpm(RzRRR Rt splitFilenameR((ROR#R&R'R%R$((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _getBaseNameMs$   cCs |iS((R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRt]scCs|iiiS(sb Is calling pkg.returnFileEntries(primary_only=True) faster than using searchFiles(). (R1RfRQ(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRQ_sicCs|id|i|i|iff}g}xQ|D]I}|id|o0|i||ot||joPqzq1q1W|S(s Returns list of obsoleters that obsolete this package. Note that we don't do obsoleting loops. If limit is != 0, then we stop after finding that many. RR(R(R R R RRR(ROt obsoleterstlimittprovtupRxtobspo((s0/usr/lib/python2.6/site-packages/yum/packages.pyt obsoletedByds$  (-RTRURVRPR{R|RRjRRRRRRRRRRRRRtfilelisttdirlistt ghostlistRRRRRRtrequires_nameststrong_requires_namestconflicts_namestobsoletes_namestprovides_printtrequires_printtstrong_requires_printtconflicts_printtobsoletes_printt changelogtEVRRtbase_package_nameRQR(((s0/usr/lib/python2.6/site-packages/yum/packages.pyRisR       "          RcBsVeZdZdZdZdZdZdZdZdZ dZ RS( s A comparable epoch, version, and release representation. Note that you almost certainly want to use pkg.verEQ() or pkg.verGT() etc. instead. cCs1||_||_||_||_||_dS(N(R RR RR (ROR%R&R'((s0/usr/lib/python2.6/site-packages/yum/packages.pyRP{s     cCs7tii|i|i|if|i|i|ifS(N(R RRR RR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pytcomparescCs|i|djotStS(Ni(RRR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyt__lt__scCs|i|djotStS(Ni(RRR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyt__gt__scCs|i|djotStS(Ni(RRR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyt__le__scCs|i|djotStS(Ni(RRR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyt__ge__scCs t||S(N(R(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyR{scCs||jptStS(N(RR(RORg((s0/usr/lib/python2.6/site-packages/yum/packages.pyR|s ( RTRURVRPRRRRRR{R|(((s0/usr/lib/python2.6/site-packages/yum/packages.pyRts       tYumAvailablePackagecBseZdZd(dZdZeddZdZdZ dZ dZ d Z d Z edd Zee Zed Zd ZeeZdZeeZdZeeZdZdZdZdZdZdZdZedZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&e'd Z(d!Z)d"Z*d#Z+d$Z,d%Z-d&d'Z.RS()s}derived class for the packageobject and RpmBase packageobject yum uses this for dealing with packages in a repositorycCsti|ti||i|_||_d|_t|_ d|_ |djo)|i ||i |_ |i|_n|i|i|i|i |if|_dS(N(RlRPRR2RaR1RmtstateRt _loadedfilest_verify_local_pkg_cachetimportFromDictR RR RR(RnR R(ROR1R!((s0/usr/lib/python2.6/site-packages/yum/packages.pyRPs          cCs|idjoyd|ijoid}|iidj o=d|ijo-|ii|iijod|ii}nd|ii|S|iS(s This reports the repo the package is from, we integrate YUMDB info. for RPM packages so a package from "fedora" that is installed has a ui_from_repo of "@fedora". Note that, esp. with the --releasever option, "fedora" or "rawhide" isn't authoritive. So we also check against the current releasever and if it is different we also print the YUMDB releasever. This means that installing from F12 fedora, while running F12, would report as "@fedora/13". t installedt from_repoRZt releaseverRXt@N(Rat yumdb_infotrpmdbRRmR(ROtend((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _ui_from_repos RscCs |iS((R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtscCs|iii|dS(sremove self from package sackN(R1RfRS(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pytexcludescCsJ|idjo d|i|i|if}nd|i|if}|S(sAreturns a printable version string - including epoch, if it's setRps%s:%s-%ss%s-%s(R R R (ROR((s0/usr/lib/python2.6/site-packages/yum/packages.pytprintVers cCs#|i}d|i|i|fS(Ns%s.%s %s(RR(Rn(ROR((s0/usr/lib/python2.6/site-packages/yum/packages.pyt compactPrints cCs|iS(N(t packagesize(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyt_sizescCs|iS(N(t relativepath(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _remote_pathscCs`|i}|o3|ddjo|d}nti||iSti|iid|iS(sreturns a URL that can be used for downloading the package. Note that if you're going to download the package in your tool, you should use self.repo.getPackage.iRXi(tbasepathturlparseturljoint remote_pathR1turls(ROtbase((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _remote_urls  cCs |iS((R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtscCs |iS((R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtscCst|do|iSd}t|ip|i|_|iS|idd}||}|id}|djo|d|d!}n||_|iS(sDReturns the name of the last person to do a commit to the changelog.t_committer_retcSsNg}x8|D]0}t|djo d}n|i|q Wdi|S(s6 does .encode("ascii", "replace") but it never fails. iRYRZ(R_RR`(txRxtval((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _nf2asciis iis> i(RzRRRtpackagertfind(RORRtix((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _committers     cCsWt|do|iSt|ip|i|_|iS|idd|_|iS(s5Returns the time of the last commit to the changelog.t_committime_reti(RzRRRt buildtime(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _committimes cCs|iddS(sReturns the 'default' checksumii(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyt _checksum"scCsj|idjodSti|i\}}}}}|djo#t|djodSt|SdS(NRi(R RmR turlsplitRtint(ROtschemetnetlocR\tquerytfragid((s0/usr/lib/python2.6/site-packages/yum/packages.pyt getDiscNum's!  cCsa|i}tii}ytii||}Wn&tij otid|nX|S(Ns"Package Header %s: RPM Cannot open( tlocalPkgR t transactiontinitReadOnlyTransactionRthdrFromPackageRRt RepoError(ROtrpmfilettsthdr((s0/usr/lib/python2.6/site-packages/yum/packages.pytreturnHeaderFromPackage1s cCstii|ioVy#ti|i}|d}Wqtitfj oti d|qXnti d||S(sTreturns an rpm header object from the package object's local header cacheisPackage Header %s: Cannot opens Package Header %s: Not Available( R[R\texiststlocalHdrtrpmtreadHeaderListFromFileterrort IndexErrorRR)(ROthlistR,((s0/usr/lib/python2.6/site-packages/yum/packages.pytreturnLocalHeader:scCsGt|dp0tii|i}|iid||_n|iS(sBreturn path to local package (whether it is present there, or not)t localpathRX(RzR[R\R]RR1tpkgdirR6(ROtrpmfn((s0/usr/lib/python2.6/site-packages/yum/packages.pyR%JscCsUt|dp>tii|i}|d d}|iid||_n|iS(sWreturn path to local cached Header file downloaded from package byte rangesthdrpathis.hdrRX(RzR[R\R]RR1thdrdirR9(ROtpkgnamethdrname((s0/usr/lib/python2.6/site-packages/yum/packages.pyR/Qs c Csyti|i}Wntj o }tSXt|doh|io^|i}|i|ijo>|i|ijo+|i |i jo|i |i jot Sn|i \}}y%t i||id|i}Wntij otSX||jotS||_t S(s^check the package checksum vs the localPkg return True if pkg is good, False if notRtdatasize(R[tstatR%tOSErrorRRzRtst_inotst_devtst_mtimetst_sizeRRR:tchecksumRRt MiscError(ROtnstR%tostt csum_typeRtfilesum((s0/usr/lib/python2.6/site-packages/yum/packages.pytverifyLocalPkg\s,     cCs}tdjodSt|dot|dS|ipdSyti|id}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(txattrRmRzR}RJR R%R(RORx((s0/usr/lib/python2.6/site-packages/yum/packages.pyt_localXattrUrls  cCs |iS((RM(R((s0/usr/lib/python2.6/site-packages/yum/packages.pyRtscCs&tidtiddti|S(s1convert the prco tuples into a nicer human strings9prcoPrintable() will go away in a future version of Yum. Ri(RRRRR:R(ROt prcoTuple((s0/usr/lib/python2.6/site-packages/yum/packages.pyt prcoPrintables cCs|iS(s.return a list of requires in normal rpm format(R(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyt requiresListscCs|i|idfgS(Ni(t checksum_typetpkgId(RO((s0/usr/lib/python2.6/site-packages/yum/packages.pyRsc Cst|doI|i\}}}}}||_||_||_||_||_nt|do$|id|_|id|_ nt|do4|i d|_ |i d|_ |i d|_ nt|d oF|iid }|d jo d-}n||_|id |_nt|d o$|id|_|id|_nt|dosx=ddddddddgD]}t|||i|qW|iidd |_|ii|idnt|doZxW|iD]H} |i| } | |ijog|i| tattrib(R[R\tdirnamet remote_urlR]R:tto_xmlR(RORRYtmsg((s0/usr/lib/python2.6/site-packages/yum/packages.pyt_return_remote_locations +cCsd}}|iotiti|i}n|iotiti|i}n|id\}}}d|i|i|i|i |i ||titi|i titi|i |||i |i|i|i|if}||i7}|S(NRZis3 %s %s %s %s %s %s %s