Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/apport/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/apport/packaging_impl.pyc


Yc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZejdde
ddlZddlZddlmZdefdYZeZdS(syapport.PackageInfo class implementation for python-apt and dpkg.

This is used on Debian and derivatives such as Ubuntu.
iNtignoresapt API not stable yet(tPackageInfot__AptDpkgPackageInfocBsIeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZed!dZedZdZdZd!dZdZdZed!dZdZdZdZ dZ!dZ"edZ#dZ$d Z%RS("sConcrete apport.PackageInfo class implementation for python-apt and
    dpkg, as found on Debian and derivatives such as Ubuntu.cCs1d|_d|_d|_d|_d|_dS(Ns/etc/default/apport(tNonet
_apt_cachet_sandbox_apt_cachet
_contents_dirt_mirrort
configuration(tself((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt__init__s
				cCsDy,|jr+ddl}|j|jnWntk
r?nXdS(Ni(RtshutiltrmtreetAttributeError(R	R((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt__del__%s	
cCssd|_|jsly.tjjj}tj|dd|_Wqltk
rhtjdd|_qlXn|jS(s(Return apt.Cache() (initialized lazily).trootdirt/N(	RRRtapttprogresstbaset
OpProgresstCacheR
(R	R((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt_cache-s		
cCsd|_|js|j||tjj|}tjd||_y|jj	|Wn+tj
jk
r}tt
|nX|jjn
|jj|jS(sBuild apt sandbox and return apt.Cache(rootdir=) (initialized lazily).

        Clear the package selection on subsequent calls.
        RN(RRRt_build_apt_sandboxtostpathtabspathRRtupdatetcachetFetchFailedExceptiontSystemErrortstrtopentclear(R	taptroottapt_sourcest
fetchProgressRte((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt_sandbox_cache;s		
cCs6y|j|SWntk
r1tdnXdS(suReturn apt.Cache()[package] (initialized lazily).

        Throw a ValueError if the package does not exist.
        spackage does not existN(RtKeyErrort
ValueError(R	tpackage((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt_apt_pkgOs
cCs4|j|}|j}|s-tdn|jS(s*Return the installed version of a package.spackage does not exist(R*t	installedR(tversion(R	R)tpkgtinst((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_versionYs
	cCs|j|jjS(s1Return the latest available version of a package.(R*t	candidateR,(R	R)((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_available_versionbscCsb|j|jj}|sgSg|jjdg|jjdgD]}|djj^qHS(s/Return a list of packages a package depends on.tDependst
PreDependsi(R*t_pkgtcurrent_vertdepends_listtgett
target_pkgtname(R	R)tcur_vertd((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_dependenciesgs
cCs^|j|jr%|j|jjS|j|jrJ|j|jjStd|dS(s-Return the source package name for a package.spackage %s does not existN(R*R+tsource_nameR0R((R	R)((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt
get_sourceqs
cCsO|j|j}|s'tdnx!|jD]}|jr1|jSq1WdS(sReturn package origin.

        Return the repository name from which a package was installed, or None
        if it cannot be determined.

        Throw ValueError if package is not installed.
        spackage is not installedN(R*R+R(toriginstoriginR(R	R)R-R@((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_package_origin{s	c
	CsItjdddgdtj}|jdjj}|jdksRt|j|}|j	r|j	j
dkrtS|g}xwt
j
dD]f}yLt|:}x0|D](}|j}|r|j|qqWWdQXWqtk
rqXqW|jrE|jjrEx*|jjD]}	|	j|kr%tSq%WntS(saCheck if a package is a genuine distro package (True) or comes from
        a third-party source.tlsb_releases-is-ststdoutis/etc/apport/native-origins.d/*N(t
subprocesstPopentPIPEtcommunicatetdecodetstript
returncodetAssertionErrorR*R+R,RtFalsetglobR tappendtIOErrorR0R?R@tTrue(
R	R)RBtthis_osR-tnative_originstftfdtlineto((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytis_distro_packages,	

cCsj|j|jr+|j|jjp*dS|j|jrV|j|jjpUdStd|dS(sReturn the architecture of a package.

        This might differ on multiarch architectures (e. g.  an i386 Firefox
        package on a x86_64 system)tunknownspackage %s does not existN(R*R+tarchitectureR0R((R	R)((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_architectures
cCsQ|jd|g}|dkr%dSg|jD]}|jds2|^q2S(s*Return list of files shipped by a package.s-LtdivertedN(t
_call_dpkgRt
splitlinest
startswith(R	R)tlistRS((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt	get_filessc

Csd||jf}tjj|s5d|}nyCtj|}tj|jsbtnt|j	|j
}Wntk
rgSXd}d||jf}tjj|sd|}tjj|sgSnt|}x|D]}yd|krtj
d|wn|j}	|	sGtj
d|wntjd	|	d
}t|j	|j
|krwnWntk
rnX||7}qWWdQX|r|j|SgSdS(s/Return list of all modified files of a package.s/var/lib/dpkg/info/%s:%s.lists/var/lib/dpkg/info/%s.listts /var/lib/dpkg/info/%s:%s.md5sumss/var/lib/dpkg/info/%s.md5sumsts(%s contains NUL character, ignoring lines%%s contains empty line, ignoring lineRiN(tget_system_architectureRRtexistststattS_ISREGtst_modetOSErrortmaxtst_mtimetst_ctimeR tapporttwarningtsplitt_check_files_md5(
R	R)tlistfiletstmax_timetsumstsumfileRTRUtwords((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_modified_filessF
	





cCstjddd|gdtjdt}|jdj}|jdkrSiSi}x|jD]}|sxqfn|jj	d \}}t
jj|rt
|d}|j}	Wd	QXtj}
|
j|	|
j}||kr|	||<qqfd
||<qfW|S(s?Return modified configuration files of a package.

        Return a file name -> file contents map of all configuration files of
        package. Please note that apport.hookutils.attach_conffiles() is the
        official user-facing API for this, which will ask for confirmation and
        allows filtering.
        s
dpkg-querys-Ws--showformat=${Conffiles}RCt	close_fdsiitrbNs	[deleted](RDRERFRPRGRHRJR]RIRnRRRdR treadthashlibtmd5Rt	hexdigest(R	R)tdpkgtouttmodifiedRURtdefault_md5sumRTtcontentstmtcalculated_md5sum((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_modified_conffiless(
cCsd}d}d}x|r|t|krtjdddd|g||||!dtjdtjd	tjd
t}|jdjd}|jdkr|}n||7}qW|S(
ssCall fgrep for a pattern on given file list and return the first
        matching file, or None if no file matches.iditfgreps-lxmt1s--tstdinRCtstderrRwsUTF-8N(	RtlenRDRERFRPRGRHRJ(R	tpatternt	file_listtmatcht
slice_sizetitpR~((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt
__fgrep_filess	c
Cstjdd|gdtjdtj}|jdjd}|jdkr{|r{|jd}|dkr{|Sntjj	tjj
|dj}g}g}	xtjd	D]p}
tjj	tjj
|
djjd
d}||ks||kr"|	j
|
q|j
|
qW|j||	}|s`|j||}n|rtjj	tjj
|djd
dS|r|j||SdSdS(sReturn the package a file belongs to, or None if the file is not
        shipped by any package.

        If uninstalled is True, this will also find files of uninstalled
        packages; this is very expensive, though, and needs network access and
        lots of CPU and I/O resources. In this case, map_cachedir can be set to
        an existing directory which will be used to permanently store the
        downloaded maps. If it is not set, a temporary directory will be used.
        s/usr/sbin/dpkg-diverts--listRCRisUTF-8ishardening-wrappers/var/lib/dpkg/info/*.listt:N(RDRERFRGRHRJRnRRtsplitexttbasenametlowerRMRNt _AptDpkgPackageInfo__fgrep_filest_search_contentsR(
R	tfiletuninstalledtmap_cachedirR}R~R-tfnamet	all_liststlikely_listsRSRR((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_file_package's.(5-cCs_tjddgdtj}|jdjj}|jdksOt|s[t|S(scReturn the architecture of the system, in the notation used by the
        particular distribution.R}s--print-architectureRCi(RDRERFRGRHRIRJRK(tklassR}tarch((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyRcRscCsWtjddgdtj}|jdjj}|jdksOtd|S(sReturn a list of default library search paths.

        The entries should be separated with a colon ':', like for
        $LD_LIBRARY_PATH. This needs to take any multiarch directories into
        account.
        sdpkg-architectures-qDEB_HOST_MULTIARCHRCis/lib/%s:/lib(RDRERFRGRHRIRJRK(R	R}tmultiarch_triple((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_library_paths^s
cCs
||_dS(sExplicitly set a distribution mirror URL for operations that need to
        fetch distribution files/packages from the network.

        By default, the mirror will be read from the system configuration
        files.N(R(R	turl((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt
set_mirrorlsc
Csddd|g}|r/|dcd|7<ny,tj|dtjd|dkrZdSWntk
rodSXd}xEtjtjj||d	D]!}tjj	|r|}qqW|st
d
y/tjddtd|dtjd
tjWntk
rnX|S(sDownload given source package and unpack it into dir (which should
        be empty).

        This also has to care about applying patches etc., so that dir will
        eventually contain the actually compiled source.

        If version is given, this particular version will be retrieved.
        Otherwise this will fetch the latest available version.

        Return the directory that contains the actual source root directory
        (which might be a subdirectory of dir). Return None if the source is
        not available.sapt-gets--assume-yestsourceit=RCtcwdis-*s.could not determine source tree root directorysdebian/rules patch || debian/rules apply-patches || debian/rules apply-dpatches || debian/rules unpack || debian/rules patch-stamp || debian/rules setuptshellRN(RDtcallRFRRhRMRRtjointisdirRKRP(R	t
srcpackagetdirR,targvtrootR;((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_source_treeus*
)

cCsdtjdS(sReturn the actual Linux kernel package name.

        This is used when the user reports a bug against the "linux" package.
        slinux-image-i(Rtuname(R	((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytget_kernel_packagescCsddl}ddl}g}g}|djd}|d}|djd}d|}	|j}
|	|
kr|
|	jr||fS|jjdd	}d
|	||f}d|}
ttj	j
||d}|j|
}|jd
krdSx0t
r7|jd}|s'Pn|j|qW|jtjddtj	j
||g}|dkr|j|jddn||fS(sInstall kernel debug package

        Ideally this would be just another package but the kernel is
        special in various ways currently so we can not use the apt
        method.
        iNtUnameitArchitecturetPackageslinux-image-debug-%ssDir::Cache::archivess/partials
%s_%s_%s.ddebs,http://ddebs.ubuntu.com/pool/main/l/linux/%stwiRatlinuxiiR}s-iit_(Raslinuxi (turllibtapt_pkgRnRtisInstalledtConfigtFindDirR RRRturlopentgetcodeRPRytwritetflushRDRRN(R	treportRRR+toutdatedtkverRtvert
debug_pkgnametct
target_dirtdebRR~tutblocktret((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt_install_debug_kernels6



	
'c	Cs(|sd}ntjj||d}tjj|sLtd|n|rt}|rytjj||d}	ntjj|dd}	ytj|	Wqtk
rqXnt}t	j
}	|rtjj
j}
ntjjj}
|s|j|	||
}nw|j|	|tjdtjj|	}y|j|
Wn+tjjk
r}tt|nX|jd}
t}x[|D]S\}}y||j}Wntk
rd}nX|sd|}|
|d	7}
tj|qn|rG|j|krGd
|||jf}|
|d	7}
n|j ||j!dkr|d|kr|j |dq|d
|kr|j |d
||d
jj|jkr|
d||j||d
jjf7}
qqqqWx"|D]}||j"ttqWtj#j$|
}y|j%d|Wn<tjjk
r}tj&dt|t'j(dnX|rdGHnxY|j)D]N}t*j+dd|j,|g|j-tjj.|j,j/dddqW|rt0j1|	n|s$t2ddj||
S(sGInstall packages into a sandbox (for apport-retrace).

        In order to work without any special permissions and without touching
        the running system, this should only download and unpack packages into
        the given root directory, not install them into the system.

        configdir points to a directory with by-release configuration files for
        the packaging system; this is completely dependent on the backend
        implementation, the only assumption is that this looks into
        configdir/release/, so that you can use retracing for multiple
        DistroReleases. As a special case, if configdir is None, it uses the
        current system configuration, and "release" is ignored.

        release is the value of the report's 'DistroRelease' field.

        packages is a list of ('packagename', 'version') tuples. If the version
        is None, it should install the most current available version.

        If cache_dir is given, then the downloaded packages will be stored
        there, to speed up subsequent retraces.

        Return a string with outdated packages, or None if all packages were
        installed.

        If something is wrong with the environment (invalid configuration,
        package servers down, etc.), this should raise a SystemError with a
        meaningful error message.
        s/etc/apt/sources.listssources.lists%s does not existRtsystemRRas#package %s does not exist, ignorings
s+%s version %s required, but %s is availabletalls-dbgs-dbgsymsKoutdated debug symbol package for %s: package version %s dbgsym version %s
tfetchers+Package download error, try again later: %sicsExtracting downloaded debs...R}s-xRiis*apt fetcher did not fetch these packages: t N(3RRRRdRRLtmakedirsRhRPttempfiletmkdtempRRttexttAcquireProgressRR&RRRRRRRR tsetR0R'RRlRmR,taddRYtmark_installRtAcquiretfetch_archivesterrortsystexittitemsRDt
check_calltdestfiletremoveRRnRRRK(R	Rt	configdirtreleasetpackagestverboset	cache_dirR#ttmp_aptrootR"R$RR%tobsoletet	real_pkgsR-RR0RRRRR((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytinstall_packagess	

	




/
0
cCstjj|jj|S(s2Return known package names which match given glob.(RMtfnmatchtfilterRtkeys(R	tnameglob((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytpackage_name_globJscCsgtjdg|dtjdtj}|jtdjd}|jdkrW|StddS(sRCall dpkg with given arguments and return output, or return None on
        error.R}RCRisUTF-8spackage does not existN(RDRERFRGtinputRHRJR((R	targsR}R~((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyR\SscCs1tjj|rmtjdd|gdtjdtjdtdddi}|jd	jd
d}natjddgdtjdtjdtjdtdddi}|j|d	jd
d}|j	d	krgSg}xC|j
D]5}|jd
r|j|j
ddd	qqW|S(sInternal function for calling md5sum.

        This is separate from get_modified_files so that it is automatically
        testable.s/usr/bin/md5sums-cRCRRwRRtenviterrorstreplaceRtFAILEDRi(RRRdRDRERFRPRGRHRJR]tendswithRNtrsplit(R	RtRR~t
mismatchestl((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyRo_s $cCs|jsxutdD]X}|j}t|dkr|ddkr|djdr|d|_PqqWtdn|jS(sReturn the distribution mirror URL.

        If it has not been set yet, it will be read from the system
        configuration.s/etc/apt/sources.listiiRishttp://sXcannot determine default mirror: /etc/apt/sources.list does not contain a valid deb line(RR RnRR^R(R	Rtfields((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt_get_mirror{s	5
cCsx|r|}n$|js*tj|_n|j}|j}tjj|d|}y,tj|}tt	j	|j
}Wntk
rd
}nX|d
ks|dkrt
jddgdt
j}|jdjdj}	|jdkstd|j|	|f}
yd	d
lm}Wn!tk
rXd	d
lm}nX||
}t|d:}
x0tr|jd}|sPn|
j|qzWWd
QX|jtjj|stn|j dr|d}nd
}t
jddd||gdt
jdt
j}|jdjd}|rt|j!dj!ddj!dd	}n|S(s4Internal function for searching file in Contents.gz.sContents-%s.gziQRBs-scRCisUTF-8s%s/dists/%s/Contents-%s.gzi(Rtwbi@BNRitzgreps-m1s^%s[[:space:]]Rt,("RRRRcRRRRetintttimeRjRhRRDRERFRGRHRIRJRKRturllib.requestRtImportErrorRR RPRyRtcloseRdR^Rn(R	RRRRtmaptsttageRBtrelease_nameRRtsrcRStdataR)RR~((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyRsP			


	

-c
Cstjjtjj|dddstjtjj|dddddtjtjj|dddddtjtjj|dddntjj|d	dd
}tjj|rtj|ntjj|drtj|d|n
tj|t	|G}t	tjj|d	ddd
}|j
|jWdQXWdQXtjjtjj|d}tjj|rtj
|tjj|d	dn7tjjdrtj
dtjj|d	dntjj|d	dd}tjj|r4tj|ntjj|dratj|d|n2tjjdrtjd|n
tj|dS(NtvartlibRtliststpartialRtarchivesR}tetcssources.list.ds.dssources.listRstrusted.gpgs/etc/apt/trusted.gpgs
trusted.gpg.ds/etc/apt/trusted.gpg.d(RRRdRRRRRtcopytreeR RRytdirnametcopy(Rtapt_rootR#tlist_dRtdestttrusted_gpgt	trusted_d((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyRs4'((%
'!%%cCstjj||S(skCompare two package versions.

        Return -1 for ver < ver2, 0 for ver1 == ver2, and 1 for ver1 > ver2.(RRtversion_compare(R	tver1tver2((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytcompare_versionsscCsYy(t|j}|j}WdQXWntk
r<tSXtjd|tjdkS(sReturn whether Apport should generate crash reports.

        Signal crashes are controlled by /proc/sys/kernel/core_pattern, but
        some init script needs to set that value based on a configuration file.
        This also determines whether Apport generates reports for Python,
        package, or kernel crashes.

        Implementations should parse the configuration file which controls
        Apport (such as /etc/default/apport in Debian/Ubuntu).
        Ns^\s*enabled\s*=\s*0\s*$(	R RRyRORPtretsearchtMR(R	RStconf((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pytenableds
N(&t__name__t
__module__t__doc__R
RRR&R*R/R1R<R>RARWRZR`RvRRRLRRtclassmethodRcRRRRRRRR\RoRRRRR (((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyRsB					
				
	
			
		0	%	+			,		'z						;(	(R#RDRRMReRRRRRRztwarningstfilterwarningst
FutureWarningRRltapport.packagingRRtimpl(((s9/usr/lib/python2.7/dist-packages/apport/packaging_impl.pyt<module>sl