HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/debian/__pycache__/debfile.cpython-38.pyc
U

&]�^p:�@sbdZddlmZmZddlZddlZddlZddlZz0ddl	m
Z
mZmZm
Z
mZmZmZmZmZWnek
rxYnXddlmZmZmZddlmZddlmZdZd	Zd
ddd
gZdZdddddgZ dZ!dZ"dZ#dZ$Gdd�de�Z%Gdd�de&�Z'Gdd�de'�Z(Gdd�de'�Z)Gd d!�d!e�Z*e+d"k�r^e*ej,d#d$�Z-e-j.�/�Z/e0e/�1d��dS)%zX Representation of Debian binary package (.deb) files


Debfile Classes
===============
�)�absolute_import�print_functionN)	�Any�Dict�IO�Iterator�List�Optional�Text�TypeVar�Union)�ArFile�ArError�ArMember)�	Changelog)�Deb822zdata.tarzcontrol.tar�gz�bz2�xzZlzmaz
debian-binaryZpreinstZpostinstZprermZpostrmZconfig�controlzusr/share/doc/%s/changelog.gzz$usr/share/doc/%s/changelog.Debian.gz�md5sumsc@seZdZdS)�DebErrorN��__name__�
__module__�__qualname__�rr�0/usr/lib/python3/dist-packages/debian/debfile.pyrAsrc@szeZdZdZdd�Zdd�Zedd��Zdd	�Zddd�Z	dd
d�Z
dd�Zdd�Ze
jdkrfdd�Zdd�Zdd�Zd
S)�DebParta�'Part' of a .deb binary package.

    A .deb package is considered as made of 2 parts: a 'data' part
    (corresponding to the possibly compressed 'data.tar' archive embedded
    in a .deb) and a 'control' part (the 'control.tar.gz' archive). Each of
    them is represented by an instance of this class. Each archive should
    be a compressed tar archive although an uncompressed data.tar is permitted;
    supported compression formats are: .tar.gz, .tar.bz2, .tar.xz .

    When referring to file members of the underlying .tar.gz archive, file
    names can be specified in one of 3 formats "file", "./file", "/file". In
    all cases the file is considered relative to the root of the archive. For
    the control part the preferred mechanism is the first one (as in
    deb.control.get_content('control') ); for the data part the preferred
    mechanism is the third one (as in deb.data.get_file('/etc/vim/vimrc') ).
    cCs||_d|_dS�N)�_DebPart__member�
_DebPart__tgz)�self�memberrrr�__init__WszDebPart.__init__c	
sp|jdk�rj|jj}tj�|�ddd�}|tksF|tksF|tk�r^t	j
dk�r|dk�rz@ddl}ddl�ddl
}|jddg|j|jd�fd	d
�d�}Wn2ttfk
r�}ztd|��W5d}~XYnX|�|j���d}|jdkr�td
|j��|�|�}n|j}ztj|dd�|_Wn8tjtjfk
�rZ}ztd|��W5d}~XYnXntd|��|jS)z�Return a TarFile object corresponding to this part of a .deb
        package.

        Despite the name, this method gives access to various kind of
        compressed tar archives, not only gzipped ones.
        N�)�r&rrZunxzz--stdoutFcs���j�j�Sr)�signal�SIGPIPE�SIG_DFLr�r'rr�<lambda>uszDebPart.tgz.<locals>.<lambda>)�stdin�stdoutZuniversal_newlinesZ
preexec_fnz%sz!command has failed with code '%s'zr:*)�fileobj�modez#tarfile has returned an error: '%s'z"part '%s' has unexpected extension)r!r �name�os�path�splitext�	PART_EXTS�	DATA_PART�	CTRL_PART�sys�version_info�
subprocessr'�io�Popen�PIPE�OSError�
ValueErrorrZcommunicate�read�
returncode�BytesIO�tarfile�openZ	ReadErrorZCompressionError)	r"r0�	extensionr9r:�proc�e�data�bufferrr*r�tgz\s>	
�

� zDebPart.tgzcCs2|�d�r|dd�}n|�d�r.|dd�}|S)zw try (not so hard) to obtain a member file name in a form relative
        to the .tar.gz root and with no heading '.' �./�N�/r%)�
startswith)�fnamerrrZ__normalize_member�s


zDebPart.__normalize_membercCs*t�|�}|����}d||kp(||kS)z.Check if this part contains a given file name.rJ)r�_DebPart__normalize_memberrI�getnames)r"rN�namesrrr�has_file�s

�zDebPart.has_fileNcCs�t�|�}z|���d|�}Wn"tk
rB|���|�}YnX|dkrTtd��|dk	r�tjdkr�ddl}t	|d�s�dd�|_
|j|||d	�Sddl}|dkr�d
}|j
|||d�S|S)z�Return a file object corresponding to a given file name.

        If encoding is given, then the file object will return Unicode data;
        otherwise, it will return binary data.
        rJNzFile not found inside package�3r�flushcSsdSrrrrrrr+��z"DebPart.get_file.<locals>.<lambda>��encoding�errors�strict)rX)rrOrIZextractfile�KeyErrorrr7�versionr:�hasattrrT�
TextIOWrapper�codecs�EncodedFile)r"rNrWrXZfobjr:r^rrr�get_file�s$



zDebPart.get_filecCs,|j|||d�}d}|r(|��}|��|S)z�Return the string content of a given file, or None (e.g. for
        directories).

        If encoding is given, then the content will be a Unicode object;
        otherwise, it will contain binary data.
        rVN)r`r?�close)r"rNrWrX�fZcontentrrr�get_content�s
zDebPart.get_contentcCst|�����Sr)�iterrIrP�r"rrr�__iter__�szDebPart.__iter__cCs
|�|�Sr�rR�r"rNrrr�__contains__�szDebPart.__contains__rScCs
|�|�Srrgrhrrr�has_key�szDebPart.has_keycCs
|�|�Sr)rcrhrrr�__getitem__�szDebPart.__getitem__cCs|j��dSr)r rarerrrra�sz
DebPart.close)NN)NN)rrr�__doc__r$rI�staticmethodrOrRr`rcrfrir7r[rjrkrarrrrrEs 0
	
!�

rc@seZdZdS)�DebDataNrrrrrrn�srnc@s&eZdZdd�Zdd�Zddd�ZdS)	�
DebControlcCs*i}tD]}|�|�r|�|�||<q|S)zo Return a dictionary of maintainer scripts (postinst, prerm, ...)
        mapping script names to script text. )�
MAINT_SCRIPTSrRrc)r"�scriptsrNrrrrq�s

zDebControl.scriptscCst|�t��S)z� Return the debian/control as a Deb822 (a Debian-specific dict-like
        class) object.

        For a string representation of debian/control try
        .get_content('control') )rrc�CONTROL_FILErerrr�
debcontrolszDebControl.debcontrolNc	Cs�|�t�stdt��|jt||d�}i}d}|dkr:d}|��D]D}|�|��dd�\}}tjdkr~t	|t
�r~|��||<qB|||<qB|��|S)a� Return a dictionary mapping filenames (of the data part) to
        md5sums. Fails if the control part does not contain a 'md5sum' file.

        Keys of the returned dictionary are the left-hand side values of lines
        in the md5sums member of control.tar.gz, usually file names relative to
        the file system root (without heading '/' or './').

        The returned keys are Unicode objects if an encoding is specified,
        otherwise binary. The returned values are always Unicode.z('%s' file not found, can't list MD5 sumsrVz
Ns
r%rS)
rR�MD5_FILErr`�	readlines�rstrip�splitr7r[�
isinstance�bytes�decodera)	r"rWrXZmd5_fileZsums�newline�lineZmd5rNrrrrs 
�
zDebControl.md5sums)NN)rrrrqrsrrrrrro�s
roc@speZdZdZddd�Zdd�Zedd	��Zed
d	��Zedd	��Z	dd
�Z
dd�Zddd�Zdd�Z
dd�ZdS)�DebFilea�Representation of a .deb file (a Debian binary package)

    DebFile objects have the following (read-only) properties:
        - version       debian .deb file format version (not related with the
                        contained package version), 2.0 at the time of writing
                        for all .deb packages in the Debian archive
        - data          DebPart object corresponding to the data.tar.gz (or
                        other compressed or uncompressed tar) archive contained
                        in the .deb file
        - control       DebPart object corresponding to the control.tar.gz (or
                        other compressed tar) archive contained in the .deb
                        file
    N�rcs�t�||||�t|�����fdd�}t�kr<tdt��i|_t|�|t	���|jt	<t
|�|t���|jt<d|_|�t�}|�
���|_|��dS)Ncsr�fdd�tD�}�ttfkr(|�����t|��}|sHtd|��n&t|�dkrbtd|��nt|�dSdS)Ncsg|]}d�|f�qS)z%s.%sr)�.0Zext��basenamerr�
<listcomp>HszBDebFile.__init__.<locals>.compressed_part_name.<locals>.<listcomp>z9missing required part in given .deb (expected one of: %s)r%z>too many parts in given .deb (was looking for only one of: %s)r)	r4r5r6�append�intersection�setr�len�list)r�Z
candidates�parts�Zactual_namesr�r�compressed_part_nameFs"
����z.DebFile.__init__.<locals>.compressed_part_namez4missing required part in given .deb (expected: '%s'))r
r$r�rP�	INFO_PARTr�_DebFile__partsro�	getmemberr6rnr5�_DebFile__pkgnamer?�strip�_DebFile__versionra)r"�filenamer/r.r�rbrr�rr$As(����
zDebFile.__init__cCs|��d|_dS)N�package)rsr�rerrrZ__updatePkgNamehszDebFile.__updatePkgNamecCs|jSr)r�rerrrr+krUzDebFile.<lambda>cCs
|jtSr)r�r5rerrrr+lrUcCs
|jtSr)r�r6rerrrr+mrUcCs
|j��S)z See .control.debcontrol() )rrsrerrrrsqszDebFile.debcontrolcCs
|j��S)z See .control.scripts() )rrqrerrrrqvszDebFile.scriptscCs|jj||d�S)z See .control.md5sums() rV)rr)r"rWrXrrrr{szDebFile.md5sumscCsl|jdkr|��t|jt|jfD]@}|j�|�r&tj|j�|�d�}|�	�}|�
�t|�Sq&dS)z� Return a Changelog object for the changelog.Debian.gz of the
        present .deb package. Return None if no changelog can be found. N)r.)r��_DebFile__updatePkgName�CHANGELOG_DEBIAN�CHANGELOG_NATIVErGrR�gzipZGzipFiler`r?rar)r"rNrZ
raw_changelogrrr�	changelog�s
�zDebFile.changelogcCs|j��|j��dSr)rrarGrerrrra�s
z
DebFile.close)Nr~N)NN)rrrrlr$r��propertyr[rGrrsrqrr�rarrrrr}1s
'
r}�__main__r%)r�)2rlZ
__future__rrr�rBr7�os.pathr1�typingrrrrrr	r
rr�ImportErrorZ
debian.arfiler
rrZdebian.changelogrZ
debian.deb822rr5r6r4r�rprrr�r�rtr�objectrrnror}r�argvZdebrrI�printr�rrrr�<module>s>0.:f