ok

Mini Shell

Direktori : /proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/yum/
Upload File :
Current File : //proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/yum/history.pyc

�
8M�bc@sddlZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddljZddl
Zddl
TddlmZmZmZddlmZmZddlmZdZid	e6d
e6de6de6d
e6de6de6Z ied	6ed
6ed6ed6ed
6ed6ed6ed6ed6ed6ed6Z!e"e#d�Z$dfd��YZ%defd��YZ&de&fd��YZ'dfd��YZ(dfd��YZ)de)fd ��YZ*d!fd"��YZ+d#Z,dS($i����N(tproxy(tsqlitet
executeSQLtsql_esc_glob(t*(tYumInstalledPackagetYumAvailablePackaget
PackageObject(t
to_unicodetto_utf8(tgetBaseArchs/var/lib/yum/historytUpdatetUpdatedtErasetInstallsTrue-Installt	Obsoletedt
ObsoletingsDep-Installt	Reinstallt	Downgradet
DowngradedcCsF|d
krg}ndddddddg}t}x*|D]"}tjj|�r=t}Pq=q=Wt}|s�dg}t}nt|�|kr�g}n|r�t	|�}n�g}t}xL|D]D}tj
|�r�|j|df�t}q�|j|d	f�q�W|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_nameVerRelArchtsql_nameVertsql_nameVerRelt	sql_envrat	sql_nevratglobt=N(tNonetFalsetyumtmisctre_full_search_neededtTruetPATTERNS_MAXtPATTERNS_INDEXED_MAXtlenRtre_globtappend(tpatternstignore_casetfieldst	need_fulltpattpat_maxttmpt	need_glob((s//usr/lib/python2.7/site-packages/yum/history.pyt_setupHistorySearchSQL>s:		
			
	t_YumHistPackageYumDBc	BsYeZdZd�Zedddddddd	g�Zd
�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}|jd�r.td||f�n||jkrStd||f�n|jj||�}tr�|dkr�td||f�n|dkr�dSt|�p�d}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.pyRJ�s

N(
t__name__t
__module__t__doc__R5tsetRBRIRLRRJ(((s//usr/lib/python2.7/site-packages/yum/history.pyR1es			tYumHistoryPackagecBseeZddd�Zeddddddddd	d
g
�Zd�Zd�Zed
d��Z	RS(c	Cs�||_||_||_||_||_|j|j|j|j|jf|_|dkrlg|_n,|jd�}|d|ddfg|_d|_	||_
t|�|_dS(Nt:iis	<history>(
RtversiontreleasetepochtarchtpkgtupRt
_checksumstsplittrepoidRCR1t
yumdb_info(	R3RRYRXRVRWtchecksumthistorytchk((s//usr/lib/python2.7/site-packages/yum/history.pyR5�s							t	buildtimet	buildhosttlicensetpackagertsizet	sourcerpmturltvendort	committert
committimecCs�|jd�r%td||f�n||jkrJtd||f�n|jj||�}tr�|dkr�td||f�n|dkr�dSt|�p�d}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.pyRI�scCs�d|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_repo�s	
tfgetcCs
|j�S(N(Rq(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt<lambda>�sN(
RPRQRR5RSRlRIRqtpropertytui_from_repo(((s//usr/lib/python2.7/site-packages/yum/history.pyRT�s			tYumHistoryPackageStatecBseZddd�ZRS(c			Cs8tj||||||||�d|_||_dS(N(RTR5Rtdonetstate(	R3RRYRXRVRWRxR_R`((s//usr/lib/python2.7/site-packages/yum/history.pyR5�s
	N(RPRQRR5(((s//usr/lib/python2.7/site-packages/yum/history.pyRv�stYumHistoryRpmdbProblemcBsDeZdZd�Zd�Zd�Zd�Zedd��ZRS(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.pyR5�s
			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|j�S(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_getProbPkgs�s!RrcCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs�s(	RPRQRRR5R�R�R�Rttpackages(((s//usr/lib/python2.7/site-packages/yum/history.pyRy�s					tYumHistoryTransactioncBs�eZdZd�Zd�Zd�Zd�Zd�Zedd��Z	edd��Z
edd	��Zd
�Zedd��Z
d�Zedd
��Zd�Zd�Zedd��Zedd��ZRS(s# Holder for a history transaction. cCs�t|�|_|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_rpmdbversiontloginuidtreturn_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(RRR�R�R�(R3R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR�scCs7|jdkr0t|jj|j��|_n|jS(N(R�RR�RCt_old_with_pkgsR�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt
_getTransWith)s!cCs7|jdkr0t|jj|j��|_n|jS(N(R�RR�RCt_old_data_pkgsR�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt
_getTransData-s!cCs7|jdkr0t|jj|j��|_n|jS(N(R�RR�RCt_old_skip_pkgsR�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt
_getTransSkip1s!RrcCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs6scCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs7scCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs8scCs7|jdkr0t|jj|j��|_n|jS(N(R�RR�RCt
_old_problemsR�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt_getProblems:s!cCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs?scCs4|js-t|_|jj|j�|_n|jS(N(R�R"RCt_old_cmdlineR�R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt_getCmdlineAs		cCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRsGscCs1|jdkr*|jj|j�|_n|jS(N(R�RRCt_load_errorsR�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt
_getErrorsIscCs1|jdkr*|jj|j�|_n|jS(N(R�RRCt_load_outputR�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt
_getOutputMscCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRsRscCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRsSs(RPRQRRR5R�R�R�R�Rtt
trans_witht
trans_datat
trans_skipR�trpmdb_problemsR�tcmdlineR�R�terrorstoutput(((s//usr/lib/python2.7/site-packages/yum/history.pyR�s"		
							tYumMergedHistoryTransactioncBs�eZd�Zd�Zedd��Zd�Zedd��Zd�Zedd��Z	d�Z
edd	��Z
ed
��Zed��Zed��Zd
�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(cCs�t|jg�|_|g|_|j|_|j|_|j|_|j|_d|_	d|_
g|_d|_t
|_d|_d|_d|_d|_d|_dS(N(RSR�t_merged_tidst_merged_objsR�R�R�R�RR�R�R�R�RR�R�R�R�R�R�(R3tobj((s//usr/lib/python2.7/site-packages/yum/history.pyR5Vs 									cCs
t|j�S(N(R�R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt_getAllTidsqsRrcCs
|j�S(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	<genexpr>vsii(RSR�R%tlistR�(R3R�((s//usr/lib/python2.7/site-packages/yum/history.pyt
_getLoginUIDsuscCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRszscCsatd�|jD��}t|�dkr;d|kr;dSd|krW|jd�nt|�S(Ncss|]}|jVqdS(N(R�(R�R�((s//usr/lib/python2.7/site-packages/yum/history.pys	<genexpr>}sii(RSR�R%tremoveR�(R3t	ret_codes((s//usr/lib/python2.7/site-packages/yum/history.pyt_getReturnCodes|scCs
|j�S(N(R�(R3((s//usr/lib/python2.7/site-packages/yum/history.pyRs�scCssg}t�}xW|jD]L}xC|jD]8}|j|krDq)n|j|j�|j|�q)WqWt|�S(N(RSR�R�RZtaddR'R�(R3R�tfiltR�R4((s//usr/lib/python2.7/site-packages/yum/history.pyR��s	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_p2sk�scCsMi}i}x4|D],}tj|�}|||j<|||<qW||fS(N(R�R�RZ(tpkgst
pkgtup2pkgtpkgstate2pkgR4tkey((s//usr/lib/python2.7/site-packages/yum/history.pyt
_list2dict�s

c	Cs�t|j|j|j|j|j|d|j�}|j|_|j|_t	|j
tkrjt|_
nt	|j
tkr�t|_
n|S(NR`(RvRRYRXRVRWRCR[Rwt
_sttxt2stcodeRxtTS_INSTALL_STATESR"tstate_installedtTS_REMOVE_STATESR(R4Rxtnpkg((s//usr/lib/python2.7/site-packages/yum/history.pyt_conv_pkg_state�scCsBt|�td�kr*tj|�}n||kr:dS||S(Nii(ii(ttypeR�R�R(tskR�((s//usr/lib/python2.7/site-packages/yum/history.pyt_get_pkg�s
cCsh|j||�}|dkr"dS||j|�=|j||�}|||j<|||j|�<dS(N(R�RR�R�RZ(R3R�tnstateR�R�txpkg((s//usr/lib/python2.7/site-packages/yum/history.pyt	_move_pkg�s
c	sP��fd�}��fd�}���fd�}���fd�}���fd�����fd����fd�}i�i�x��jD]�}�j|j�\��x t�j��D]}|\}}	}
|
dkr�q�n�|}x9dD].}|�j||��}
|
dk	r	Pq	q	Wq�trGq�||
kr||d�|d
kr�||
d�q�q�||
kr�||d�|d
kr�||
d�q�q��|�|d
kr�||
d�q�q�Wt�j��j	�j��}x�|D]�}|�ks	|�kr-q	n�|}�|}
trJq	|j
dkrx|
j
dkr��|�q�q	|j
dkr�d}|
j
|ks�t�q	|j
dkrUtr�q�|
j
dkr�|||
�q�|
j
dkr|||
�|�j|d�|j
�q�|
j
dkr�|||
�|�j|d�|j
�q�q	|j
dkr	trmq�|
j
dkr��|
�q�|
j
dkr�|||
�|�j|d�|
j
�|�j|d�|
j
�q�|
j
dkr�|�j|d��}|dkr.|�j|d��}n|dkrX|j
d
krOq	n|}n|�j|
d��}|dkr�|�j|
d��}n|dkr�|�j|
d
��}n|dkr�q	n|||
�||kr9d}d
|j
|j
fkrd
}n||kr,|||�n�|�q�||kr�d}d}d
|j
|j
fkrrd
}n||kr�|||�n|||�q�d}d}d
|j
|j
fkr�d
}n||kr�|||�n|||�q�q	q	Wx�D]}�|�|<qWx�D]}�|�|<q$Wq�Wt�j
��S(Ncs�j|��S(N(R�(R�(t
fpkgstate2pkgR3(s//usr/lib/python2.7/site-packages/yum/history.pyt
_get_pkg_f�scs�j|��S(N(R�(R�(t
npkgstate2pkgR3(s//usr/lib/python2.7/site-packages/yum/history.pyt
_get_pkg_n�scs�j||���dS(N(R�(R�R�(R�tfpkgtup2pkgR3(s//usr/lib/python2.7/site-packages/yum/history.pyt_move_pkg_f�scs�j||���dS(N(R�(R�R�(R�tnpkgtup2pkgR3(s//usr/lib/python2.7/site-packages/yum/history.pyt_move_pkg_n�scs3�|j=�j|�}|�kr/�|=ndS(N(RZR�(R4R�(R�R�R3(s//usr/lib/python2.7/site-packages/yum/history.pyt_del1_n�s
cs3�|j=�j|�}|�kr/�|=ndS(N(RZR�(R4R�(R�R�R3(s//usr/lib/python2.7/site-packages/yum/history.pyt_del1_f�s
cs0|j|jkst��|��|�dS(N(RZtAssertionError(tfpkgR�(R�R�(s//usr/lib/python2.7/site-packages/yum/history.pyt_del2�s
RR
RsTrue-InstallsDep-InstallRRRRRR(RR
(RsTrue-InstallsDep-InstallR(RR
RRR(RR
(RsTrue-InstallsDep-InstallR(RsTrue-InstallsDep-Install(R
R(RRR(R
R(RR(R�R�R�R�tkeysR�RRRStintersectionRxR�R�tvalues(R3R�R�R�R�R�R�R�RRYRxR�txstateR�tsametupsRZtgood_statestxfpkgtxnpkgtnfstatetnnstateRK((R�R�R�R�R�R�R3s//usr/lib/python2.7/site-packages/yum/history.pyR��s�




!


	

"

	
	
		

cCsHt�}x2|jD]'}x|jD]}|j|�q#WqWt|�S(N(RSR�R�R�R�(R3tprobsR�tprob((s//usr/lib/python2.7/site-packages/yum/history.pyR�ds
	cCsfg}xO|jD]D}|js%qn|rD|d|jkrDqn|j|j�qW|sbdS|S(Ni����(R�R�R'R(R3tcmdlinesR�((s//usr/lib/python2.7/site-packages/yum/history.pyR�ks	cCs.g}x!|jD]}|j|j�qW|S(N(R�textendR�(R3R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR�wscCs.g}x!|jD]}|j|j�qW|S(N(R�R�R�(R3R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR�|scCs�|j|jkrdS|jj|j�|jj|�|jjdt�|j|jkry|j|_|j|_n|j	|j	kr�|j	|_	|j
|_
ndS(Ntreverse(R�R�R�R�R'tsortR"R�R�R�R�(R3R�((s//usr/lib/python2.7/site-packages/yum/history.pytmerge�sN(RPRQR5R�RtR�R�R�R�R�R�tstaticmethodRR�R�R�R�R�R�R�R�R�R�R�(((s//usr/lib/python2.7/site-packages/yum/history.pyR�Us(									�				t
YumHistorycBs?eZdZded@d�Zd�Zd�Zd�Zd�Z	d�Z
d@ed�Zed	�Z
ed
�Zed�Zed�Zed
��Zd�Zd�Zd�Zd�Zd�Zd�Zggd@d�Zd�Zd�Zd�Zd�Zd@d�Zd�Z d@d�Z!d�Z"d�Z#d�Z$d�Z%d �Z&d!�Z'gd@ed"�Z(ed#�Z)d$�Z*d%�Z+d&�Z,d'�Z-d(�Z.d)�Z/d*�Z0d+�Z1d,�Z2d-�Z3d.�Z4d/�Z5ed0�Z6d1d2d3d4gZ7d5�Z8d6d7d8d9d:d;d<d=gZ9d>�Z:d?�Z;RS(As, API for accessing the history sqlite data. Rnc	Cs�d|_tjj�|_tjj|�j	|�sYtjj|d|�|j_
ntjjd|�|j_
t|j_t
|j_||_d|_tjj|jj
�s�ytj|jj
�Wnttfk
r�}dSXt
|j_n*tj|jj
tj�r$t
|j_ntjd|jj
�}x�tt|��D]�}tjj|�}|td�td�!}|jdd�}t|�dkr�qPnytt|�Wntk
r�qPnXd|d	|d
|df|_ ||_PqPW|jdkr&|j!�s&dSn|jj
d|j |j_"tjj|jj"�s�ytj|jj"�Wq�ttfk
r�}dSXn*tj|jj"tj�r�t
|j_ndS(NRns%s/history-*-*-*.sqliteshistory-s.sqlitet-iis%s-%s-%siii(#Rt_connRR t
GenericHoldertconftostpathtnormpathR@tdb_pathRtwritableR"treadableR=t_db_filetexiststmakedirstIOErrortOSErrortaccesstW_OKRtreversedR�tbasenameR%R\tmaptintt
ValueErrort_db_datet_create_db_filet
addon_path(	R3trootR�R=tetDBstdtfnametpieces((s//usr/lib/python2.7/site-packages/yum/history.pyR5�sT	#		
"	cCs|j�dS(N(tclose(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt__del__�scCs�|jdkr~|jjsdSytj|j�|_Wn*tjtjfk
rdt	|j_dSXt
|jj�d�n|jj�S(NsPRAGMA locking_mode = EXCLUSIVE(R�RR�R�RtconnectR�tOperationalErrort
DatabaseErrorRRtcursor(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt_get_cursor�scCs
|jj�S(N(R�tcommit(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt_commit�scCs
|jj�S(N(R�trollback(R3((s//usr/lib/python2.7/site-packages/yum/history.pyt	_rollback�scCs,|jdk	r(|jj�d|_ndS(N(R�RR(R3((s//usr/lib/python2.7/site-packages/yum/history.pyR�s
c
	Cs?|j�}t|d|�xd|D]\\}}|dkrK|dkrK|S|dkr]q#n|dkroq#n||kr#|Sq#W|s�dS|\}}}	}
}t|�t|�t|	�t|
�t|�f\}}}	}
}|dk	rt|d|||	|
||f�}n!t|d|||	|
|f�}|jS(Ns�SELECT pkgtupid, checksum FROM pkgtups
                           WHERE name=? AND arch=? AND
                                 epoch=? AND version=? AND release=?s�INSERT INTO pkgtups
                                (name, arch, epoch, version, release, checksum)
                                VALUES (?, ?, ?, ?, ?, ?)s�INSERT 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_pkgtup2pid�s0
0cCsU|j�}|dk	r?dt|d�t|d�f}n|j|j||�S(Ns%s:%sii(treturnIdSumRRER#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|t�r|j||�St|t�r>|j||�St|t�r]|j||�S|j|jd|�S(N(
t
isinstanceRR+RR'RTR,R#RZR(R3R%R((s//usr/lib/python2.7/site-packages/yum/history.pytpkg2pid"scCs�d}|jttfkrB|jr-d}qB|jrBd}qBn|jtkrf|jrfd}qfn|dkr�tj	|j�}|dkr�|j
r�d}q�n|S(NRRRRsDep-Install(Rtoutput_statet
TS_INSTALLtTS_TRUEINSTALLt	reinstallt
downgradestTS_ERASEt
downgraded_byt
_stcode2sttxtRJtisDep(ttxmbrRx((s//usr/lib/python2.7/site-packages/yum/history.pyttxmbr2state+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	st�t|d�s.|dkr2dS|j�}|dkrNdSt|d|j||f�}|jS(NR:suINSERT INTO trans_data_pkgs
                         (tid, pkgtupid, state)
                         VALUES (?, ?, ?)(RR�thasattrRRR: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�}|j�dS(NR:s�UPDATE 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|d�sdS|j�}|dks8|j�r<dSt|j��}t|d|j|j|f�}|j	}|s�|Si}|j
}|||j<|jdkr�x!|jD]}|||j<q�Wn|jdkr�|j
||j
j<nxb|j�D]T}|j|�}|j|j
jkr6d}	nd}	t|d|||	f�}qW|S(NR:swINSERT INTO trans_rpmdb_problems
                         (tid, problem, msg)
                         VALUES (?, ?, ?)t	conflictst
duplicatesRAtFALSEs}INSERT INTO trans_prob_pkgs
                             (rpid, pkgtupid, main)
                             VALUES (?, ?, ?)(R?RRR=Rt__str__RR:R|RR4RZRCt	duplicateR�R.(
R3R|RtuproblemROR{R�R4R;tmain((s//usr/lib/python2.7/site-packages/yum/history.pyt_trans_rpmdb_problemks:			
	cCsdt|d�sdS|j�}|dks8|j�r<dSt|d|jt|�f�}|jS(NR:shINSERT INTO trans_cmdline
                         (tid, cmdline)
                         VALUES (?, ?)(R?RRR=RR:RR(R3R�RRO((s//usr/lib/python2.7/site-packages/yum/history.pyt_trans_cmdline�scCs<|j�}|dkrdSt|dttj��t|�tjj�f�}|j	|_
x*|D]"}	|j|	�}
|j|
�qeWx?|D]7}|j
|j�}
|j|�}|j|
|�q�Wx*|D]"}	|j
|	�}
|j|
�q�Wx|D]}
|j|
�qW|r.|j|�n|j�dS(Ns�INSERT INTO trans_beg
                            (timestamp, rpmdb_version, loginuid)
                            VALUES (?, ?, ?)(RRRRttimeRERR tgetloginuidRR:R+R<R.R%R9R@R>RJRKR(R3t
rpmdb_versiont
using_pkgsttxmbrst
skip_packagesR�R�RROR4R;R8RxR|((s//usr/lib/python2.7/site-packages/yum/history.pytbeg�s.	



cCs`|j�}|dkrdSx3|D]+}t|�}t|d|j|f�q#W|j�dS(NsJINSERT INTO trans_error
                          (tid, msg) VALUES (?, ?)(RRRRR:R(R3R�Rterror((s//usr/lib/python2.7/site-packages/yum/history.pyt_log_errors�s
cCs�|dkst|d�r dS|j�}|dkr<dSx9|j�D]+}t|�}t|d|j|f�qIW|j�dS(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_output�scCsK|j�}t|d|f�g}x|D]}|j|d�q,W|S(NsfSELECT msg FROM trans_error
                      WHERE tid = ?
                      ORDER BY mid ASCi(RRR'(R3R�RR�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR��s

cCsK|j�}t|d|f�g}x|D]}|j|d�q,W|S(NsoSELECT line FROM trans_script_stdout
                      WHERE tid = ?
                      ORDER BY lid ASCi(RRR'(R3R�RR�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR��s

cCs�|s|st�t|d�s&dS|j�}|dkrBdSt|d|jttj��t|�|f�}|j	�|s�t|dd|jf�|j	�n|dk	r�|j
|�n|`dS(NR:s�INSERT INTO trans_end
                            (tid, timestamp, rpmdb_version, return_code)
                            VALUES (?, ?, ?, ?)sKUPDATE trans_data_pkgs SET done = ?
                          WHERE tid = ?RA(R�R?RRRR:RRLRERRT(R3RNR�R�RRO((s//usr/lib/python2.7/site-packages/yum/history.pyRp�s$	

cCst|d�stS|stS|s'tS|jjdt|j�}|jjr�tjj	|�r�ytj
|dd�Wq�ttfk
r�}tSXn|j
dd�}|d|}y:t|d�}|jt|��|j�|j�Wnttfk
r}tSXtS(s�append data to an arbitrary-named file in the history 
           addon_path/transaction id location,
           returns True if write succeeded, False if notR:Rntmodei�R>sw+(R?RR�RRER:R�R�R�R�R�R�R�treplacetopentwriteR	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"(	R�RRERRZRR[treadR(	R3R�titemthist_and_tidt
addon_infotitaddon_namesRbRV((s//usr/lib/python2.7/site-packages/yum/history.pytreturn_addon_data6s%
c
Cs�|j�}t|d|f�g}xT|D]L}t|d|d|d|d|d|dd|�}|j|�q,W|S(	Ns�SELECT name, arch, epoch, version, release, checksum
                      FROM trans_with_pkgs JOIN pkgtups USING(pkgtupid)
                      WHERE tid = ?
                      ORDER BY name ASC, epoch ASCiiiiiiR`(RRRTR'(R3R�RR�R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR�Fs

0	cCs�|j�}t|d|f�g}x�|D]�}t|d|d|d|d|d|d|dd	|�}|d
dk|_d|_t|jtkr�t	|_nt|jt
kr�t|_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(
RRRvRwRR�R�RxR�R"R�RR'(R3R�RR�R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR�Ss

&	cCs�|j�}|dks%|j�r)gSt|d|f�g}xT|D]L}t|d|d|d|d|d|dd|�}|j|�qIW|S(	Ns�SELECT name, arch, epoch, version, release, checksum
                      FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid)
                      WHERE tid = ?
                      ORDER BY name ASC, epoch ASCiiiiiiR`(RRR=RRTR'(R3R�RR�R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR�gs

0	cCs�|j�}|dks%|j�r)gSt|d|f�g}xg|D]_}t|d|d|d|d|d|dd|�}|d	d
k|_|j|�qIW|S(Ns�SELECT 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{RR�R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR�vs

0	cCs�|j�}|dks%|j�r)gSt|d|f�g}x<|D]4}t||d|d|d�}|j|�qIW|S(Ns�SELECT rpid, problem, msg
                      FROM trans_rpmdb_problems
                      WHERE tid = ?
                      ORDER BY problem ASC, rpid ASCiii(RRR=RRyR'(R3R�RR�R�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR��s

!cCs\|j�}|dks%|j�r)dSt|d|f�g}x|D]}|dSWdS(Ns[SELECT cmdline
                      FROM trans_cmdline
                      WHERE tid = ?i(RRR=R(R3R�RR�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR��s

	cCs�|j�}|d
krgSd}|s1d}nd
}|r�t|�tjjkr�tt|��}}|ddjdgt|��7}n|d7}|d
k	r�|dt	|�7}nt
|||�g}i}xo|D]g}	|rt|�tjjkr|	d|krq�qnt||	�}
|
||	d<|j|
�q�Wd	}|j
�}t|�tjjkr�t
||�n4|ddjdgt|��7}t
|||�xc|D][}	|	d|kr�q�n|	d
||	d_|	d||	d_|	d||	d_q�Wd
}x�t|�D]�}
|
j}d
}
|d
k	ra|j}
n|
d
ks�|d
ks�|jd
|
jkr�n3|
|kr�t|
_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 is�SELECT tid,
                         trans_end.timestamp AS end_ts,
                         trans_end.rpmdb_version AS end_rv,
                         return_code
                  FROM trans_endiiiN(RRR%Rt	constantsR$R�RStjoinRERR�R'R�R�R�R�RR�R�R"R�R�R(R3ttidstlimittcomplete_transactions_onlyRtsqltparamsR�ttid2objR�R�tlastcur_rvtlas_rv((s//usr/lib/python2.7/site-packages/yum/history.pytold�sd	'

	$
	.			
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.pytlast�s
cCs�|j�}|dks%|j�r)dS|j|dt�}|dkrNdSdi|d6}t||||f�x|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_key�s
	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"(R3R�RGRH((s//usr/lib/python2.7/site-packages/yum/history.pyt_save_yumdb2scCsv|j�}|dks%|j�r)tS|j|dt�}|dkrNtSdi|d6}t|||f�tS(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|d�stS|j|d�oC|j|�oC|j|�sT|j�tS|j�tS(s< Sync. all the data for rpmdb/yumdb for this installed pkg. R|R(R�RR�R�RRR"(R3R�((s//usr/lib/python2.7/site-packages/yum/history.pyt
sync_alldbLs

c	Cs�idd6dd6dd6dd6dd6dd6}|j�}|dksU|j�rYtSddddddf}xM|D]E\}}}t|d||f�x|D]}|d||<q�WqxW|S(s& Some stats about packages in the DB. itnevractnevratnevrtnatrpmdbR*sCOUNT(*)tpkgtupssCOUNT(DISTINCT(name || arch))s4COUNT(DISTINCT(name||version||epoch||release||arch))s.COUNT(DISTINCT(name||version||epoch||release))sCOUNT(DISTINCT(pkgtupid))t	pkg_rpmdbt	pkg_yumdbsSELECT %s FROM %sN(R�sCOUNT(*)R�(R�sCOUNT(DISTINCT(name || arch))R�(R�s4COUNT(DISTINCT(name||version||epoch||release||arch))R�(R�s.COUNT(DISTINCT(name||version||epoch||release))R�(R�sCOUNT(DISTINCT(pkgtupid))R�(syumdbsCOUNT(DISTINCT(pkgtupid))R�(RRRzRR(R3R�RRVR�tbsqltesqlR�((s//usr/lib/python2.7/site-packages/yum/history.pyt
_pkg_statsYs,

	
ccs�|j�}t}g}g}xi|D]a\}}	xR|D]J}
|r^|jd|
|	f�n|jd|
|	f�|j|�q8Wq%W|s�t�|dj|�7}t|||�x|D]}|Vq�WdS(s2Yields all the package data for the given params. s%s LIKE ?%ss%s %s ?s OR N(Rt_FULL_PARSE_QUERY_BEGR'R�RmR(R3R(R*R)Rtqsqltpat_sqlstpat_datatpatterntresttfieldRK((s//usr/lib/python2.7/site-packages/yum/history.pyt_yieldSQLDataListvs

cCs-|j�}|dkrt�Sg|D]'}tjdd|�jdd�^q&}t||�}|\}}}}	g}
t�}|r�x�|j|||�D]}|j|d�q�Wn�t	}
|s�t
}
nx{tjj
||
�D]d}t||�}|\}}}}	|st�x.|j|||�D]}|j|d�q1Wq�Wd}|ddjdgt|��7}t|�}t�}t|�tjj
kr�t|d	�x2|D]*}|d
|kr�|j|d�q�q�W|S|s�|St|||�x|D]}|j|d�qW|S(s{ Search for history transactions which contain specified
            packages al. la. "yum list". Returns transaction ids. s	\[[^]]+\]Rkt[t!is2SELECT tid FROM trans_data_pkgs WHERE pkgtupid IN s(%s)t,s(SELECT tid,pkgtupid FROM trans_data_pkgsiN(RRRStretsubRZR0R�R�R#R$RR t
seq_max_splitR�RmR%R�RlR(R3R(R)RRKRVR+t	npatternsR*tnamesR�t	pkgtupidsR�R-tnpsRqRrRn((s//usr/lib/python2.7/site-packages/yum/history.pytsearch�sJ
1		$	


s� CREATE TABLE pkg_rpmdb (
     pkgtupid INTEGER NOT NULL REFERENCES pkgtups,
     rpmdb_key TEXT NOT NULL,
     rpmdb_val TEXT NOT NULL);
sA CREATE INDEX i_pkgkey_rpmdb ON pkg_rpmdb (pkgtupid, rpmdb_key);
s� CREATE TABLE pkg_yumdb (
     pkgtupid INTEGER NOT NULL REFERENCES pkgtups,
     yumdb_key TEXT NOT NULL,
     yumdb_val TEXT NOT NULL);
sA CREATE INDEX i_pkgkey_yumdb ON pkg_yumdb (pkgtupid, yumdb_key);
cCs�|j�stSt|d�r&|jS|j�}|dkrBtSt|d�x:|D]}PqVWx|jD]}|j|�qkW|j	�t
|_t
S(s3 Update to version 3 of history, rpmdb/yumdb data. t_cached_updated_3sPRAGMA table_info(pkg_yumdb)N(R=RR?R�RRRt
_update_ops_3texecuteRR"(R3Rtobtop((s//usr/lib/python2.7/site-packages/yum/history.pyRz�s


	s� CREATE TABLE trans_skip_pkgs (
     tid INTEGER NOT NULL REFERENCES trans_beg,
     pkgtupid INTEGER NOT NULL REFERENCES pkgtups);
sk CREATE TABLE trans_cmdline (
     tid INTEGER NOT NULL REFERENCES trans_beg,
     cmdline TEXT NOT NULL);
s� CREATE TABLE trans_rpmdb_problems (
     rpid INTEGER PRIMARY KEY,
     tid INTEGER NOT NULL REFERENCES trans_beg,
     problem TEXT NOT NULL, msg TEXT NOT NULL);
s� CREATE TABLE trans_prob_pkgs (
     rpid INTEGER NOT NULL REFERENCES trans_rpmdb_problems,
     pkgtupid INTEGER NOT NULL REFERENCES pkgtups,
     main BOOL NOT NULL DEFAULT FALSE);
s' CREATE VIEW vtrans_data_pkgs AS
     SELECT tid,name,epoch,version,release,arch,pkgtupid,
            state,done,
            name || '-' || epoch || ':' ||
            version || '-' || release || '.' || arch AS nevra
     FROM trans_data_pkgs JOIN pkgtups USING(pkgtupid)
     ORDER BY name;
s CREATE VIEW vtrans_with_pkgs AS
     SELECT tid,name,epoch,version,release,arch,pkgtupid,
            name || '-' || epoch || ':' ||
            version || '-' || release || '.' || arch AS nevra
     FROM trans_with_pkgs JOIN pkgtups USING(pkgtupid)
     ORDER BY name;
s CREATE VIEW vtrans_skip_pkgs AS
     SELECT tid,name,epoch,version,release,arch,pkgtupid,
            name || '-' || epoch || ':' ||
            version || '-' || release || '.' || arch AS nevra
     FROM trans_skip_pkgs JOIN pkgtups USING(pkgtupid)
     ORDER BY name;
s� CREATE VIEW vtrans_prob_pkgs2 AS
     SELECT tid,rpid,name,epoch,version,release,arch,pkgtups.pkgtupid,
            main,problem,msg,
            name || '-' || epoch || ':' ||
            version || '-' || release || '.' || arch AS nevra
     FROM (SELECT * FROM trans_prob_pkgs,trans_rpmdb_problems WHERE
           trans_prob_pkgs.rpid=trans_rpmdb_problems.rpid)
           JOIN pkgtups USING(pkgtupid)
     ORDER BY name;
cCs�|jjstSt|d�r&|jS|j�}|dkrBtSt|d�x:|D]}PqVWx|jD]}|j	|�qkW|j
�t|_tS(s; Update to version 2 of history, includes trans_skip_pkgs. t_cached_updated_2s"PRAGMA table_info(trans_skip_pkgs)N(R�R�RR?R�RRRt
_update_ops_2R�RR"(R3RR�R�((s//usr/lib/python2.7/site-packages/yum/history.pyR=/s


	cCsytjd�|_d|jjd|jdf}|j|kr�tj||d�tjj	|d�r�tj|d|d�q�n||_|jj
s�tStjj	|j�s�tj|jtj
d�}tj|�n|j�}d	d
ddd
dddg}x|D]}|j|�qWx|jD]}|j|�q3Wx|jD]}|j|�qTW|j�tS(s6 Create a new history DB file, populating tables etc. s%Y-%m-%ds%s/%s-%s.%sR`Rs.olds-journals-journal.oldi�s� CREATE TABLE trans_beg (
     tid INTEGER PRIMARY KEY,
     timestamp INTEGER NOT NULL, rpmdb_version TEXT NOT NULL,
     loginuid INTEGER);
s� CREATE TABLE trans_end (
     tid INTEGER PRIMARY KEY REFERENCES trans_beg,
     timestamp INTEGER NOT NULL, rpmdb_version TEXT NOT NULL,
     return_code INTEGER NOT NULL);
s� CREATE TABLE trans_with_pkgs (
     tid INTEGER NOT NULL REFERENCES trans_beg,
     pkgtupid INTEGER NOT NULL REFERENCES pkgtups);
s� CREATE TABLE trans_error (
     mid INTEGER PRIMARY KEY,
     tid INTEGER NOT NULL REFERENCES trans_beg,
     msg TEXT NOT NULL);
s� CREATE TABLE trans_script_stdout (
     lid INTEGER PRIMARY KEY,
     tid INTEGER NOT NULL REFERENCES trans_beg,
     line TEXT NOT NULL);
s� CREATE TABLE trans_data_pkgs (
     tid INTEGER NOT NULL REFERENCES trans_beg,
     pkgtupid INTEGER NOT NULL REFERENCES pkgtups,
     done BOOL NOT NULL DEFAULT FALSE, state TEXT NOT NULL);
s� CREATE TABLE pkgtups (
     pkgtupid INTEGER PRIMARY KEY,     name TEXT NOT NULL, arch TEXT NOT NULL,
     epoch TEXT NOT NULL, version TEXT NOT NULL, release TEXT NOT NULL,
     checksum TEXT);
sO CREATE INDEX i_pkgtup_naevr ON pkgtups (name, arch, epoch, version, release);
(RLtstrftimeRR�R�R�R�trenameR�R�R�RR[tO_CREATRRR�R�R�RR"(R3R�RbRtopsR�((s//usr/lib/python2.7/site-packages/yum/history.pyRIs@
		

N(<RPRQRRt_history_dirRR5RRRRRR"R#R'R+RR,R.R�R9R<R>R@RBRJRKRRRTRXR�R�RpRcRjR�R�R�R�R�R�RwRxR{RmRDR}R~RR�R�R�R�R�R�R�R�RzR�R=R(((s//usr/lib/python2.7/site-packages/yum/history.pyR��s�<					!		
				*	!					)	
					
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 
(-RLR�tos.pathRR�RzRtsqlutilsRRRtyum.miscR t
yum.constantsRtyum.packagesRRRtyum.i18nRR	t
rpmUtils.archR
R�t	TS_UPDATEt
TS_UPDATEDR4R0R1tTS_OBSOLETEDt
TS_OBSOLETINGR6R�RRR0R1RTRvRyR�R�R�R�(((s//usr/lib/python2.7/site-packages/yum/history.pyt<module>sX




'0D	 S�?����

Zerion Mini Shell 1.0