[c @sdZddklZddkZddkZddkZddkZddklZddk Z ddk l Z dfdYZ de fd YZd efd YZd efd YZdZdZdefdYZdS(s; Classes for manipulating and querying groups of packages. i(tPackageSackErrorN(t parsePackages(t compareEVRtPackageSackVersioncBs5eZdZdZdZdZdZRS(cCs"d|_tidg|_dS(Nitsha1(t_numtmisct Checksumst_chksum(tself((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt__init__s cCsd|i|iifS(Ns%u:%s(RRt hexdigest(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt__str__#scCs|djotSt|tdtdfjot||jS|i|ijotS|ii|iijotStS(Ntu(tNonetFalsettypetstrRRtdigesttTrue(R tother((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt__eq__&s %cCs ||j S(N((R R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt__ne__-scCsb|id7_|iit||dj o,|ii|d|ii|dndS(Nii(RRtupdateRR(R tpkgtcsum((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR0s  (t__name__t __module__R R RRR(((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRs     tPackageSackBasecBseZdZdZdZdZdZdZdZdZ d%d%d%d%d%dZ ge d Z d Zd Zd%d%d%d%d%d%d Zd%d&d Zd%d'dZdZdZdZdZe dZdZdZdZdZdZd%d%e dZdZe hdZd%d%e dZ d%d%e dZ!d%e dZ"dZ#d Z$d!Z%d"Z&d#Z'd%d$Z(RS((s8Base class that provides the interface for PackageSacks.cCs h|_dS(N(tadded(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR :scCst|iS(N(tlentreturnPackages(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt__len__=scCs5|i}t|do |iSt|SdS(Nt__iter__(RthasattrR!titer(R tret((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR!@s  cCs|djodSt|i}t|i}t|t|jot|t|SxDtt|t|D]'\}}t||}|o|SqzWdS(Nii(RtlistRRtziptsortedtcmp(R Rts_reposto_reposts_repoto_repoR$((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt__cmp__Gs   cCs tdS(N(tNotImplementedError(R t compatArchs((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytsetCompatArchsUscCs tdS(N(R.(R trepotmdtypetcallbackt cacheOnly((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytpopulateXscCs#tidtdd|i|S(s5return a list of package objects by (n,a,e,v,r) tuples;packagesByTuple() will go away in a future version of Yum. t stackleveli(twarningstwarntDeprecationWarningtsearchPkgTuple(R tpkgtup((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytpackagesByTuple[s  cCs tdS(s6return list of pkgobjects matching the nevra requestedN(R.(R tnametepochtvertreltarch((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt searchNevracscCs tdS(N(R.(R tnamestreturn_pkgtups((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt searchNamesgsc Cs7|id|id|id|id|id|iS(srreturn list of package objects matching the name, epoch, ver, rel, arch of the package object passed inR=R>R?R@RA(RBR=R>R?R@RA(R tpo((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytsearchPOjs$c Cs=|\}}}}}|id|d|d|d|d|S(s7return list of pkgobject matching the (n,a,e,v,r) tupleR=RAR>R?R@(RB(R R;tntatetvtr((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR:qsc Csf|o1|i}|i}|i}|i}|i}nt|id|d|d|d|d|S(spreturn if there are any packages in the sack that match the given NAEVR or the NAEVR of the given poR=RAR>R?R@(R=RAR>tversiontreleasetboolRB(R R=RAR>R?R@RF((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytcontainsvs     cCs tdS(s5return dict { packages -> list of matching provides }N(R.(R R=tflagsRM((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt getProvidesscCs tdS(s5return dict { packages -> list of matching requires }N(R.(R R=RQRM((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt getRequiresscCs tdS(s<return list of package requiring the name (any evr and flag)N(R.(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytsearchRequiresscCs tdS(s<return list of package providing the name (any evr and flag)N(R.(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytsearchProvidesscCs tdS(sCreturn list of package conflicting with the name (any evr and flag)N(R.(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytsearchConflictsscCs tdS(s=return list of package obsoleting the name (any evr and flag)N(R.(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytsearchObsoletesscCs tdS(sEreturns a dict of obsoletes dict[obsoleting pkgtuple] = [list of obs]N(R.(R tnewest((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytreturnObsoletesscCs tdS(sb Is calling pkg.returnFileEntries(primary_only=True) faster than using searchFiles(). N(R.(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pythave_fastReturnFileEntriesscCs tdS(s#return list of packages by filenameN(R.(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt searchFilesscCs tdS(s"add a pkgobject to the packageSackN(R.(R tobj((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt addPackagescCs tdS(sbuilds the useful indexes for searching/querying the packageSack This should be called after all the necessary packages have been added/deletedN(R.(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt buildIndexesscCs tdS(sdelete a pkgobjectN(R.(R R\((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt delPackagescCs tdS(sreturn list of all packagesN(R.(R trepoidtpatternst ignore_case((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRscGs tdS(s Add an "excluder" for all packages in the repo/sack. Can basically do anything based on nevra, changes lots of exclude decisions from "preload package; test; delPackage" into "load excluder". Excluderid is used so the caller doesn't have to track "have I loaded the excluder for this repo.", it's probably only useful when repoid is None ... if it turns out utterly worthless then it's still not a huge wart. N(R.(R R`t excluderidtexcludertargs((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytaddPackageExcludersc Cs`d}t}h}h}h}xt|iD]}|i} |i|| xb|D]Z} |i|| jo@| |jot|| t||djp|i||jo|d7}Pq$qqW|djo|i|qqW|S(sjreturns a list of package objects that are not required by any other package in this repositoryc sshx|iD] }|Vq Wx|iD] }|Vq#Wx|iD] }|Vq<Wx|iD] }|VqUWdS(s& Return all the provides, via. yield. N(tprovides_namestfilelisttdirlistt ghostlist(RFtprov((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt_return_all_providesBs       R`ii(Rtrequires_namesRRtaddR=R( R R`RtreqtorphansRFRLtpreqR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytreturnLeafNodes>s4      +   N(NNN(NNN()RRt__doc__R R R!R-R0R5R<RRBRRERGR:RPRRRSRTRURVRWRYRZR[R]R^R_RRfRvRxRyRzR{R}RRRR(((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR8sL                     &      5tMetaSackcBsseZdZdZdZdZdZdZdZdZ d!d!d!d!d!dZ ge d Z d!d"d Zd!d#d Zd Zd ZdZdZe dZdZdZdZdZd!d!e dZdZd!d!e dZd!d!e dZd!e dZdZdZdZ dZ!dZ"dZ#d Z$RS($sqRepresents the aggregate of multiple package sacks, such that they can all be treated as one unified sack.cCs#ti|h|_d|_dS(N(RR tsacksRt compatarchs(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR rs  cCs:d}x-t|iiD]}|t|7}qW|S(Ni(R'RtvaluesR(R R$tsack((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR ws cCs<x5|iiD]$}t|do|iqqWdS(NtdropCachedData(RRR"R(R R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR}scCs!||i|<|i|idS(s1Adds a repository's packageSack to this MetaSack.N(RR0R(R R`R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pytaddSacks cCs$|i|ii||||dS(N(RtidR5(R R1R2R3R4((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR5scCs+x$|iiD]}|i|qWdS(N(RRR0(R R/R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR0scCs&tidtdd|id|S(s5return a list of package objects by (n,a,e,v,r) tuples;packagesByTuple() will go away in a future version of Yum. R6iR<(R7R8R9t_computeAggregateListResult(R R;((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR<s  cCs|id|||||S(s6return list of pkgobjects matching the nevra requestedRB(R(R R=R>R?R@RA((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRBscCs|id||S(NRE(R(R RCRD((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyREscCs|id|||S(s5return dict { packages -> list of matching provides }RR(t_computeAggregateDictResult(R R=RQRM((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRRscCs|id|||S(s5return dict { packages -> list of matching requires }RS(R(R R=RQRM((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRSscCs|id|S(s<return list of package requiring the name (any evr and flag)RT(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRTscCs|id|S(s<return list of package providing the name (any evr and flag)RU(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRUscCs|id|S(sCreturn list of package conflicting with the name (any evr and flag)RV(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRVscCs|id|S(s=return list of package obsoleting the name (any evr and flag)RW(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRWsc s|p|idS|id}td|D}h}d}d }dfd}xt|i|dtdD]`}|d} || jo|| | oqn| }|} ||jo||||s R cSs[t|d|d}|o|St|d|d|df|d|d|df S(s4 Compare two pkgtup's (ignore arch): n, a, e, v, r. iiii(R(R(txtyR$((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt_pkgtup_nevr_cmpscs||djS(Ni((RR(R(s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt_pkgtup_nevr_eqsRDR(iN(RRRR'RER( R RXtobsdictRCtnobsdictt last_nametlast_pkgRR;R=t last_pkgtup((Rs3/usr/lib/python2.6/site-packages/yum/packageSack.pyRYs(   cCs|id|S(s#return list of packages by filenameR[(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR[scCsdS(saAdd a pkgobject to the packageSack. This is a meaningless operation for the MetaSack.N((R R\((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR]scCs(x!|iiD]}|iqWdS(sbuilds the useful indexes for searching/querying the packageSack This should be called after all the necessary packages have been added/deletedN(RRR^(R R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR^scCs|iii|dS(s2Delete a pkgobject if it exists in every sub-sack.N(R1RR_(R R\((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR_scCs;|p|idd||S|i|id|d|S(sReturns a list of packages. Note that the packages are always filtered to those matching the patterns/case. An optional repoid allows you to easily get data for a specific repo. RRaRbN(RRRR(R R`RaRb((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRs  cGsD|p |i}|dd|||S|i|id|||S(s Add an "excluder" for all packages in the repo/sack. Can basically do anything based on nevra, changes lots of exclude decisions from "preload package; test; delPackage" into "load excluder". Excluderid is used so the caller doesn't have to track "have I loaded the excluder for this repo.", it's probably only useful when repoid is None ... if it turns out utterly worthless then it's still not a huge wart. RfN(RRRRf(R R`RcRdRetcalr((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRfs  cCsk|i}|d|||}t|}| o5|p|o'di|pg}td|n|S(sreturn list of newest packages based on name, arch matching this means(in name.arch form): foo.i386 and foo.noarch are not compared to each other for highest version only foo.i386 and foo.i386 will be compared. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. Rxs, sNo Package Matching %s(RtpackagesNewestByNameArchtjoinR(R RwRaRbRRtui_pats((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRxs  cCsv|id|||}t|}| oF|p|o8|o |}ndi|pg}td|n|S(sreturn list of newest packages based on name matching this means(in name.arch form): foo.i386 and foo.noarch will be compared to each other for highest version.Rys, sNo Package Matching %s(RtpackagesNewestByNameRR(R R=RaRbRR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRys    cCs|id||S(s,returns a list of pkg tuples (n, a, e, v, r)Rz(R(R RaRb((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRz"s cCs(x!|iiD]}|iqWdS(N(RRR{(R R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR{'scCs+x$|iiD]}|i|qWdS(sDexclude incompatible arches. archlist is a list of compatible archesN(RRR}(R R|R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR}+scCs|id|||S(NR(R(R R~RR3((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR0scCs|id||S(NR(R(R RR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR3sc Cs#g}g}d}x|iiD]}t|doggg}}}y|i|\}}}Wntj o q"nX|i||i||djot|}q|it|}q"q"Wt i |}t i |}|djo g}n t |}|||fS(NR( RRRR"RRtextendRt intersectionRRR%( R RRRRRRJtmtu((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR6s,      cGsg}xt|iiD]m}t||oWt||}yt||}Wntj o qnX|o|i|qqqW|S(N(R'RRR"tgetattrtapplyRR(R t methodNameRetresultRtmethodt sackResult((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRQscGsh}xt|iiD]m}t||oWt||}yt||}Wntj o qnX|o|i|qqqW|S(N(R'RRR"RRRR(R RReRRRR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR`sN(NNN(NNN(%RRRR R RRR5R0R<RRBRRERRRSRTRURVRWRYR[R]R^R_RRfRxRyRzR{R}RRRRR(((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRnsD            !           t PackageSackcBsveZdZdZdZddZdZdZd"d"d"d"d"dZ ge dZ d"d#d Z d"d$d Z d Zd Zd ZdZdZe dZdZdZdZdZdZdZdZdZdZdZd"d"e dZd"d"e dZd"d"e dZ d"e dZ!dZ"d Z#d!Z$RS(%s*represents sets (sacks) of Package ObjectscCs^h|_h|_h|_h|_h|_h|_h|_h|_d|_ d|_ dS(Ni( tnevrat obsoletestrequirestprovidest conflictst filenamest pkgsByRepotpkgsByIDRRt indexesBuilt(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR rs         cCs5d}x(|iD]}|t|i|7}qW|S(Ni(RR(R R$R1((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR s  terrorcCsG|ip9|djo tdqC|djo|iqCndS(scheck to see if the indexes are built, if not do what failure demands either error out or build the indexes, default is to error outRs$Indexes not yet built, cannot searchtbuildN(RRR^(R tfailure((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt _checkIndexess     cCs|idS(s* Do nothing, mainly for the testing code. N(t clearIndexes(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRscCs ||_dS(N(R(R R((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR0sc CsN|idd|||||f|ijo|i|||||fS|dj o(|ii|ddddfg}n.g}x$|iiD]}|i|qWg}x|D]} |o|| ijp\|o|| ijpE|o|| i jp.|o|| i jp|o|| i joqn|i | qW|S(s6return list of pkgobjects matching the nevra requestedRRN( RRRtgetRt itervaluesRR=R>R?R@RAR( R R=R>R?R@RARt pkgsbyRepoRRF((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRBs( (cCs|iddg}t}xZ|D]R}||joq&n|i||i|ii|ddddfgq&W|o#g}|D]}||iq~S|S(s6return list of pkgobjects matching the names requestedRRN(RRRRRRRR;(R RCRDRtdoneR=RR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyREs   /#cCs|idd|djo d}n9t|ttdtfjotii|}nh}xM|ii |gD]6}|i d|||f}|o||| list of matching provides }RRRit/N(NNN(NNN(RRRRtunicodetrpmUtilst miscutilststringToVersionRRt matchingPrcosR[RgR(R R=RQRMRRFthitsthit((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRRs"  "!cCs|idd|djo d}n9t|ttdtfjotii|}nh}xM|ii |gD]6}|i d|||f}|o||| list of matching requires }RRRN(NNN( RRRRRRRRRRR(R R=RQRMRRFR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRSs  "c Cs|iddt||}ti|\}}\}}}g} g} ||jo| i||nxD| D]<} | i||||||ffo| i| ququW|djo| Sti|p| S| i|i|ti | S(NRRR( RRRtstring_to_prco_tupleRt checkPrcoRt re_filenameR[R( R R=tprcotypetprcodictRHtfRJRKRLt basic_resultstresultsRF((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt searchPrcos"! % cCs|i|dS(s3return list of package requiring the item requestedR(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRTscCs|i|dS(s3return list of package providing the item requestedR(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRUscCs|i|dS(s6return list of package conflicting with item requestedR(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRVscCs|i|dS(s4return list of package obsoleting the item requestedR(R(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRWscCsh}xP|iD]B}t|idjoqn|i|igi|iqW|p|Std|iD}g}x,|D]$}||jo|i|qqWx|D] }||=qW|S(sEreturns a dict of obsoletes dict[obsoleting pkgtuple] = [list of obs]icssx|]}|iVqWdS(N(R;(RR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pys s ( RRRRgR;RRRyR(R RXtobsRFt newest_tupsttogoR((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRY s$ #  cCstS(sb Is calling pkg.returnFileEntries(primary_only=True) faster than using searchFiles(). (R(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRZ%scCs4|idd||ijo |i|SgSdS(s& Return list of packages by filename. RRN(RR(R R=((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR[*s cCs0||jog||R?R@((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR]Es   cCsP|ix6|iD]+}x"|i|D]}|i|q(WqWd|_dS(sbuilds the useful indexes for searching/querying the packageSack This should be called after all the necessary packages have been added/deletediN(RRRR(R R`R\((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR^Ps  cCsLh|_h|_h|_h|_h|_h|_h|_d|_dS(Ni(RRRRRRRR(R ((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR]s       cCsx?|idD].\}}\}}}|i|i||qWx?|idD].\}}\}}}|i|i||qRWx?|idD].\}}\}}}|i|i||qWx?|idD].\}}\}}}|i|i||qWxD|iD]6}x-|i|D]}|i|i||q+WqW|i|i |i ||i \} } } } } |i|i | | | | | f||i|i | ddddf|dS(NRRRR(t returnPrcoRRRRRtreturnFileTypestreturnFileEntriesRRRR;RR(R R\RHtflRJRKRLtftypetfileR=RAR>R?R@((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRis* %cCsx?|idD].\}}\}}}|i|i||qWx?|idD].\}}\}}}|i|i||qRWx?|idD].\}}\}}}|i|i||qWx?|idD].\}}\}}}|i|i||qWxD|iD]6}x-|i|D]}|i|i||q+WqW|i|i |i ||i \} } } } } |i|i | | | | | f||i|i | ddddf|dS(NRRRR(RRRRRRRRRRRR;RR(R R\RHRRJRKRLRRR=RAR>R?R@((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyt_delPackageFromIndex|s* %cCs8|i|i|i||io|i|ndS(sdelete a pkgobjectN(RRR`RR(R R\((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyR_s c Csg}|djo,xP|iD]}|i|i|qWn(y|i|}Wntj onX|o/t||| dd}|d|d}n|S(s2return list of all packages, takes optional repoidRs repo-pkgkeyiiN(RRRtKeyErrorR(R R`RaRbt returnListR1((s3/usr/lib/python2.6/site-packages/yum/packageSack.pyRs   cCs5h}|oQ|idd|ii|dddddf}|ptd|qvn|id|d|}x|D]y}|i|if|jo|||i|ifs$     7