v_c@sddlZddlZddlZddlZddlZddlmZddlmZm Z m Z ddl j Z ddl Zddl TddlmZmZmZddlmZmZddlmZdZid e6d e6d e6d e6d e6de6de6Z i ed 6ed 6ed 6ed 6ed 6ed6ed6ed6ed6ed6ed6Z!e"e#dZ$dfdYZ%defdYZ&de&fdYZ'dfdYZ(dfdYZ)de)fd YZ*d!fd"YZ+d#Z,dS($iN(tproxy(tsqlitet executeSQLt sql_esc_glob(t*(tYumInstalledPackagetYumAvailablePackaget PackageObject(t to_unicodetto_utf8(t getBaseArchs/var/lib/yum/historytUpdatetUpdatedtErasetInstalls True-Installt Obsoletedt Obsoletings Dep-Installt Reinstallt Downgradet DowngradedcCsF|d krg}ndddddddg}t}x*|D]"}tjj|r=t}Pq=q=Wt}|sdg}t}nt||krg}n|rt |}ng}t}xL|D]D}tj |r|j |dft}q|j |d fqW| r0| r0|r0|||tfS|}|||tfS( svSetup need_full and patterns for _yieldSQLDataList, also see if we can get away with just using searchNames(). tnamet sql_nameArchtsql_nameVerRelArcht sql_nameVertsql_nameVerRelt sql_envrat sql_nevratglobt=N( tNonetFalsetyumtmisctre_full_search_neededtTruet PATTERNS_MAXtPATTERNS_INDEXED_MAXtlenRtre_globtappend(tpatternst ignore_casetfieldst need_fulltpattpat_maxttmpt need_glob((s//usr/lib/python2.7/site-packages/yum/history.pyt_setupHistorySearchSQL>s:          t_YumHistPackageYumDBc BsYeZdZdZedddddddd gZd Zd Zd d Z RS(s9 Class to pretend to be yumdb_info for history packages. cCs ||_dS(N(t_pkg(tselftpkg((s//usr/lib/python2.7/site-packages/yum/history.pyt__init__hst command_linet from_repotfrom_repo_revisiontfrom_repo_timestampt installed_byt changed_bytreasont releasevercCs|j}|jdr.td||fn||jkrStd||fn|jj||}tr|dkrtd||fn|dkrdSt|pd}t ||||S(s0 Load yumdb attributes from the history sqlite. t_s%s has no yum attribute %stN( R2t startswithtAttributeErrort_valid_yumdb_keyst_historyt_load_yumdb_keyRRtstrtsetattr(R3tattrR4tval((s//usr/lib/python2.7/site-packages/yum/history.pyt __getattr__ps  cCs|j|}|dk S(N(tgetR(R3RGtx((s//usr/lib/python2.7/site-packages/yum/history.pyt __contains__scCs,yt||}Wntk r'|SX|S(sretrieve an add'l data obj(tgetattrRA(R3RGtdefaulttres((s//usr/lib/python2.7/site-packages/yum/history.pyRJs  N( t__name__t __module__t__doc__R5tsetRBRIRLRRJ(((s//usr/lib/python2.7/site-packages/yum/history.pyR1es   tYumHistoryPackagec BseeZdddZeddddddddd d g Zd Zd Zed dZ RS(c Cs||_||_||_||_||_|j|j|j|j|jf|_|dkrlg|_n,|jd}|d|ddfg|_d|_ ||_ t ||_ dS(Nt:iis ( RtversiontreleasetepochtarchtpkgtupRt _checksumstsplittrepoidRCR1t yumdb_info( R3RRYRXRVRWtchecksumthistorytchk((s//usr/lib/python2.7/site-packages/yum/history.pyR5s          t buildtimet buildhosttlicensetpackagertsizet sourcerpmturltvendort committert committimecCs|jdr%td||fn||jkrJtd||fn|jj||}tr|dkrtd||fn|dkrdSt|pd}t||||S(s0 Load rpmdb attributes from the history sqlite. R>s%s has no attribute %sR?N( R@RAt_valid_rpmdb_keysRCt_load_rpmdb_keyRRRERF(R3RGRH((s//usr/lib/python2.7/site-packages/yum/history.pyRIs cCsd|jkr}|jjd}|jjdk rkd|jkrk|jj|jjkrkd|jj}nd|jj|S|jS(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 authoritative. 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". R7R?R=t/t@N(R^RCR=RR7R](R3tend((s//usr/lib/python2.7/site-packages/yum/history.pyt _ui_from_repos  tfgetcCs |jS(N(Rq(R3((s//usr/lib/python2.7/site-packages/yum/history.pytsN( RPRQRR5RSRlRIRqtpropertyt ui_from_repo(((s//usr/lib/python2.7/site-packages/yum/history.pyRTs     tYumHistoryPackageStatecBseZdddZRS(c Cs8tj||||||||d|_||_dS(N(RTR5Rtdonetstate( R3RRYRXRVRWRxR_R`((s//usr/lib/python2.7/site-packages/yum/history.pyR5s  N(RPRQRR5(((s//usr/lib/python2.7/site-packages/yum/history.pyRvstYumHistoryRpmdbProblemcBsDeZdZdZdZdZdZeddZRS(sZ Class representing an rpmdb problem that existed at the time of the transaction. cCs7t||_||_||_||_d|_dS(N(tweakrefRCtrpidtproblemttextRt _loaded_P(R3R`R{R|R}((s//usr/lib/python2.7/site-packages/yum/history.pyR5s    cCsI|dkrdSt|j|j}|r0| St|j|j}|S(Ni(RtcmpR|R{(R3tothertret((s//usr/lib/python2.7/site-packages/yum/history.pyt__cmp__s cCs t|jS(N(thashR{(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt__hash__scCs7|jdkr0t|jj|j|_n|jS(N(R~RtsortedRCt_old_prob_pkgsR{(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getProbPkgss!RrcCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRss( RPRQRRR5RRRRttpackages(((s//usr/lib/python2.7/site-packages/yum/history.pyRys    tYumHistoryTransactioncBseZdZdZdZdZdZdZeddZ eddZ edd Z d Z edd Z d Zedd ZdZdZeddZeddZRS(s# Holder for a history transaction. cCst||_|d|_|d|_|d|_|d|_|d|_|d|_|d|_d|_ d|_ d|_ d|_ t|_d|_d|_d|_d|_d|_dS(Niiiiiii(RzRCttidt beg_timestamptbeg_rpmdbversiont end_timestamptend_rpmdbversiontloginuidt return_codeRt _loaded_TWt _loaded_TDt _loaded_TSt _loaded_PROBRt_have_loaded_CMDt _loaded_CMDt _loaded_ERt _loaded_OTtaltered_lt_rpmdbtaltered_gt_rpmdb(R3R`trow((s//usr/lib/python2.7/site-packages/yum/history.pyR5s$                cCsi|dkrdSt|j|j}|r0| St|j|j}|rO|St|j|j}| S(Ni(RRRRR(R3RR((s//usr/lib/python2.7/site-packages/yum/history.pyRs cCs7|jdkr0t|jj|j|_n|jS(N(RRRRCt_old_with_pkgsR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getTransWith)s!cCs7|jdkr0t|jj|j|_n|jS(N(RRRRCt_old_data_pkgsR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getTransData-s!cCs7|jdkr0t|jj|j|_n|jS(N(RRRRCt_old_skip_pkgsR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getTransSkip1s!RrcCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs6scCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs7scCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs8scCs7|jdkr0t|jj|j|_n|jS(N(RRRRCt _old_problemsR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getProblems:s!cCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs?scCs4|js-t|_|jj|j|_n|jS(N(RR"RCt _old_cmdlineRR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getCmdlineAs  cCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRsGscCs1|jdkr*|jj|j|_n|jS(N(RRRCt _load_errorsR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getErrorsIscCs1|jdkr*|jj|j|_n|jS(N(RRRCt _load_outputR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getOutputMscCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRsRscCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRsSs(RPRQRRR5RRRRRtt trans_witht trans_datat trans_skipRtrpmdb_problemsRtcmdlineRRterrorstoutput(((s//usr/lib/python2.7/site-packages/yum/history.pyRs"        tYumMergedHistoryTransactioncBseZdZdZeddZdZeddZdZeddZ dZ e dd Z e d Ze d Ze d Zd ZdZdZdZdZdZdZRS(cCst|jg|_|g|_|j|_|j|_|j|_|j|_d|_ d|_ g|_ d|_ t |_d|_d|_d|_d|_d|_dS(N(RSRt _merged_tidst _merged_objsRRRRRRRRRRRRRRRR(R3tobj((s//usr/lib/python2.7/site-packages/yum/history.pyR5Vs               cCs t|jS(N(RR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _getAllTidsqsRrcCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRssscCsCtd|jD}t|dkr9t|dSt|S(Ncss|]}|jVqdS(N(R(t.0R((s//usr/lib/python2.7/site-packages/yum/history.pys vsii(RSRR%tlistR(R3R((s//usr/lib/python2.7/site-packages/yum/history.pyt _getLoginUIDsuscCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRszscCsatd|jD}t|dkr;d|kr;dSd|krW|jdnt|S(Ncss|]}|jVqdS(N(R(RR((s//usr/lib/python2.7/site-packages/yum/history.pys }sii(RSRR%tremoveR(R3t ret_codes((s//usr/lib/python2.7/site-packages/yum/history.pyt_getReturnCodes|s  cCs |jS(N(R(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRsscCssg}t}xW|jD]L}xC|jD]8}|j|krDq)n|j|j|j|q)WqWt|S(N(RSRRRZtaddR'R(R3RtfiltRR4((s//usr/lib/python2.7/site-packages/yum/history.pyRs cCs1|dkr|j}n|jt|j|fS(s6 Take a pkg and return the key for it's state lookup. N(RRxRR RY(R4Rx((s//usr/lib/python2.7/site-packages/yum/history.pyt_p2sks  cCsMi}i}x4|D],}tj|}|||j<|||Z:d?Z;RS(As, API for accessing the history sqlite data. Rnc Csd|_tjj|_tjj|j |sYtjj|d||j_ ntjjd||j_ t |j_ t |j_||_d|_tjj|jj sytj|jj Wnttfk r}dSXt |j_ n*tj|jj tjr$t |j_ ntjd|jj }xtt|D]}tjj|}|tdtd !}|jdd}t|dkrqPnytt|Wntk rqPnXd|d |d |d f|_ ||_PqPW|jdkr&|j!s&dSn|jj d|j |j_"tjj|jj"sytj|jj"Wqttfk r}dSXn*tj|jj"tjrt |j_ ndS( NRns%s/history-*-*-*.sqliteshistory-s.sqlitet-iis%s-%s-%siii(#Rt_connRR t GenericHoldertconftostpathtnormpathR@tdb_pathRtwritableR"treadableR=t_db_filetexiststmakedirstIOErrortOSErrortaccesstW_OKRtreversedRtbasenameR%R\tmaptintt ValueErrort_db_datet_create_db_filet addon_path( R3trootRR=tetDBstdtfnametpieces((s//usr/lib/python2.7/site-packages/yum/history.pyR5sT #     "  cCs|jdS(N(tclose(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt__del__scCs|jdkr~|jjsdSytj|j|_Wn*tjtjfk rdt |j_dSXt |jj dn|jj S(NsPRAGMA locking_mode = EXCLUSIVE( RRRRRtconnectRtOperationalErrort DatabaseErrorRRtcursor(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _get_cursors  cCs |jjS(N(Rtcommit(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt_commitscCs |jjS(N(Rtrollback(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt _rollbackscCs,|jdk r(|jjd|_ndS(N(RRR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs c Cs?|j}t|d|xd|D]\\}}|dkrK|dkrK|S|dkr]q#n|dkroq#n||kr#|Sq#W|sdS|\}}} } } t|t|t| t| t| f\}}} } } |dk rt|d||| | | |f} n!t|d||| | | f} |jS(NsSELECT pkgtupid, checksum FROM pkgtups WHERE name=? AND arch=? AND epoch=? AND version=? AND release=?sINSERT INTO pkgtups (name, arch, epoch, version, release, checksum) VALUES (?, ?, ?, ?, ?, ?)sINSERT INTO pkgtups (name, arch, epoch, version, release) VALUES (?, ?, ?, ?, ?)(RRRRt lastrowid( R3RZR_tcreatetcurt sql_pkgtupidt sql_checksumtntaR tvtrRO((s//usr/lib/python2.7/site-packages/yum/history.pyt _pkgtup2pids0     0 cCsU|j}|dk r?dt|dt|df}n|j|j||S(Ns%s:%sii(t returnIdSumRRER#RZ(R3tpoRtcsum((s//usr/lib/python2.7/site-packages/yum/history.pyt _apkg2pids  'cCsVd}|j}d|kr@d|kr@d|j|jf}n|j|j||S(Nt checksum_typet checksum_datas%s:%s(RR^R(R)R#RZ(R3R%RR&tyumdb((s//usr/lib/python2.7/site-packages/yum/history.pyt _ipkg2pids  cCs|j||S(N(R'(R3R%R((s//usr/lib/python2.7/site-packages/yum/history.pyt _hpkg2pidscCsst|tr|j||St|tr>|j||St|tr]|j||S|j|jd|S(N( t isinstanceRR+RR'RTR,R#RZR(R3R%R((s//usr/lib/python2.7/site-packages/yum/history.pytpkg2pid"scCsd}|jttfkrB|jr-d}qB|jrBd}qBn|jtkrf|jrfd}qfn|dkrtj |j}|dkr|j rd}qn|S(NRRRRs Dep-Install( Rt output_statet TS_INSTALLtTS_TRUEINSTALLt reinstallt downgradestTS_ERASEt downgraded_byt _stcode2sttxtRJtisDep(ttxmbrRx((s//usr/lib/python2.7/site-packages/yum/history.pyt txmbr2state+s        cCs>|j}|dkrdSt|d|j|f}|jS(NskINSERT INTO trans_with_pkgs (tid, pkgtupid) VALUES (?, ?)(RRRt_tidR(R3tpidRRO((s//usr/lib/python2.7/site-packages/yum/history.pyttrans_with_pid<s   cCsK|j}|dks%|j r)dSt|d|j|f}|jS(NskINSERT INTO trans_skip_pkgs (tid, pkgtupid) VALUES (?, ?)(RRt_update_db_file_2RR:R(R3R;RRO((s//usr/lib/python2.7/site-packages/yum/history.pyttrans_skip_pidFs  cCss|dk stt|d s.|dkr2dS|j}|dkrNdSt|d|j||f}|jS(NR:suINSERT INTO trans_data_pkgs (tid, pkgtupid, state) VALUES (?, ?, ?)(RRthasattrRRR:R(R3R;RxRRO((s//usr/lib/python2.7/site-packages/yum/history.pyttrans_data_pid_begQs  cCskt|d s|dkr dS|j}|dkr<dSt|dd|j||f}|jdS(NR:sUPDATE trans_data_pkgs SET done = ? WHERE tid = ? AND pkgtupid = ? AND state = ? tTRUE(R?RRRR:R(R3R;RxRRO((s//usr/lib/python2.7/site-packages/yum/history.pyttrans_data_pid_end]s  c Cs_t|dsdS|j}|dks8|j r<dSt|j}t|d|j|j|f}|j }|s|Si}|j }|||j <|jdkrx!|j D]}|||j RJRKR(R3t rpmdb_versiont using_pkgsttxmbrst skip_packagesRRRROR4R;R8RxR|((s//usr/lib/python2.7/site-packages/yum/history.pytbegs.        cCs`|j}|dkrdSx3|D]+}t|}t|d|j|fq#W|jdS(NsJINSERT INTO trans_error (tid, msg) VALUES (?, ?)(RRRRR:R(R3RRterror((s//usr/lib/python2.7/site-packages/yum/history.pyt _log_errorss    cCs|dkst|d r dS|j}|dkr<dSx9|jD]+}t|}t|d|j|fqIW|jdS(s6 Note that data can be either a real pkg. ... or not. R:NsSINSERT INTO trans_script_stdout (tid, line) VALUES (?, ?)(RR?Rt splitlinesRRR:R(R3tdatatmsgRRS((s//usr/lib/python2.7/site-packages/yum/history.pytlog_scriptlet_outputs   cCsK|j}t|d|fg}x|D]}|j|dq,W|S(NsfSELECT msg FROM trans_error WHERE tid = ? ORDER BY mid ASCi(RRR'(R3RRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRs   cCsK|j}t|d|fg}x|D]}|j|dq,W|S(NsoSELECT line FROM trans_script_stdout WHERE tid = ? ORDER BY lid ASCi(RRR'(R3RRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRs   cCs|s| stt|ds&dS|j}|dkrBdSt|d|jttjt||f}|j |st|dd|jf|j n|dk r|j |n|`dS(NR:sINSERT INTO trans_end (tid, timestamp, rpmdb_version, return_code) VALUES (?, ?, ?, ?)sKUPDATE trans_data_pkgs SET done = ? WHERE tid = ?RA( RR?RRRR:RRLRERRT(R3RNRRRRO((s//usr/lib/python2.7/site-packages/yum/history.pyRps$       cCst|dstS|stS|s'tS|jjdt|j}|jjrtjj | rytj |ddWqt t fk r}tSXn|j dd}|d|}y:t|d}|jt||j|jWnt t fk r}tSXtS(sappend data to an arbitrary-named file in the history addon_path/transaction id location, returns True if write succeeded, False if notR:RntmodeiR>sw+(R?RRRRER:RRRRRRRtreplacetopentwriteR tflushRR"(R3tdatanameRVttid_dirR tsafenametdata_fntfo((s//usr/lib/python2.7/site-packages/yum/history.pytwrite_addon_data s, c Cs|jjdt|d}tj|d}g|D]}|j|d^q8}|s`|S||krpdSt||d}|j}|j|S(NRnRR?R"( RRRERRZRR[treadR( R3Rtitemt hist_and_tidt addon_infotit addon_namesRbRV((s//usr/lib/python2.7/site-packages/yum/history.pytreturn_addon_data6s%   c Cs|j}t|d|fg}xT|D]L}t|d|d|d|d|d|dd|}|j|q,W|S( NsSELECT name, arch, epoch, version, release, checksum FROM trans_with_pkgs JOIN pkgtups USING(pkgtupid) WHERE tid = ? ORDER BY name ASC, epoch ASCiiiiiiR`(RRRTR'(R3RRRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRFs   0 c Cs|j}t|d|fg}x|D]}t|d|d|d|d|d|d|dd |}|d d k|_d|_t|jtkrt |_nt|jt krt |_n|j |q,W|S( Ns SELECT name, arch, epoch, version, release, checksum, done, state FROM trans_data_pkgs JOIN pkgtups USING(pkgtupid) WHERE tid = ? ORDER BY name ASC, epoch ASC, state DESCiiiiiiiR`iRA( RRRvRwRRRRxRR"RRR'(R3RRRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRSs   &   c Cs|j}|dks%|j r)gSt|d|fg}xT|D]L}t|d|d|d|d|d|dd|}|j|qIW|S( NsSELECT name, arch, epoch, version, release, checksum FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid) WHERE tid = ? ORDER BY name ASC, epoch ASCiiiiiiR`(RRR=RRTR'(R3RRRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRgs   0 c Cs|j}|dks%|j r)gSt|d|fg}xg|D]_}t|d|d|d|d|d|dd|}|d d k|_|j|qIW|S( NsSELECT name, arch, epoch, version, release, checksum, main FROM trans_prob_pkgs JOIN pkgtups USING(pkgtupid) WHERE rpid = ? ORDER BY name ASC, epoch ASCiiiiiiR`iRA(RRR=RRTRIR'(R3R{RRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRvs   0 cCs|j}|dks%|j r)gSt|d|fg}x<|D]4}t||d|d|d}|j|qIW|S(NsSELECT rpid, problem, msg FROM trans_rpmdb_problems WHERE tid = ? ORDER BY problem ASC, rpid ASCiii(RRR=RRyR'(R3RRRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRs   !cCs\|j}|dks%|j r)dSt|d|fg}x|D] }|dSWdS(Ns[SELECT cmdline FROM trans_cmdline WHERE tid = ?i(RRR=R(R3RRRR((s//usr/lib/python2.7/site-packages/yum/history.pyRs    cCs|j}|d krgSd}|s1d}nd }|rt|tjjkrtt|}}|ddjdgt|7}n|d7}|d k r|dt |7}nt |||g}i}xo|D]g} |rt|tjjkr| d|krqqnt || } | || d<|j | qWd }|j }t|tjjkrt ||n4|ddjdgt|7}t |||xc|D][} | d|krqn| d || d_| d || d_| d || d_qWd } xt|D]} | j} d } | d k ra| j} n| d ks| d ks| jd | jkrn3| | krt| _t| _nt| _t| _| } q4W|S(s Return a list of the last transactions, note that this includes partial transactions (ones without an end transaction). s]SELECT tid, trans_beg.timestamp AS beg_ts, trans_beg.rpmdb_version AS beg_rv, trans_end.timestamp AS end_ts, trans_end.rpmdb_version AS end_rv, loginuid, return_code FROM trans_beg JOIN trans_end USING(tid)sSELECT tid, trans_beg.timestamp AS beg_ts, trans_beg.rpmdb_version AS beg_rv, NULL, NULL, loginuid, NULL FROM trans_begs WHERE tid IN (%s)s, t?s ORDER BY tid DESCs LIMIT isSELECT tid, trans_end.timestamp AS end_ts, trans_end.rpmdb_version AS end_rv, return_code FROM trans_endiiiN(RRR%Rt constantsR$RRStjoinRERRR'RRRRRRRR"RRR(R3ttidstlimittcomplete_transactions_onlyRtsqltparamsRttid2objRRtlastcur_rvtlas_rv((s//usr/lib/python2.7/site-packages/yum/history.pytoldsd   '     $    .      cCs?|jgd|}|sdSt|dks7t|dS(si This is the last full transaction. So any incomplete transactions do not count, by default. iiN(RwRR%R(R3RpR((s//usr/lib/python2.7/site-packages/yum/history.pytlasts cCs|j}|dks%|j r)dS|j|dt}|dkrNdSdi|d6}t||||fx|D] }|dSWdS(NRs\SELECT %(db)sdb_val FROM pkg_%(db)sdb WHERE pkgtupid=? and %(db)sdb_key=? tdbi(RRt_update_db_file_3R.RR(R3R4RyRGRR;RqR((s//usr/lib/python2.7/site-packages/yum/history.pyt_load_anydb_keys    cCs|j|d|S(Ntrpm(R{(R3R4RG((s//usr/lib/python2.7/site-packages/yum/history.pyRmscCs|j|d|S(NR(R{(R3R4RG((s//usr/lib/python2.7/site-packages/yum/history.pyRDscCs|j}|dks%|j r)dS|j|dt}|dkrNdSdi|d6}t||||t|f|jS(NRshINSERT INTO pkg_%(db)sdb (pkgtupid, %(db)sdb_key, %(db)sdb_val) VALUES (?, ?, ?)Ry(RRRzR.RRRR(R3R4RyRGRHRR;Rq((s//usr/lib/python2.7/site-packages/yum/history.pyt_save_anydb_keys  cCs|j|d||S(NR|(R}(R3R4RGRH((s//usr/lib/python2.7/site-packages/yum/history.pyt_save_rpmdb_key"scCs|j|d||S(NR(R}(R3R4RGRH((s//usr/lib/python2.7/site-packages/yum/history.pyt_save_yumdb_key$scCsXxQtjD]F}t||d}|dkr4q n|j|d||s tSq WtS(se Save all the data for rpmdb for this installed pkg, assumes there is no data currently. R|N(RTRlRMRR}RR"(R3tipkgRGRH((s//usr/lib/python2.7/site-packages/yum/history.pyt _save_rpmdb's cCsXxQtjD]F}|jj|}|dkr4q n|j|d||s tSq WtS(se Save all the data for yumdb for this installed pkg, assumes there is no data currently. RN(R1RBR^RJRR}RR"(R3RRGRH((s//usr/lib/python2.7/site-packages/yum/history.pyt _save_yumdb2s cCsv|j}|dks%|j r)tS|j|dt}|dkrNtSdi|d6}t|||ftS(s= Delete all the data for rpmdb/yumdb for this installed pkg. Rs)DELETE FROM pkg_%(db)sdb WHERE pkgtupid=?RyN(RRRzRR.RR"(R3R4RyRR;Rq((s//usr/lib/python2.7/site-packages/yum/history.pyt _wipe_anydb=s  cCsb|j|dstS|j|doC|j|oC|j|sT|jtS|jtS(s< Sync. all the data for rpmdb/yumdb for this installed pkg. R|R(RRRRRRR"(R3R((s//usr/lib/python2.7/site-packages/yum/history.pyt sync_alldbLs  c Csidd6dd6dd6dd6dd6dd6}|j}|dksU|j rYtSddddddf}xM|D]E\}}}t|d||fx|D]}|d||R@RBRJRKRRRTRXRRRpRcRjRRRRRRRwRxR{RmRDR}R~RRRRRRRRRRzRR=R(((s//usr/lib/python2.7/site-packages/yum/history.pyRs<     !      * !   )      Q          @     s SELECT pkgtupid,name,epoch,version,release,arch, name || "." || arch AS sql_nameArch, name || "-" || version || "-" || release || "." || arch AS sql_nameVerRelArch, name || "-" || version AS sql_nameVer, name || "-" || version || "-" || release AS sql_nameVerRel, epoch || ":" || name || "-" || version || "-" || release || "." || arch AS sql_envra, name || "-" || epoch || ":" || version || "-" || release || "." || arch AS sql_nevra FROM pkgtups WHERE (-RLRtos.pathRRRzRtsqlutilsRRRtyum.miscR t yum.constantsRt yum.packagesRRRtyum.i18nRR t rpmUtils.archR Rt TS_UPDATEt TS_UPDATEDR4R0R1t TS_OBSOLETEDt TS_OBSOLETINGR6RRRR0R1RTRvRyRRRR(((s//usr/lib/python2.7/site-packages/yum/history.pytsX         '0D  S?