HEX
Server: Apache
System: Linux hn220.greenhost.nl 6.12.58 #3 SMP Wed Nov 19 09:04:59 UTC 2025 x86_64
User: webmaster (87278)
PHP: 8.4.5
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Upload Files
File: //lib/python3/dist-packages/apt/__pycache__/debfile.cpython-39.pyc
a

?��`e��@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZmZmZmZddlmZddlmZGdd�de�ZGd	d
�d
e�ZGdd�de�Zd
d�Zedkr�e�dS)z;Classes for working with locally available Debian packages.�)�print_functionN)�Dict�Iterable�List�Optional�Set�Tuple�Union�cast)�gettext)�BytesIOc@seZdZdZdS)�NoDebArchiveExceptionz9Exception which is raised if a file is no Debian archive.N)�__name__�
__module__�__qualname__�__doc__�rr�-/usr/lib/python3/dist-packages/apt/debfile.pyr
#sr
c@sPeZdZdZed�\ZZZZdZ	dEdd�Z
dd�Zd	d
�Zdd�Z
ed
d��Zedd��ZdFdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zedd��Zed d!��Zed"d#��Zd$d%�Zd&d'�Zd(d)�ZdGd+d,�ZdHd-d.�Zd/d0�Zd1d2�Z ed3d4��Z!ed5d6��Z"e#d7d8��Z$e#d9d:��Z%dId;d<�Z&d=d>�Z'd?d@�Z(dAdB�Z)dJdCdD�Z*dS)K�
DebPackagezA Debian Package (.deb file).�rNcCs`|durt��}||_ttjd�|_d|_d|_i|_	g|_
d|_d|_d|_
|r\|�|�dS)N�F)�apt�Cache�_cacher
�apt_inst�DebFile�_debfile�pkgname�filename�	_sections�
_need_pkgs�_check_was_run�_failure_string�
_multiarch�open��selfr�cacherrr�__init__3szDebPackage.__init__cCsh|�dd|�g|_t�|_d|_||_t�|j�|_|jj	�
d�}t�|�|_
|j
d|_d|_dS)z open given debfile �z	open '%s'r�control�PackageFN)�_dbgr �set�_installed_conflictsr"rrrrr*�extractdata�apt_pkgZ
TagSectionrrr!)r&rr*rrrr$CszDebPackage.opencCs
|j|S�N�r�r&�keyrrr�__getitem__QszDebPackage.__getitem__cCs
||jvSr1r2r3rrr�__contains__UszDebPackage.__contains__csFg�z|jj��fdd��Wn"ty@td�|jgYS0�S)z$return the list of files in the deb.cs��|j�Sr1��append�name��item�data��filesrr�<lambda>_�z%DebPackage.filelist.<locals>.<lambda>z(List of files for '%s' could not be read)rr<�go�SystemError�_r�r&rr=r�filelistYs�zDebPackage.filelistcsJg�z|jj��fdd��Wn"ty@td�|jgYS0t��S)z, return the list of files in control.tar.gz cs��|j�Sr1r7r:�r*rrr?lr@z-DebPackage.control_filelist.<locals>.<lambda>z0List of control files for '%s' could not be read)rr*rArBrCr�sortedrDrrFr�control_filelistes
��zDebPackage.control_filelistFcCs�d|vr|S|js|S|j�|�r&|S||jvr`|j|jdur`ttjj|j|j�jdkr`|Sd||jf}||jvr||S|j|}|jdur�|S|jj	}|j
|j@r�|S|r�|j
|j@s�|S|S)N�:�all�%s:%s)
r#r�is_virtual_package�	candidater
r�package�Version�architectureZ_candZ
multi_archZMULTI_ARCH_FOREIGNZMULTI_ARCH_SAME)r&r�in_conflict_checkingZmultiarch_pkgnameZ
multiarch_pkg�candrrr�_maybe_append_multiarch_suffixss<
�
���



�z)DebPackage._maybe_append_multiarch_suffixc	Cs�|�dd|�|D]�}|d}|d}|d}|�|�}||jvr�|j�|�r|�dd|�|j�|�D]}|jrldSqlq|j|j}|dur�t�|j	||�r�dS|s|jj|dd	�D](}|jr�|�dd
|j
|f�dSq�qdS)z�Return 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.
        �z_checkOrGroup(): %s r�r)z+_is_or_group_satisfied(): %s is virtual depTN)Zinclude_nonvirtualz'found installed '%s' that provides '%s'F)r,rSrrL�get_providing_packages�is_installed�	installedr0�	check_dep�versionr9)	r&�or_group�dep�depname�ver�oper�pkg�instZppkgrrr�_is_or_group_satisfied�s@

��
�
��z!DebPackage._is_or_group_satisfiedc
Cs|D]�}|\}}}|�|�}||jvrX|j�|�s4q|j�|�}t|�dkrNq|dj}|j|}|jj�|j�}|sxqt	�
|j||�s�q|�dd|�|j
�|�dSd}	|D]L}|	|d7}	|r�|r�|	d|d|df7}	||t|�dkr�|	d7}	q�|jtd	�|	7_d
S)zTry to satisfy the or_group.rUrrTzNeed to get: %sTrz (%s %s)�|z"Dependency is not satisfiable: %s
F)rSrrLrV�lenr9�	_depcacheZget_candidate_ver�_pkgr0rYZver_strr,r r8r"rC)
r&r[r\r]r^r_�	providersr`rRZor_strrrr�_satisfy_or_group�s@





��zDebPackage._satisfy_or_groupcCs�|�dd|||f�|j|}|jr>|jdus4J�|jj}n"|jr\|jdusRJ�|jj}ndSt�|||�r�|�	|||�s�|j
td�|j7_
|�dd|j�dSdS)z@Return True if a pkg conflicts with a real installed/marked pkg.r)z8_check_single_pkg_conflict() pkg='%s' ver='%s' oper='%s'NFz)Conflicts with the installed package '%s'z!conflicts with installed pkg '%s'T)
r,rrWrXrZ�marked_installrMr0rY�replaces_real_pkgr"rCr9)r&rr^r_r`�pkgverrrr�_check_single_pkg_conflict�s,��


��z%DebPackage._check_single_pkg_conflictcCs�|�dd|�|D]�}|d}|d}|d}|j|dd�}||jvr�|j�|�r|j�|�D]N}|�dd|j�|j|jkr�|�dd	�q`|�|j||�r`|j�	|j�q`q|�|||�r|j�	|�qt
|j�S)
z5Check the or-group for conflicts with installed pkgs.rTz _check_conflicts_or_group(): %s rrUT)rQr)zconflicts virtual check: %szconflict on self, ignoring)r,rSrrLrVr9rrlr.�add�bool)r&r[r\r]r^r_r`rrr�_check_conflicts_or_groups.�
�z$DebPackage._check_conflicts_or_groupcCs4d}zt�|j|d�WSty.gYS0dS)z/List of packages conflicting with this package.�	ConflictsFN�r0�
parse_dependsr�KeyErrorr3rrr�	conflicts3s
zDebPackage.conflictsc	CsBg}dD]4}z|�t�|j|d��Wqty:Yq0q|S)z2List of packages on which this package depends on.)ZDependszPre-DependsF)�extendr0rrrrs)r&�dependsr4rrrrv=s�zDebPackage.dependscCs4d}zt�|j|d�WSty.gYS0dS)z<List of virtual packages which are provided by this package.ZProvidesFNrqr3rrr�providesKs
zDebPackage.providescCs4d}zt�|j|d�WSty.gYS0dS)z4List of packages which are replaced by this package.ZReplacesFNrqr3rrr�replacesUs
zDebPackage.replacescCs�|�dd|||f�|j|}d}|jrB|jdus8J�|jj}n"|jr`|jdusVJ�|jj}nd}|jD]J}|D]@\}}}||krr|dus�t�	|||�rr|�dd|�dSqrqjdS)z�Return 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).
        r)zreplaces_real_pkg() %s %s %sNz?we have a replaces in our package for the conflict against '%s'TF)
r,rrWrXrZrirMrxr0rY)r&rr_r^r`rkr[r9rrrrj_s(



��zDebPackage.replaces_real_pkgcCs"d}|jD]}|�|�r
d}q
|S)z�Check 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.
        TF)rtro)r&�resr[rrr�check_conflictszs


zDebPackage.check_conflictsc
CsTtt|j��}tt|d�d�}|jd}|jd}dd�|jD�}t|j�D�]�\}}||dkr~|jj�	t|�|d�|j
s�qN|jd	us�J�|jj
}|jjD]~}	|	jD]r}
|
j|jkr�t�||
j|
j�s�|�d
d|j�|jtd�|j|
j|
j|
jd
�7_|jj��dSq�q�d|jvrN|jdD�]}|D]�}|jj|jk�r�|jj|k�r�t�||j|j��r�|�d
d|j�|jtd�|j|jj|j|jd�7_|jj��dS|jj|v�rB|j|jk�rB|�d
d|�|jtd�d�|�|j |jj|jd�7_|jj��dS�qB�q8qN|jj��dS)z�
        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
        �2rUrO�ArchitecturecSsg|]}|dd�qS)rr)�.0�xrrr�
<listcomp>�r@z=DebPackage.check_breaks_existing_packages.<locals>.<listcomp>rgY@NrTzwould break (depends) %sz]Breaks existing package '%(pkgname)s' dependency %(depname)s (%(deprelation)s %(depversion)s))rr]ZdeprelationZ
depversionFrpzwould break (conflicts) %szZBreaks existing package '%(pkgname)s' conflict: %(targetpkg)s (%(comptype)s %(targetver)s))r�	targetpkgZcomptypeZ	targetverz{Breaks existing package '%(pkgname)s' that conflict: '%(targetpkg)s'. But the '%(debfile)s' provides it via: '%(provides)s'�,)rwZdebfiler�rT)!�floatrdr�max�intrrw�	enumerateZop_progress�updaterWrXrfZcurrent_verZdependenciesZor_dependenciesr9rr0rYZrelationrZr,r"rCZdoneZdepends_listZ
target_pkgrPZ	comp_typeZ
target_ver�joinr)
r&�sizeZsteps�debverZdebarchrw�ir`r^Zdep_orr\Zconflicts_ver_listZc_orrrr�check_breaks_existing_packages�s�	



����

�
�
����

�����	z)DebPackage.check_breaks_existing_packagesTcCs�|�dd�|jd}|jd}d�||g�}|jd}|�dd|�||jvr�|j|}|rt|jd	urt|jj}n|s�|jd	ur�|jj}n|jS|d	ur�t�	||�}|�dd
|�|dkr�|j
S|dkr�|jS|dkr�|jS|jS)a	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).
        r)�compare_to_version_in_cacher+r|rIrOrUz
debver: %sNz"CompareVersion(debver,instver): %sr)
r,rr�rrXrZrM�VERSION_NONEr0Zversion_compare�VERSION_SAME�
VERSION_NEWER�VERSION_OUTDATED)r&Z
use_installedrrPr�r`ZcacheverZcmprrrr��s.






z&DebPackage.compare_to_version_in_cachecCsD|�dd�d|_d|jvr6|�dd�td�|_dS|jd}|d	kr�|tj�d
�kr�|t��vr�||_	d|j
|j	f|_
|�dd|�n|�dd
�td�||_dS|s�|��|jkr�|j
|j
jr�td�|_dSd|_|��s�dS|��s�dS|�|j��s
dS|���sdS|j
jjdk�r@td�|_|j
��dSdS)z$Check if the package is installable.r)�checkTr|rUzERROR: no architecture fieldz$No Architecture field in the packageFrJzAPT::ArchitecturerKzFound multiarch arch: '%s'zERROR: Wrong architecture dude!zVWrong architecture '%s' -- Run dpkg --add-architecture to add it and update afterwardsz$A later version is already installedrrz1Failed to satisfy all dependencies (broken cache))r,r!rrCr"r0Zconfig�findZget_architecturesr#rr�r�rrXrzr��_satisfy_dependsrvreZbroken_count�clear)r&�allow_downgradeZarchrrrr�sN


���


zDebPackage.checkcCs|�t�|d��S)z-Satisfy the dependencies in the given string.F)r�r0rr)r&Z
dependsstrrrr�satisfy_depends_strEszDebPackage.satisfy_depends_strc	Cs�zt�|jj�}|Wnty(Yn0|D]}|�|�s.|�|�s.dSq.|jD]J}z|j|jdd�WqTt	y�t
d�||_|j��YdS0qTdS)zSatisfy the dependencies.F)Z	from_userzCannot install '%s'T)
r0ZActionGrouprre�AttributeErrorrbrhr Zmark_installrBrCr"r�)r&rvZ_actiongroupr[r`rrrr�Js"



zDebPackage._satisfy_dependscCs&|�dd|j�|js td��|jS)zReturn missing dependencies.rUzInstalling: %s�-property only available after check() was run)r,r r!r�rDrrr�missing_depsbs�zDebPackage.missing_depscCs�g}g}g}|jstd��|jD]h}|js0|jrv|jdus>J�|�|j�d}|jjD]}||j	O}qV|sv|�|j�|j
r |�|j�q |||fS)z�Get the changes required to satisfy the dependencies.

        Returns: a tuple with (install, remove, unauthenticated)
        r�NF)r!r�rriZmarked_upgraderMr8r9ZoriginsZtrustedZ
marked_delete)r&�install�removeZunauthenticatedr`Z
authenticated�originrrr�required_changesls&�
zDebPackage.required_changescCs>d}t|�D],\}}|ddkr(|d7}|dt|�7}q|S)Nr�Pr�
z%2.2x )r��ord)�in_data�hexr��crrr�to_hex�szDebPackage.to_hexcCsxd}t|t�rD|D].}t|�dks.t|�dkr8|d7}q||7}qn0|D]*}|dks\|dkrf|d7}qH|t|�7}qH|S)Nr�
�� )�
isinstance�strr��chr)r��sr��brrr�	to_strish�s


zDebPackage.to_strishc	Cs�|�d�r|dd�}|�|�}|�d�r\|r\t|�}tj|d�}td��d�}||��7}z|�	d�WSt
y�td�}||�|�7}|YS0dS)Nz./rTz.gz)ZfileobjzAutomatically decompressed:

zutf-8z,Automatically converted to printable ascii:
)�
startswithr/�endswithr�gzipZGzipFilerC�encode�read�decode�	Exceptionr�)	r&�partr9Zauto_decompressZauto_hexr<�ioZgzZnew_datarrr�_get_content�s

zDebPackage._get_contentcCs,z|�|jj|�WSty&YdS0dS�z6 return the content of a specific control.tar.gz file rN)r�rr*�LookupError�r&r9rrr�control_content�szDebPackage.control_contentcCs,z|�|jj|�WSty&YdS0dSr�)r�rr<r�r�rrr�data_content�szDebPackage.data_contentcCs||jkrt|tjd�dS)z%Write debugging output to sys.stderr.)�fileN)�debug�print�sys�stderr)r&�level�msgrrrr,�s
zDebPackage._dbgcCs�|jdurt�d��|dur2t�tjddd|j�Sz|��WntyX|��Yn0|�	|j�}z|�
�Wnty�|��Yn0|SdS)zInstall the package.NzNo filename specifiedZdpkgz-i)rr0�Error�os�spawnlp�P_WAITZstart_updater�ZstartUpdate�runZ
finish_updateZfinishUpdate)r&Zinstall_progressryrrrr��s

zDebPackage.install)NN)F)T)F)TT)N)+rrrr�ranger�r�r�r�r�r(r$r5r6�propertyrErHrSrbrhrlrortrvrwrxrjrzr�r�r�r�r�r�r��staticmethodr�r�r�r�r�r,r�rrrrr'sb�


�
%/.!
	


	
	Y
$
?
	

	

rc@sPeZdZdZddd�Zedd��Zedd��Zed	d
��Zdd�Z	ddd�Z
dS)�
DscSrcPackagez#A locally available source package.NcCsTt�|d|�||_g|_g|_t�|_d|_g|_i|_	|jdurP|�
|j�dS)Nr)rr(r�_depends�
_conflictsr-r.r�binariesrr$r%rrrr(�s
zDscSrcPackage.__init__cCs|jS�z&Return the dependencies of the package)r�rDrrrrv�szDscSrcPackage.dependscCs|jSr�)r�rDrrrrt�szDscSrcPackage.conflictscCs|jd��ddd�S)z6Return the list of files associated with this dsc fileZFilesrTNr))r�splitrDrrrrE�szDscSrcPackage.filelistc
Cs.ddg}ddg}t�|�}t�|�}t�|�}z�|D]�}|D]$}||vrJq<|j�t�||��q<|D]$}||vrtqf|j�t�||��qfd|vr�|d|_	d|vr�dd�|d�
d	�D�|_|��D]}||vr�|||j
|<q�q4W~|��n~|��0td
�|j	d�|j�f}	|	|j
d<d
|_dS)zOpen the package.z
Build-DependszBuild-Depends-IndepzBuild-ConflictszBuild-Conflicts-IndepZSourceZBinarycSsg|]}|���qSr)�strip)r}r�rrrrr@z&DscSrcPackage.open.<locals>.<listcomp>r�zBInstall Build-Dependencies for source package '%s' that builds %s
r�ZDescriptionFN)r0Zopen_maybe_clear_signed_filer��fdopenZTagFiler�ruZparse_src_dependsr�rr�r��keysr�closerCr�r!)
r&r�Zdepends_tagsZconflicts_tags�fdZfobjZtagfileZsec�tagr�rrrr$sF



�
�

��
zDscSrcPackage.openFcCsN|��s<|jD],}|j|jjr,ttd���|j|��qd|_|�	|j
�S)z�Check if the package is installable.

        The second parameter is ignored and only exists for compatibility
        with parent type.z%An essential package would be removedT)rzr.rrfZ	essentialr�rCZmark_deleter!r�rv)r&r�rrrrr�*s
zDscSrcPackage.check)NN)F)rrrrr(r�rvrtrEr$r�rrrrr��s




$r�c
Csddlm}ddlm}|�}d}td||�|�f�|�|�}td|�|D]}td|j�qRtt	j
d|�}td	|j�|��s�td
�t|j
�td|j�t|j�t|j�td�|�|��}t|�t|d
�}d}	t|�t�|	d���dS)z
Test functionr)r)�InstallProgresszwww-browserz%s virtual: %szProviders for %s :z %srUzDeb: %szcan't be satifiedzmissing deps: %szInstalling ...)r'z:libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)FN)Z	apt.cacherZapt.progress.baser�r�rLrVr9rr��argvrr�r"r�r�rEr�r�r�r0rr)
rr�r'Zvprgr`�dZretr�Zdsrrr�_test<s.




r��__main__)rZ
__future__rrrr0r�r�r��typingrrrrrrr	r
rrCr�r�IOErrorr
�objectrr�r�rrrrr�<module>s*(AY'