Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/apt/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/apt/debfile.pyc


WRc@sdZddlZddlZddlZddlZddlZddlZddlmZddl	m	Z	de
fdYZdefdYZ
d	e
fd
YZdZedkrendS(
s;Classes for working with locally available Debian packages.iN(tgettext(tStringIOtNoDebArchiveExceptioncBseZdZRS(s9Exception which is raised if a file is no Debian archive.(t__name__t
__module__t__doc__(((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRst
DebPackagecBseZdZed\ZZZZdZd!d!dZ
dZdZe
dZe
dZedZd	Zd
ZdZdZe
d
Ze
dZe
dZe
dZdZdZdZedZdZdZ dZ!e
dZ"e
dZ#e$dZ%e$dZ&eedZ'dZ(dZ)dZ*d!d Z+RS("sA Debian Package (.deb file).iicCs}|dkrtj}n||_d|_d|_i|_g|_t|_	d|_
d|_|ry|j|ndS(Nt(
tNonetapttCachet_cachet_debfiletpkgnamet	_sectionst
_need_pkgstFalset_check_was_runt_failure_stringt
_multiarchtopen(tselftfilenametcache((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt__init__-s								cCs|jdd|g|_t|_d|_||_tj|j|_|jj	j
d}tj||_
|j
d|_t|_dS(s open given debfile is	open '%s'RtcontroltPackageN(t_dbgRtsett_installed_conflictsRRtapt_insttDebFileRRtextractdatatapt_pkgt
TagSectionRR
RR(RRR((s//usr/lib/python2.7/dist-packages/apt/debfile.pyR;s			cCs|j|S(N(R(Rtkey((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt__getitem__HscsOgy |jjjfdWn"tk
rJtd|jgSXS(s$return the list of files in the deb.csj|jS(N(tappendtname(titemtdata(tfiles(s//usr/lib/python2.7/dist-packages/apt/debfile.pyt<lambda>Pss(List of files for '%s' could not be read(RR(tgotSystemErrort_R(R((R)s//usr/lib/python2.7/dist-packages/apt/debfile.pytfilelistKs 
	csUgy |jjjfdWn"tk
rJtd|jgSXtS(s, return the list of files in control.tar.gt csj|jS(N(R%R&(R'R((R(s//usr/lib/python2.7/dist-packages/apt/debfile.pyR*[ss0List of control files for '%s' could not be read(RRR+R,R-Rtsorted(R((Rs//usr/lib/python2.7/dist-packages/apt/debfile.pytcontrol_filelistVs 
	cCs|js
|S|jj|r#|S||jkrO|j|jjdkrO|Sd||jf}||jkru|S|j|jj}|j|j@r|S|r|j|j@r|S|S(Ntalls%s:%s(	RRtis_virtual_packaget	candidatetarchitecturet_candt
multi_archtMULTI_ARCH_FOREIGNtMULTI_ARCH_SAME(RR
tin_conflict_checkingtmultiarch_pkgnametcand((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt_maybe_append_multiarch_suffixcs"	c	CsL|jdd|x1|D])}|d}|d}|d}|j|}||jkr|jj|r|jdd|x*|jj|D]}|jrtSqWqqn|j|j}|d	k	rt	j
|j||rtS|sxM|jj|dtD]0}|jr
|jdd|j|ftSq
WqqWt
S(
sReturn True if at least one dependency of the or-group is satisfied.

        This method gets an 'or_group' and analyzes if at least one dependency
        of this group is already satisfied.
        is_checkOrGroup(): %s iiis+_is_or_group_satisfied(): %s is virtual deptinclude_nonvirtuals'found installed '%s' that provides '%s'N(RR<RR2tget_providing_packagestis_installedtTruet	installedRR!t	check_deptversionR&R(	Rtor_grouptdeptdepnametvertopertpkgtinsttppkg((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt_is_or_group_satisfieds.



	$	c
Csx|D]}|\}}}|j|}||jkr|jj|sRqn|jj|}t|dkr|qn|dj}n|j|}|jjj|j}|sqnt	j
|j||sqn|jdd||j
j|tSWd}	xn|D]f}|	|d7}	|rP|rP|	d|d|df7}	n||t|dkr|	d7}	qqW|jtd|	7_tS(	sTry to satisfy the or_group.iiisNeed to get: %sRs (%s %s)t|s"Dependency is not satisfiable: %s
(R<RR2R>tlenR&t	_depcachetget_candidate_vert_pkgR!RBtver_strRRR%R@RR-R(
RRDRERFRGRHt	providersRIR;tor_str((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt_satisfy_or_groups8


cCs|jdd|||f|j|}|jrB|jj}n|jrZ|jj}ntStj	|||r|j
|||r|jtd|j
7_|jdd|j
tStS(s@Return True if a pkg conflicts with a real installed/marked pkg.is8_check_single_pkg_conflict() pkg='%s' ver='%s' oper='%s's)Conflicts with the installed package '%s's!conflicts with installed pkg '%s'(RRR?RARCtmarked_installR3RR!RBtreplaces_real_pkgRR-R&R@(RR
RGRHRItpkgver((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt_check_single_pkg_conflicts
		cCsA|jdd|x|D]}|d}|d}|d}|j|dt}||jkr|jj|rx|jj|D]s}|jdd|j|j|jkr|jddqn|j|j||r|j	j
|jqqWqqn|j|||r|j	j
|qqWt|j	S(	s5Check the or-group for conflicts with installed pkgs.is _check_conflicts_or_group(): %s iiR9isconflicts virtual check: %ssconflict on self, ignoring(RR<R@RR2R>R&R
RYRtaddtbool(RRDRERFRGRHRI((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt_check_conflicts_or_groups*



	cCs7d}ytj|j|SWntk
r2gSXdS(s4List of package names conflicting with this package.t	ConflictsN(R!t
parse_dependsRtKeyError(RR#((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt	conflictss

cCsPg}xCdD];}y!|jtj|j|Wq
tk
rGq
Xq
W|S(s7List of package names on which this package depends on.tDependssPre-Depends(RasPre-Depends(textendR!R^RR_(RtdependsR#((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRcs
!
cCs7d}ytj|j|SWntk
r2gSXdS(s<List of virtual packages which are provided by this package.tProvidesN(R!R^RR_(RR#((s//usr/lib/python2.7/dist-packages/apt/debfile.pytprovides#s

cCs7d}ytj|j|SWntk
r2gSXdS(s4List of packages which are replaced by this package.tReplacesN(R!R^RR_(RR#((s//usr/lib/python2.7/dist-packages/apt/debfile.pytreplaces,s

cCs|jdd|||f|j|}|jrB|jj}n|jrZ|jj}nd}xd|jD]Y}xP|D]H\}}}||krwt	j
|||rw|jdd|tSqwWqjWtS(sReturn True if a given non-virtual package is replaced.

        Return True if the deb packages replaces a real (not virtual)
        packages named (pkgname, oper, ver).
        isreplaces_real_pkg() %s %s %ss?we have a replaces in our package for the conflict against '%s'N(
RRR?RARCRVR3RRgR!RBR@R(RR
RHRGRIRXRDR&((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRW5s
		!cCs6t}x)|jD]}|j|rt}qqW|S(sCheck if there are conflicts with existing or selected packages.

        Check if the package conflicts with a existing or to be installed
        package. Return True if the pkg is OK.
        (R@R`R\R(RtresRD((s//usr/lib/python2.7/dist-packages/apt/debfile.pytcheck_conflictsKs

cCs;tt|j}tt|dd}|jd}|jd}g|jD]}|dd^qR}xt|jD]\}}||dkr|jjj	t||dn|j
sq|n|jj}	x|j
jD]}
x|
jD]}|j|jkrtj||j|js|jdd|j|jtd	i|jd
6|jd6|jd6|jd
67_|jjjtSqqWqWd|	jkr|xs|	jdD]a}xX|D]P}
|
jj|jkr|
jj|krtj||
j|
jr|jdd|j|jtdi|jd
6|
jjd6|
jd6|
jd67_|jjjtSn|
jj|kr|j|jkr|jdd||jtdidj |d6|j!d6|
jjd6|jd
67_|jjjtSqWqWq|q|W|jjjt"S(s 
        check if installing the package would break exsisting 
        package on the system, e.g. system has:
        smc depends on smc-data (= 1.4)
        and user tries to installs smc-data 1.6
        i2itVersiontArchitectureigY@iswould break (depends) %ss]Breaks existing package '%(pkgname)s' dependency %(depname)s (%(deprelation)s %(depversion)s)R
RFtdeprelationt
depversionR]swould break (conflicts) %ssZBreaks existing package '%(pkgname)s' conflict: %(targetpkg)s (%(comptype)s %(targetver)s)t	targetpkgtcomptypet	targetvers{Breaks existing package '%(pkgname)s' that conflict: '%(targetpkg)s'. But the '%(debfile)s' provides it via: '%(provides)s't,Retdebfile(#tfloatRNRtmaxtintRRet	enumeratetop_progresstupdateR?RQtcurrent_verRAtdependenciestor_dependenciesR&R
R!RBtrelationRCRRR-tdoneRtdepends_listt
target_pkgR4t	comp_typet
target_vertjoinRR@(RtsizetstepstdebvertdebarchtxRetiRIRGtdep_orREtconflicts_ver_listtc_or((s//usr/lib/python2.7/dist-packages/apt/debfile.pytcheck_breaks_existing_packagesYs`

$$	



'




cCs%|jdd|jd}|jd}|jdd|||jkr|ry|j|jry|j|jj}n4|r|j|jr|j|jj}n|jS|d	k	rtj	||}|jdd||dkr|j
S|dkr|jS|dkr|jSqn|jS(
s	Compare the package to the version available in the cache.

        Checks if the package is already installed or availabe in the cache
        and if so in what version, returns one of (VERSION_NONE,
        VERSION_OUTDATED, VERSION_SAME, VERSION_NEWER).
        itcompare_to_version_in_cacheRRjis
debver: %ss"CompareVersion(debver,instver): %siN(
RRRRARCR3tVERSION_NONERR!tversion_comparetVERSION_SAMEt
VERSION_NEWERtVERSION_OUTDATED(Rt
use_installedR
Rtcachevertcmp((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRs(


cCs|jddt|_d|jkrK|jddtd|_tS|jd}|dkr|tjj	dkr|tj
kr||_d	|j|jf|_|jdd
|q|jddtd||_tSn|j
|jkr/|j|jjr/td
|_tSnd|_|jsHtS|jsXtS|j|jsntS|js~tS|jjjdkrtd|_|jjtStS(s$Check if the package is installable.itcheckRkisERROR: no architecture fields$No Architecture field in the packageR1sAPT::Architectures%s:%ssFound multiarch arch: '%s'sERROR: Wrong architecture dude!sWrong architecture '%s's$A later version is already installedRis1Failed to satisfy all dependencies (broken cache)(RR@RRR-RRR!tconfigtfindtget_architecturesRR
RRRRARiRt_satisfy_dependsRcROtbroken_counttclear(Rtarch((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRsB	
$		
cCs|jtj|S(s-Satisfy the dependencies in the given string.(RR!R^(Rt
dependsstr((s//usr/lib/python2.7/dist-packages/apt/debfile.pytsatisfy_depends_strscCsytj|jj}Wntk
r,nXx3|D]+}|j|s4|j|s_tSq4q4Wxa|jD]V}y|j|j	dtWqmt
k
rtd||_|jj
tSXqmWtS(sSatisfy the dependencies.t	from_usersCannot install '%s'(R!tActionGroupRROtAttributeErrorRLRURRtmark_installR,R-RRR@(RRct_actiongroupRDRI((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRs 



	cCs6|jdd|j|js/tdn|jS(sReturn missing dependencies.isInstalling: %ss-property only available after check() was run(RRRR(R((s//usr/lib/python2.7/dist-packages/apt/debfile.pytmissing_depss	cCsg}g}g}|js*tdnx|jD]}|jsL|jr|j|jt}x!|jj	D]}||j
O}qoW|s|j|jqn|jr4|j|jq4q4W|||fS(sGet the changes required to satisfy the dependencies.

        Returns: a tuple with (install, remove, unauthenticated)
        s-property only available after check() was run(RRRRVtmarked_upgradeR%R&RR3toriginsttrustedt
marked_delete(RtinstalltremovetunauthenticatedRIt
authenticatedtorigin((s//usr/lib/python2.7/dist-packages/apt/debfile.pytrequired_changess 		cCsXd}xKt|D]=\}}|ddkr<|d7}n|dt|7}qW|S(NRiPis
s%2.2x (Rvtord(tin_datathexRtc((s//usr/lib/python2.7/dist-packages/apt/debfile.pytto_hex-s
cCsd}t|tkrgx|D]A}t|dksIt|dkrV|d7}q||7}qWnFxC|D];}|dks|dkr|d7}qn|t|7}qnW|S(NRi
it (ttypetstrRtchr(RtsRtb((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt	to_strish6s
$


c	Cs|jdr|d}n|j|}|jdr}|r}t|}tjd|}td}||j7}nyt|d}Wn1t	k
rtd}||j
|7}|SX|S(Ns./is.gztfileobjsAutomatically decompressed:

sutf-8s,Automatically converted to printable ascii:
(t
startswithR tendswithRtgziptGzipFileR-treadtunicodet	ExceptionR(	RtpartR&tauto_decompresstauto_hexR(tiotgztnew_data((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt_get_contentIs

cCs3y|j|jj|SWntk
r.dSXdS(s6 return the content of a specific control.tar.gz file RN(RRRtLookupError(RR&((s//usr/lib/python2.7/dist-packages/apt/debfile.pytcontrol_content\s
cCs3y|j|jj|SWntk
r.dSXdS(s6 return the content of a specific control.tar.gz file RN(RRR(R(RR&((s//usr/lib/python2.7/dist-packages/apt/debfile.pytdata_contentcs
cCs#||jkrtj|IJndS(s%Write debugging output to sys.stderr.N(tdebugtsyststderr(Rtleveltmsg((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRjscCs|dkr+tjtjddd|jSy|jWntk
rV|jnX|j|j}y|j	Wntk
r|j
nX|SdS(sInstall the package.tdpkgs-iN(RtostspawnlptP_WAITRtstart_updateRtstartUpdatetrunt
finish_updatetfinishUpdate(Rtinstall_progressRh((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRos

N(,RRRtrangeRRRRRRRRR$tpropertyR.R0RR<RLRURYR\R`RcReRgRWRiRR@RRRRRRtstaticmethodRRRRRRR(((s//usr/lib/python2.7/dist-packages/apt/debfile.pyR!sB	
		*	,		 						@	:						t
DscSrcPackagecBsMeZdZdddZedZedZdZdZ	RS(s#A locally available source package.cCsrtj|d|||_g|_g|_t|_d|_g|_	|jdk	rn|j
|jndS(NR(RRRRt_dependst
_conflictsRRR
tbinariesR(RRR((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRs					cCs|jS(s&Return the dependencies of the package(R(R((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRcscCs|jS(s&Return the dependencies of the package(R(R((s//usr/lib/python2.7/dist-packages/apt/debfile.pyR`sc	Csyddg}ddg}t|}tj|}zx|D]}x=|D]5}||krbqJn|jjtj||qJWx=|D]5}||krqn|jjtj||qWd|kr|d|_nd|kr|djd|_	nd|kr=|d|j
d<q=q=WWd	~|jXtd
|jdj
|j	f}||j
d<t|_d	S(
sOpen the package.s
Build-DependssBuild-Depends-IndepsBuild-ConflictssBuild-Conflicts-IndeptSourcetBinarys, RjNsBInstall Build-Dependencies for source package '%s' that builds %s
RtDescription(RR!tTagFileRRbtparse_src_dependsRR
tsplitRRtcloseR-RRR(	Rtfiletdepends_tagstconflicts_tagstfobjttagfiletsecttagR((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRs6

!
!	
cCsu|js\xM|jD]?}|j|jjrDttdn|j|jqWnt|_	|j
|jS(s%Check if the package is installable..s%An essential package would be removed(RiRRRQt	essentialRR-tmark_deleteR@RRRc(RR
((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRs	N(
RRRRRRRcR`RR(((s//usr/lib/python2.7/dist-packages/apt/debfile.pyRs	 c	Cs"ddlm}ddlm}|}d}d||j|fGH|j|}d|GHx|D]}d|jGHqfWttj	d|}d	|j
GH|jsd
GH|jGHnd|j
GH|jGH|jGHdGH|j|}|GHtd
|}d}|jtj|GHdS(s
Test functioni(R
(tInstallProgressswww-browsers%s virtual: %ssProviders for %s :s %sisDeb: %sscan't be satifiedsmissing deps: %ssInstalling ...Rs:libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)N(t	apt.cacheR
tapt.progress.baseRR2R>R&RRtargvR
RRRRR.RRRR!R^(	R
RRtvpRSRItdtretR((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt_tests.		
t__main__(RR	RR!RRRRR-RtIOErrorRtobjectRRRR(((s//usr/lib/python2.7/dist-packages/apt/debfile.pyt<module>s `E	%