AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/apport/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/apport/__pycache__/packaging_impl.cpython-310.pyc
o

��hT�@s(dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
Z
e
�dde�ddlZzddlZddlmZmZmZeeeefeZeZWn#ey|ddlmZmZddlmZdd	lmZmZddlZYnwddlZdd
lm Z Gdd�de �Z!e!�Z"dS)
zyapport.PackageInfo class implementation for python-apt and dpkg.

This is used on Debian and derivatives such as Ubuntu.
�N)�closing�ignorezapt API not stable yet)�urlopen�quote�unquote)�URLError�	HTTPError)r)rr)�PackageInfoc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd_d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Z	3	3d`d4d5�Zed6d7��Zd8d9�Zd:d;�Z 	3	$dad<d=�Z!d>d?�Z"d@dA�Z#	3	3	$dbdCdD�Z$dEdF�Z%edGdH��Z&dIdJ�Z'edKdL��Z(dMdN�Z)dOdP�Z*dQdR�Z+edSdT��Z,edUdV��Z-edWdX��Z.dYdZ�Z/d3Z0d[d\�Z1d3Z2d]d^�Z3d3S)c�__AptDpkgPackageInfoz�Concrete apport.PackageInfo class implementation for python-apt and
    dpkg, as found on Debian and derivatives such as Ubuntu.cCsFd|_d|_d|_d|_d|_d|_d|_d|_|jd|_d|_	dS)Nzhttps://api.launchpad.net/develz*/~%(user)s/+archive/%(distro)s/%(ppaname)sF)
�
_apt_cache�_sandbox_apt_cache�_sandbox_apt_cache_arch�
_contents_dir�_mirror�_virtual_mapping_obj�_contents_mapping_obj�_launchpad_base�_ppa_archive_url�_contents_update��self�r�7/usr/lib/python3/dist-packages/apport/packaging_impl.py�__init__-s
z__AptDpkgPackageInfo.__init__cCs4z|jr
t�|j�WdSWdStyYdSw)N)r�shutil�rmtree�AttributeErrorrrrr�__del__9s��z__AptDpkgPackageInfo.__del__cCsv|jdur|jStj�|d�}tj�|�r5t|d��}t�|�|_Wd�|jS1s-wY|jSi|_|jS)N�virtual_mapping.pickle�rb)r�os�path�join�exists�open�pickle�load�r�	configdir�mapping_file�fprrr�_virtual_mapping@s

���z%__AptDpkgPackageInfo._virtual_mappingcCsZtj�|d�}|jdur+t|d��}t�|j|�Wd�dS1s$wYdSdS)Nr�wb)r r!r"rr$r%�dumpr'rrr�_save_virtual_mappingMs
"��z*__AptDpkgPackageInfo._save_virtual_mappingcCs�|jr|jd|kr|jd|kr|jStj�|d||f�}tj�|�r2t�|�jdkr2t�|�tj�|�rXt|d��}t	�
|�|_Wd�|jS1sPwY|jS||d�|_|jS)N�release�arch�contents_mapping-%s-%s.picklerr)r/r0)rr r!r"r#�stat�st_size�remover$r%r&�rr(r/r0r)r*rrr�_contents_mappingSs$
�

���z&__AptDpkgPackageInfo._contents_mappingcCs|tj�|d||f�}|jdur<z!t|d��}t�|j|�Wd�WdS1s*wYWdSty;YdSwdS)Nr1r,)r r!r"rr$r%r-�MemoryErrorr5rrr�_save_contents_mappinges
�
&���z+__AptDpkgPackageInfo._save_contents_mappingcCs\d|_|js+ztjj��}tj|dd�|_W|jSty*tjdd�|_Y|jSw|jS)z(Return apt.Cache() (initialized lazily).N�/��rootdir)rr�apt�progress�base�
OpProgress�Cacher)rr=rrr�_cacheqs��z__AptDpkgPackageInfo._cachec

Cs�d|_|jr||jkrI|�|||||�tj�|�}tj|d�|_||_z|j�	|�Wntj
jy@}	ztt
|	���d}	~	ww|j��|jS|j��|jS)z�Build apt sandbox and return apt.Cache(rootdir=) (initialized lazily).

        Clear the package selection on subsequent calls.
        Nr:)rrr
�_build_apt_sandboxr r!�abspathr<r@�update�cache�FetchFailedException�SystemError�strr$�clear)
r�aptroot�apt_sources�
fetchProgress�distro_name�release_codename�originsr0r;�errr�_sandbox_caches$
���

�z#__AptDpkgPackageInfo._sandbox_cachecCs*z|��|WStytd|��w)zuReturn apt.Cache()[package] (initialized lazily).

        Throw a ValueError if the package does not exist.
        �package %s does not exist)rA�KeyError�
ValueError�r�packagerrr�_apt_pkg�s
�z__AptDpkgPackageInfo._apt_pkgcCs&|�|�}|j}|std|��|jS)z*Return the installed version of a package.rR)rW�	installedrT�version)rrV�pkg�instrrr�get_version�s

z __AptDpkgPackageInfo.get_versioncCs|�|�jjS)z1Return the latest available version of a package.)rW�	candidaterYrUrrr�get_available_version�sz*__AptDpkgPackageInfo.get_available_versioncCsJ|�|�jj}|sgSdd�|j�dg�|j�dg�|j�dg�D�S)z/Return a list of packages a package depends on.cSsg|]}|djj�qS�r)�
target_pkg�name)�.0�drrr�
<listcomp>�sz9__AptDpkgPackageInfo.get_dependencies.<locals>.<listcomp>�Depends�
PreDepends�
Recommends)rW�_pkg�current_ver�depends_list�get)rrV�cur_verrrr�get_dependencies�s���z%__AptDpkgPackageInfo.get_dependenciescCs@|�|�jr
|�|�jjS|�|�jr|�|�jjStd|��)z-Return the source package name for a package.rR)rWrX�source_namer]rTrUrrr�
get_source�s
z__AptDpkgPackageInfo.get_sourcecCs8|�|�j}|std��|jD]
}|jr|jSqdS)z�Return 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.
        zpackage is not installedN)rWrXrTrO�origin)rrVrZrprrr�get_package_origin�s

�z'__AptDpkgPackageInfo.get_package_origincCs�|�|�}|jr|jjdurdS|��d}|jr,|jjr,|jjD]
}|j|kr+dSq!tdd�|jjD��tdg�krDtj	�
d�rDdSdS)	z�Check if a package is a genuine distro package.

        Return True for a native distro package, False if it comes from a
        third-party source.
        NFrTcSsg|]}|j�qSr)rp)rb�orrrrd�sz:__AptDpkgPackageInfo.is_distro_package.<locals>.<listcomp>�z/etc/system-image/channel.ini)rWrXrY�get_os_versionr]rOrp�setr r!r#)rrVrZrMrrrrr�is_distro_package�s

� 
�z&__AptDpkgPackageInfo.is_distro_packagec	Cs�|�|�}|jr|jjdurdSg}t�d�D]1}z&t|��}|D]
}|��}|r.|�|�q!Wd�n1s9wYWqtyHYqw|jr_|jj	r_|jj	D]
}|j
|vr^dSqTdS)z�Check if a package originated from a native location

        Return True for a package which came from an origin which is listed in
        native-origins.d, False if it comes from a third-party source.
        NFz/etc/apport/native-origins.d/*T)rWrXrY�globr$�strip�append�IOErrorr]rOrp)rrVrZ�native_origins�f�fd�linerrrrr�is_native_origin_package�s0


�����
�z-__AptDpkgPackageInfo.is_native_origin_packagecCs�tjj�dd�ddlm}|jdddd�}|jd	}|j|�	�d
d�}	|	j
|d�}
|jd
d�}|j|||
ddd�}|s?dSd}
|D]!}|j
dkrKqC|jsV|jdd�}
n|j�|�rd|jdd�}
nqC|
sidS|
D]}|d|dfSdS)NzAPT::Get::AllowUnauthenticated�Truer��	Launchpad�apport-retrace�
production�devel�rY�ubuntu���)�name_or_version)�archtag�primary�raFT)�binary_namerY�distro_arch_series�ordered�exact_match)NNrs�Deleted)�include_meta�url�sha1)r<�apt_pkg�configru�launchpadlib.launchpadr��login_anonymously�
distributions�	getSeries�split�getDistroArchSeries�
getArchive�getPublishedBinaries�status�architecture_specific�binaryFileUrls�distro_arch_series_link�endswith)r�	distro_idr/rVrYr0r��	launchpadr��series�dasr��bpph�bf_urls�bp�bfrrr�get_lp_binary_package	s@�
�
��z*__AptDpkgPackageInfo.get_lp_binary_packageFc	Cs�zt|�}|��dkrtd|����Wnttfy)t�dt|��YdSwz|��}WntyCt�dt|��YdSwt	|t
�rN|�d�}|rWt�
|�dSt�
|�S)z�Open, read and parse the json of a url

        Set entries to True when the json data returned by Launchpad
        has a dictionary with an entries key which contains the data
        desired.
        ��%uzcannot connect to: %sNzfailure reading data at: %szutf-8�entries)r�getcoderr�apport�warningr�readrz�
isinstance�bytes�decode�json�loads)rr�r��response�contentrrr�json_request+s(���


z!__AptDpkgPackageInfo.json_requestc
Cs�ddlm}|jdddd�}|jd}|jdd	�}|j||d
d�}|s%dSd}	|D]}
|
jd
kr1q)|
��}	|	s:dSg}|	D]}|�|�q>|S)Nrr�r�r�r�r�r�r�r�T)rnrYr�rsr�)	r�r�r�r�r��getPublishedSourcesr��sourceFileUrlsry)
rr�rVrYr�r�r�r��pss�sfus�ps�source_files�sfurrr�get_lp_source_packageEs.�
�
z*__AptDpkgPackageInfo.get_lp_source_packagecCsH|�|�jr|�|�jjpdS|�|�jr|�|�jjpdStd|��)z�Return the architecture of a package.

        This might differ on multiarch architectures (e. g. an i386 Firefox
        package on a x86_64 system)�unknownrR)rWrX�architecturer]rTrUrrr�get_architecture]s
z%__AptDpkgPackageInfo.get_architecturecCs,|�d|g�}|dur
dSdd�|��D�S)z*Return list of files shipped by a package.z-LNcSsg|]	}|�d�s|�qS)�diverted)�
startswith)rbr|rrrrdpsz2__AptDpkgPackageInfo.get_files.<locals>.<listcomp>)�
_call_dpkg�
splitlines)rrV�listrrr�	get_filesjsz__AptDpkgPackageInfo.get_filesc

Csnd||��f}tj�|�sd|}zt�|�}t�|j�s t�t|j	|j
�}Wnty3gYSwd}d||��f}tj�|�sPd|}tj�|�sPgSt|d��Q}|D]F}z6d|vrgt�
d|�WqX|��}	|	sut�
d	|�WqXt�d
|	d�d��d��}t|j	|j
�|kr�WqXWn	ty�Ynw||7}qXWd
�n1s�wY|r�|�|�SgS)z/Return list of all modified files of a package.z/var/lib/dpkg/info/%s:%s.listz/var/lib/dpkg/info/%s.list�z /var/lib/dpkg/info/%s:%s.md5sumsz/var/lib/dpkg/info/%s.md5sumsr�z(%s contains NUL character, ignoring linez%%s contains empty line, ignoring liner9r��UTF-8N)�get_system_architecturer r!r#r2�S_ISREG�st_mode�OSError�max�st_mtime�st_ctimer$r�r�r�r��encode�_check_files_md5)
rrV�listfile�s�max_time�sums�sumfiler}r~�wordsrrr�get_modified_filesrsP
���
��
z'__AptDpkgPackageInfo.get_modified_filesc
Cstjdddd|gtjd�}|��d��}|jdkriSi}|��D]f}|s'q"|����dd�\}}t	j
�|�r�z0t|d	��}|�
�}	Wd�n1sNwYt��}
|
�|	�|
��}||krh|	||<Wq"ty�}zd
t|�||<WYd}~q"d}~wwd||<q"|S)a?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.
        z
dpkg-queryz-Wz--showformat=${Conffiles}�--��stdoutrN�rz[inaccessible: %s]z	[deleted])�
subprocess�Popen�PIPE�communicater��
returncoder�rxr�r r!r#r$r��hashlib�md5rD�	hexdigestrzrH)
rrV�dpkg�out�modifiedr~r!�default_md5sumr}�contents�m�calculated_md5sumrPrrr�get_modified_conffiles�s<
��

�
���
z+__AptDpkgPackageInfo.get_modified_conffilescCs�d}d}d}|sC|t|�krCtjdddd|g||||�tjtjtjd�}|��d�d	�}|jdkr7|}||7}|sC|t|�ks|S)
zsCall fgrep for a pattern on given file list and return the first
        matching file, or None if no file matches.N�dr�fgrepz-lxm�1r�)�stdinr��stderrr�)�lenr�r�r�r�r�r�)r�pattern�	file_list�match�
slice_size�i�pr�rrr�
__fgrep_files�s ��
�	z"__AptDpkgPackageInfo.__fgrep_filesNcCsj|r
|�||||�Stjdd|gtjtjd�}|��d�d�}|jdkr3|r3|��d}|dkr3|Stj	�
tj	�|��d��}	g}
g}t
�
d�D](}tj	�
tj	�|��d���d	�d}
|
|	vsg|	|
vrm|�|�qJ|
�|�qJ|�||�}|s�|�||
�}|s�|�d
�r�|dd�}|�d
||�}|s�|�d
||
�}|r�tj	�
tj	�|��d�d	�dSdS)apReturn the package a file belongs to.

        Return 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.
        Also, release and arch can be set to a foreign release/architecture
        instead of the one from the current system.
        zdpkg-divertz--list�r�r�rr�r�zhardening-wrapperz/var/lib/dpkg/info/*.list�:z/usr�N�%s)�_search_contentsr�r�r�r�r�r�r�r r!�splitext�basename�lowerrwry� _AptDpkgPackageInfo__fgrep_filesr�)r�file�uninstalled�map_cachedirr/r0r�r�rZ�fname�	all_lists�likely_listsr|r�r�rrr�get_file_package�s:�&"z%__AptDpkgPackageInfo.get_file_packagecCsBtjddgtjd�}|��d����}|jdksJ�|sJ�|S)zcReturn the architecture of the system, in the notation used by the
        particular distribution.r�z--print-architecturer�r�r�r�r�r�r�rxr�)�klassr�r0rrrr�s
�z,__AptDpkgPackageInfo.get_system_architecturecCs>tjddgtjd�}|��d����}|jdksJ�d|S)z�Return 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.
        zdpkg-architecturez-qDEB_HOST_MULTIARCHr�rz/lib/%s:/libr)rr��multiarch_triplerrr�get_library_pathss
�z&__AptDpkgPackageInfo.get_library_pathscCs@||_z|jrt�|j�d|_WdSWdStyYdSw)z�Explicitly 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)rrrrr)rr�rrr�
set_mirror-s��z__AptDpkgPackageInfo.set_mirrorcCs
tj��}|rt��}|�d|���|��|j|d<|r(t	j
gd�|d�dddd|g}|r;|d	d
|7<z�t	j
|||d�dkr�|sKWd
S|�|��||�}	|	r�d}
t
jj�d�dkrpt
jj�d�}
t
jj�dd�t
jj��}t
j�|�}g}
|	D]}|
�t
jj|||d��q�|��}||jkr�Wd
S|
r�t
jj�d|
�t�tj�|d��D]}t	j
ddd|gt	j|d�q�nWd
SWn
ty�Yd
Swd
}t�tj�||d��D]
}tj�|�r�|}q�|s�Jd��zt	j
dd|d�W|St�yY|Sw)a:Download source package and unpack it into dir.

        This also has to care about applying patches etc., so that dir will
        eventually contain the actually compiled source. dir needs to exist and
        should be empty.

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

        If sandbox is given, it calls apt-get source in that sandbox, otherwise
        it uses the system apt configuration.

        If apt_update is True, it will call apt-get update before apt-get
        source. This is mostly necessary for freshly created sandboxes.

        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.
        zODir "%s";
Dir::State::Status "/var/lib/dpkg/status";
Debug::NoLocking "true";
 �
APT_CONFIG)�apt-get�-qqrD)�envrrz--assume-yes�sourcer��=)�cwdrrNrszAcquire::http::Proxy)�destdirz*.dsczdpkg-sourcez-sn�-x)r�rz-*z.could not determine source tree root directoryz�(debian/rules patch || debian/rules apply-patches || debian/rules apply-dpatches || debian/rules unpack || debian/rules patch-stamp || debian/rules setup) >/dev/null 2>&1T)�shellr) r �environ�copy�tempfile�NamedTemporaryFile�writer��flushrar��callr��get_distro_namer<r�r��findrur=r>�AcquireProgress�Acquirery�AcquireFile�run�RESULT_CONTINUErwr!r"r�r��isdir)r�
srcpackage�dirrY�sandbox�
apt_updaterr|�argv�sf_urls�proxyrL�fetcher�af_queue�sf�result�dsc�rootrcrrr�get_source_tree>s�
��

�
�
���������z$__AptDpkgPackageInfo.get_source_treecCsdt��dS)z�Return the actual Linux kernel package name.

        This is used when the user reports a bug against the "linux" package.
        zlinux-image-r�)r �unamerrrr�get_kernel_package�sz'__AptDpkgPackageInfo.get_kernel_packagecCsg}g}|d��d}|d}|d��d}d|}|��}||vr-||jr-||fStjj�d�d}	d|||f}
d	|
}ttj	�
|	|
�d
�}t|�}
|
��dkrWdS	|
�
d�}|s`n|�|�qX|��|��t�ddtj	�
|	|
�g�}|dkr�|�|
�d�d�||fS)z�Install 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.
        �Uname��Architecture�Packagezlinux-image-debug-%s�Dir::Cache::archivesz/partialz
%s_%s_%s.ddebz,http://ddebs.ubuntu.com/pool/main/l/linux/%s�wr�)rs�linuxTi r�z-ir�_)r�rA�isInstalledr<r�r��find_dirr$r r!r"rr�r�r$r%�closer�r&ry)r�reportrX�outdated�kverr0�ver�
debug_pkgname�c�
target_dir�debr�r��u�block�retrrr�_install_debug_kernel�s8

�z*__AptDpkgPackageInfo._install_debug_kernelTc=s|s|��}|sd}|��|_nftj�||d�}||��kr/tj�|||d�}
tj�|
�r/|
}z
|�|�|��Wnt	yT}zt
�dt|��WYd}~nd}~wwt
tj�||d���}|����|_Wd�n1sqwYtj�|�s�t	d|��|r�d}||��kr�|}nd}|r�tj�|||d	�}n	tj�|d
|d	�}tj�|�s�t�|�nd}t��}tjj�d|�tjj�d
d�tjj�dd�tjj�dd�|r�tjj��}ntjj��}|s�|�||||��|j|	|��n7|�|||��|j|	�tjtj� |�d��z��!|�Wntj"j#�y*}zt	t|���d}~ww��
�tjj�$d�}d}tj�%�}tj�|d�}i}tj�|��r{t
|��!}|D]}|��}|�s_�qT|�&�\}}|||<�qTWd�n	1�svwYt�}i}tj�'|�}g}|�rBg} |D]�\}!}"z�|!}#Wnt(�y�d|!�)dd�}$||$d7}t
�|$�Y�q�w|#j*j+D]~}%|%dj,�v�r҈�-|%dj,�d|%d<�|%dj,j*j.}&|%dj,dd�|D�v�r�q�|%dj,|v�r||%dj,}'|�/|'|&�dk�r
| �0|%dj,|'f�n| �0|%dj,|&f�n
| �0|%dj,|&f�|%dj,dd�|D�v�r9|�0|%dj,df��q��q�|�1| �|D�]J\}!}"z�|!}#Wnt(�ymd|!�)dd�}$||$d7}t
�|$�Y�qDwz|"�rx|#j2|"|#_*Wn9t(�y�|�3|��||!|"|�\}(})|(�r�|�0tjj4||(d|)|d��|"||!<n|d |!|"|#j*j.f7}Ynw|#j*}*|�5|!�|�r�|�6|�}+|*j7D]
}|+�8|t���5|!��q�g},d!|*j9v�r�|,tj�:|*j9d!�7},d"|*j9v�r�|,tj�:|*j9d"�7},|,D]�}-|-dd|*j;j,k�r	�q�|-d}-��<|-d��rtz|+|-d}.Wnt(�y(Y�q�w|.D]E}||*j;j,k�r6�q+tj�|d#|�}/t=�=|/�D]}0|�>|0�}"tj�?|"|-d$|-d%��r]t�@|0��qDz||=W�q+t(�ypY�q+w~.�q�tj�|d#|-d�}/t=�=|/�D].}0|�>|0�}"tj�?|"|-d$|-d%��r�t�@|0�z||-d=W�q�t(�y�Y�q�w�q��q�|*jAd&k�r�|
�r�zt|!d'}1�|1}2d}3|"�r	z
|2j2|"|2_*d}3Wn2t(�y|�3|��||1|"|�\}(})|(�r|�0tjj4||(d|)|d��|"||1<d}3nt(�Ynw|3�s+z	|2j2|*j.|2_*Wnt(�y*|d(|!|"|2j*j.f7}Ynw|�5|1�W�qDt(�y�|�B�|�C|*jD��rg�fd)d�|jED�}4|"�rf|4D]}2�|2j*j.|"k�rd|4�F|2��qTng}4|4�r�|4D]m}||v�rw�qnd}3|"�r�z�|j2|"�|_*d}3Wn/t(�y�|�3|��|||"|�\}(})|(�r�|�0tjj4||(d|)|d��|"||<d}3Ynw|3�s�z
�|j2|*j.�|_*Wn
t(�y�Ynw|�5|��qnn�d}3|!d*}5zk�|5}6|�5|5�|"�r*z
|6j2|"|6_*d}3Wn/t(�y)|�3|��||5|"|�\}(})|(�r'|�0tjj4||(d|)|d��|"||5<d}3Ynw|3�sMz	|6j2|*j.|6_*Wnt(�yL|d+|!|*j.|6j*j.f7}YnwWn;t(�y�|"�r~|�3|��||5|"|�\}(})|(�r~|�0tjj4||(d|)|d��|"||5<d}3|3�s�|d,|!7}YnwY�qDw�qDtG|�}7|�H�D]x}||7v�r�|7|du�r�|�I|��|j*j.k�r�|�F|��q��|�Jdd��q�|�I|�|7|k�r׈|�Jdd��q�|�I|��|j*j.k�r�|�Jdd��q�|�F|��q�|�I|��|j*j.k�r
�|�Jdd��q�|�F|��q�tK�K�}8z�jL|d-�Wn"tj"j#�y?}zt
�Md.t|��tN�Od%�WYd}~nd}~ww|�rGtPd/�|jQD]c}9tR�Sd0d1|9jTg��U�}:|:���&�\}}|�rq||v�sqtj�V|9jT�|8k�r�|�I|�|k�rzn||v�r�|||k�r�ntR�Wd2d3|9jT|g�|||<tj�X|9jT��&d4d%�d};|;|v�r�|�F|;��qJtY|�Z��}<|<�[�t
|d5��$}|<D]}|�\|�|�\d6�|�\||�|�\d��q�Wd�n	1�s�wY|�r�t]�^|�|�r�Jd7d6�|���|�r|�_|�|S)8a�Install 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.

        If permanent_rootdir is True, then the sandbox created from the
        downloaded packages will be reused, to speed up subsequent retraces.

        If architecture is given, the sandbox will be created with packages of
        the given architecture (as specified in a report's "Architecture"
        field). If not given it defaults to the host system's architecture.

        If origins is given, the sandbox will be created with apt data sources
        for foreign origins.

        If install_deps is True, then the dependencies of packages will also
        be installed.

        Return a string with outdated packages, or an empty string 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.
        �/etc/apt/sources.list�sources.listzcannot determine mirror: %sN�codenamez%s does not existFrsr<�systemTzAPT::ArchitecturezAcquire::Languages�nonez'Acquire::http::Proxy::api.launchpad.net�DIRECTz#Acquire::http::Proxy::launchpad.netr:rCzpackages.txtz#package %s does not exist, ignoring�%z%%�
rcS�g|]}|d�qSr_r�rbrZrrrrdc�z9__AptDpkgPackageInfo.install_packages.<locals>.<listcomp>r�cSr^r_rr_rrrrdqr`zsha1:%s)�hashrz,%s version %s required, but %s is available
�	Conflicts�Replacesz%s_*.debr�r@�all�-dbgzAoutdated -dbg package for %s: package version %s -dbg version %s
cs2g|]}|�d�r|�vrd�|jjvr|�qS)re�transitional)r�r]�description)rbr��rErrrd�s��z-dbgsymzKoutdated debug symbol package for %s: package version %s dbgsym version %s
z%no debug symbol package found for %s
)r6z+Package download error, try again later: %szExtracting downloaded debs...�dpkg-debz--showr�rrFrD� z*apt fetcher did not fetch these packages: )`r��get_distro_codename�current_release_codenamer r!r"r#r�$_get_primary_mirror_from_apt_sourcesrGr�r�rHr$r�rxr.�makedirsr"�mkdtempr<r�r�rur=�textr)r>rQr'rBr@rCrDrErFrH�
SourceRecordsr�r*rS�replacer]�dependenciesra�get_providing_packagesrY�compare_versionsry�extend�versionsr�r+�addr+�provides�
setdefault�record�
parse_dependsrV�is_virtual_packagerw�_deb_version�	check_dep�unlinkr��restart�lookuprn�binariesr4�dictr!rk�mark_install�time�fetch_archives�error�sys�exit�print�itemsr��check_output�destfiler��getctime�
check_callrr��keys�sortr$rrr.)=rr;r(r/�packages�verbose�	cache_dir�permanent_rootdirr�rO�install_dbg�install_depsrK�arch_apt_sourcesrPr|�tmp_aptroot�aptroot_archrJrL�
archivedir�obsolete�src_records�pkg_list�pkg_versionsr~r��v�	real_pkgs�lp_cacher6�
acquire_queue�depsrZrM�	cache_pkgr��dep�dep_pkg_vers�inst_version�lp_url�sha1sumr]�virtual_mapping�	conflicts�conflict�	providers�debsr!�dbg_pkg�dbg�	pkg_found�dbgs�
dbgsym_pkg�dbgsym�requested_pkgs�last_writtenr�r��pkg_name�pkgsrrhr�install_packages�s�-
����
�
����

��	
���

��
��
��


�

��

���	
����
��
�

������

�������
�������^
��
$

�

��

�
z%__AptDpkgPackageInfo.install_packagescCstj�|����|�S)z2Return known package names which match given glob.)rw�fnmatch�filterrAr�)r�nameglobrrr�package_name_glob�sz&__AptDpkgPackageInfo.package_name_globcCsDtjdg|tjtjd�}|�t�d�d�}|jdkr|Std��)zRCall dpkg with given arguments and return output, or return None on
        error.r�rrr�zpackage does not exist)r�r�r�r��inputr�r�rT)r�argsr�r�rrrr��s�
z__AptDpkgPackageInfo._call_dpkgcCs�tj�|�r!tjdd|gtjtjdid�}|��djddd�}n&t|�t	ks+Jd	��tjddgtjtjtjdid
�}|�|�djddd�}|j
dkrNgSg}|��D]}|�d�rf|�
|�dd
�d�qT|S)z�Internal function for calling md5sum.

        This is separate from get_modified_files so that it is automatically
        testable.
        z/usr/bin/md5sumz-cr9)r�r�rrrr�rr)�errorsz&md5sum list value must be a byte array)r�r�r�rr�FAILEDrr@)r r!r#r�r�r�r�r��typer�r�r�r�ry�rsplit)rr�r�r��
mismatchesr~rrrr��s(�
�

�z%__AptDpkgPackageInfo._check_files_md5cCs�t|��C}|D]9}|��}t|�dkr@|ddkr@|d�d�r#d}nd}||�d�s3||�d�r@||Wd	�Sqtd
|��1sJwYd	S)z?Heuristically determine primary mirror from an apt sources.list�rrQr@�[r�zhttp://zhttps://NzEcannot determine default mirror: %s does not contain a valid deb line)r$r�r�r�rG)rrKr|r~�fields�
mirror_idxrrrrm�s"
�
��
��z9__AptDpkgPackageInfo._get_primary_mirror_from_apt_sourcescCs|js	|�d�|_|jS)zReturn the distribution mirror URL.

        If it has not been set yet, it will be read from the system
        configuration.rV)rrmrrrr�_get_mirror�sz __AptDpkgPackageInfo._get_mirrorcCs"t|d�r
|jdur
|jStd��)z7Map a DistroRelease: field value to a release code namerlNzBCannot map DistroRelease to a code name without install_packages())�hasattrrl�NotImplementedError)rr/rrr�_distro_release_to_codename�sz0__AptDpkgPackageInfo._distro_release_to_codenamec 	Cs$|r|}n|js
t��|_|j}|dur|��}|dur!|��}n|�|�}dD�]�}tj�|d|||f�}d}zt�	|�}	t
t��|	j�}
Wnt
yTd}
Ynw|
dus^|
dk�rd|��|||f}|
r�zddlm}dd	lm}
Wnty�ddlm}dd	lm}
Ynwdd
lm}|
|�d}||�}|�d|
|�d
�|��}|�dd�}|r�|�|d�}||�|	j�k}nd}nd}|�rd|_zt|�}Wnty�|dkr�Yq(wt|d��}	|�d�}|s�n|� |�q�Wd�n	1�swY|�!�tj�"|��sJ�|�#|||�}|�r&t$|�d
k�r)d|_|j�r�ddl%}|�d|d���}d}|D]�}|d7}|dk�rU|dv�rU|dk�rU�q>|�&�d}|�&d�ddk�r�|�&d�ddv�rq�q>|�&d�ddk�r�|�&d�d
dv�r��q>|�&�d�&d�d�&d�d}n|�&d�ddv�r�|�&�d�&d�d�&d�d}n�q>||v�r�|||k�rÐq>|||<�q>|||<�q>Wd�n	1�s�wYq(|j�r�|�'|||�d|_t(|t)��r�|�*�}|dd k�r|dd�}|�+�g}|�,d!��r|�-|d"d��+��nY|�,d#��r.|�-|d"d��+��nG|�,d$��r@|�-|d"d��+��n5|�,d%��rR|�-|d"d��+��n#|�,d&��rd|�-|d"d��+��n|�,d'��ru|�-|d"d��+��|D]}z||�*�}|WSt.�y�Y�qwwdS)(z4Internal function for searching file in Contents.gz.N)z	-proposedrsz	-securityz-updatesz%s%s-Contents-%s.gzFi�Qz%s/dists/%s%s/Contents-%s.gzr)�HTTPConnection)�urlparse)�datetimer@�HEADr�z
last-modifiedz%a, %d %b %Y %H:%M:%S %ZTrsr,i@Brr)�trusty�xenial�!�/susr)�libslibexecslibx32�bin�sbin�sharesgamessBrotherr�)sdocsiconssmanstexlivesgocodeslocaleshelpr��,)r�r�r�r9zusr/lib/x86_64-linux-gnu/rzusr/lib/i386-linux-gnu/zusr/lib/systemd/z
usr/lib/udev/zusr/bin/z	usr/sbin/)/rr"ror�rkr�r r!r"r2�intr�r�r�r��httplibr�r��ImportError�http.client�urllib.parser��request�getresponse�	getheader�strptime�
fromtimestamprrrzr$r�r$rIr#r6r��gzipr�r8r�r�r�r�r�ryrS) rr
rr/r0r0�pocket�maprD�st�ager�r�r�r��server�conn�res�modified_strr��srcr|�data�contents_mappingr�r��line_numr~r!rV�filesrZrrrr�s�




�
����

��
""
��� 

�z%__AptDpkgPackageInfo._search_contentsc
	Cs�|�d�r�|�d�dd�}d}t|�dkr|�d�d}d}|t|�kr�t�d|d|��}t�d||d��}z2tttj	j
|||d	����}	|	��|	��d
kr[t
d|	����Wd�n1sewYWn#tt
fy�|d7}|t|�kr�|r�|�d�d}d}nd}Yqw	|r�|r�d||||f}
d
||||f}z,tt|���}	|	��|	��d
kr�t
d|	����Wd�n1s�wYd}Wn
tt
fy�d}Ynw|
|d|
dd�dSdS)a�For an origin from a Launchpad PPA create sources.list content.

        distro is the distribution for which content is being created e.g.
        ubuntu.

        release_codename is the codename of the release for which content is
        being created e.g. trusty.

        Return a string containing content suitable for writing to a sources.list
        file, or None if the origin is not a Launchpad PPA.
        �LP-PPA-�-r�NTr@�ppaF��user�distro�ppanamer�r�z-deb http://ppa.launchpad.net/%s/%s/%s %s mainz5http://ppa.launchpad.net/%s/%s/%s/dists/%s/main/debugz main/debugrsz
deb-srcr�r])r�r�r�ryrHr"rrr��	packagingrr�r�rr)
rrpr�rN�
components�try_ppa�indexr��ppa_namer��ppa_line�	debug_url�	add_debugrrr�create_ppa_source_from_origin�sl


�����
�

�
����z2__AptDpkgPackageInfo.create_ppa_source_from_originc
Cs�tj�tj�|ddd��sMt�tj�|ddddd��t�tj�|ddddd��t�tj�|ddd��t�tj�|d	dd
��t�tj�|d	dd��tj�|d	dd�}tj�|�rat�|�tj�|d
�rrt�|d
|�nt�|�t	|��+}t	tj�|d	dd�d��}|�
|���Wd�n1s�wYWd�n1s�wY|�r�d}	i}
|D]�}|dkr�q�d}tj�|d
�r�tj�|d
|d�}tj�|�s�d|vr�tj�|d
|�d�d�}tj�|�s�d}ntj�|�s�d}|�rt	|��}
|
��}	Wd�n	1�swYn|�
|||�}	|	�r|t	tj�|d	dd|d�d��
}|�
|	�Wd�n	1�sCwY|	��D].}|�d��rV�qLd|v�r]�qL|��d�d�d}|��d�d�d}||f|
|<�qLq�t�d|�q�tj�tj�|�d�}tj�|��r�t�|tj�|d	d��ntj�d��r�t�dtj�|d	d��tj�|d	dd�}tj�|��r�t�|�tj�|d
��r�t�|d
|�ntj�d ��r�t�d |�nt�|�|�rV|	�rX|
��D]_\}\}}tjjt|�|t|�d!�}tj�|�}|�s�q�z|d"}Wnt�y1t�d#|�Y�q�wd$d%tj�|d&|�d'd(d)d*d+|g	}t�|�d,k�rTt�d-|�	�q�dSdSdS).N�var�libr<�lists�partialrE�archivesr��etcz
apt.conf.dz
preferences.dzsources.list.dz.drWrDrsr�z.listzLP-PPAr��a�#zppa.launchpad.netr@r9r�rz-Could not find or create source config for %sztrusted.gpgz/etc/apt/trusted.gpgz
trusted.gpg.dz/etc/apt/trusted.gpg.dr��signing_key_fingerprintz/Error: can't find signing_key_fingerprint at %szapt-keyz	--keyringz%s.gpg�advz--quietz--keyserverzkeyserver.ubuntu.comz
--recv-keyrzUnable to import key for %s)r r!r#r"rnrrr.�copytreer$r$r�rxrr�r�r�r�r��dirnamer!r�r�rrr��
IndexErrorr�r&)r�apt_rootrKrMrNrO�list_dr��dest�source_list_content�origin_datarp�origin_path�src_extr~r�r��trusted_gpg�	trusted_d�ppa_userr��ppa_archive_url�ppa_inforr3rrrrB�s�


�����

�����
�	

��������z'__AptDpkgPackageInfo._build_apt_sandboxcCsJtjdd|dgtjd�}|�t�d�d���}|jdksJ�|s#J�|S)z!Return the version of a .deb fileriz-f�Versionr�rr�)r�r�r�r�r�r�rxr�)rrZr�r�rrrr~7s
z!__AptDpkgPackageInfo._deb_versioncCstj�||�S)zkCompare two package versions.

        Return -1 for ver < ver2, 0 for ver1 == ver2, and 1 for ver1 > ver2.)r<r��version_compare)r�ver1�ver2rrrruAsz%__AptDpkgPackageInfo.compare_versionscCsJ|jdur"tjddgtjd�}|��d�d���|_|jdks"J�|jS)z(Get "lsb_release -sc", cache the result.N�lsb_releasez-scr�rr�)�_distro_codenamer�r�r�r�r�rxr�)rr!rrrrkJs

�z(__AptDpkgPackageInfo.get_distro_codenamecCs<|jdur|��d��|_d|jvr|j�dd�|_|jS)zuGet osname from /etc/os-release, or if that doesn't exist,
           'lsb_release -sir' output and cache the result.Nrrjr�)�_distro_namertrrrrrrrr'Ws


z$__AptDpkgPackageInfo.get_distro_name)F)FNNN)NNF)FNFNNTF)4�__name__�
__module__�__qualname__�__doc__rrr+r.r6r8rArQrWr\r^rmrorqrvrr�r�r�r�r�r�r�r	r�classmethodr�rrr<r>rUr�r�r�r�rmr�r�rrrBr~rur"rkr#r'rrrrr
)s�

	

"
0(
�6

�X'
�[	




A
k
	r
)#r'r�r rwr2r�r"rr�r�r��
contextlibr�warnings�filterwarnings�
FutureWarningr<�cPickler%�urllibrrrrzrrr��urllib.error�urllib.requestr�r��apport.packagingr	r
�implrrrr�<module>sH@�
G

Anon7 - 2022
AnonSec Team