File: //lib/python3.10/distutils/__pycache__/archive_util.cpython-310.pyc
o
    ��bc|!  �                   @   sF  d Z ddlZddlmZ ddlZzddlZW n ey!   dZY nw ddlmZ ddl	m
Z
 ddlmZ ddl
mZ zddlmZ W n eyM   dZY nw zdd	lmZ W n eya   dZY nw d
d� Zdd
� Z		d#dd�Zd$dd�Zedgdfedgdfedgdfedgdfedgdfeg dfd�Zdd � Z		d%d!d"�ZdS )&zodistutils.archive_util
Utility functions for creating archive files (tarballs, zip files,
that sort of thing).�    N)�warn)�DistutilsExecError)�spawn)�mkpath)�log)�getpwnam)�getgrnamc                 C   �L   t du s| du r
dS zt | �}W n ty   d}Y nw |dur$|d S dS )z"Returns a gid, given a group name.N�   )r   �KeyError��name�result� r   �-/usr/lib/python3.10/distutils/archive_util.py�_get_gid   �   �r   c                 C   r	   )z"Returns an uid, given a user name.Nr
   )r   r   r   r   r   r   �_get_uid+   r   r   �gzipc                    s2  dddddd�}dddd	d
�}|dur||� � vrtd��| d
 }	|dkr-|	|�|d�7 }	ttj�|	�|d� ddl}
t�	d� t
���t��� � ���fdd�}|sp|
�|	d||  �}z
|j
||d� W |��  n|��  w |dkr�tdt� |	||  }
tjdkr�||	|
g}n|d|	g}t||d� |
S |	S )a=  Create a (possibly compressed) tar file from all the files under
    'base_dir'.
    'compress' must be "gzip" (the default), "bzip2", "xz", "compress", or
    None.  ("compress" will be deprecated in Python 3.2)
    'owner' and 'group' can be used to define an owner and a group for the
    archive that is being built. If not provided, the current owner and group
    will be used.
    The output tar file will be named 'base_dir' +  ".tar", possibly plus
    the appropriate compression extension (".gz", ".bz2", ".xz" or ".Z").
    Returns the output filename.
    �gz�bz2�xz� )r   �bzip2r   N�compressz.gzz.bz2z.xzz.Z)r   r   r   r   NzKbad value for 'compress': must be None, 'gzip', 'bzip2', 'xz' or 'compress'z.tarr   ��dry_runr   zCreating tar archivec                    s,   � d ur
� | _ �| _�d ur�| _�| _| S )N)�gid�gname�uid�uname)�tarinfo�r   �group�ownerr   r   r   �_set_uid_gida   s   z"make_tarball.<locals>._set_uid_gidzw|%s)�filterz'compress' will be deprecated.�win32z-f)�keys�
ValueError�getr   �os�path�dirname�tarfiler   �infor   r   �open�add�closer   �PendingDeprecationWarning�sys�platformr   )�	base_name�base_dirr   �verboser   r$   r#   �tar_compression�compress_ext�archive_namer.   r%   �tar�compressed_name�cmdr   r"