U
e5d|! ã @ sD d Z ddlZddlmZ ddlZzddlZW n ek
rD dZY nX ddlmZ ddl m
Z
ddlmZ ddl
mZ zddlmZ W n ek
rž dZY nX zdd lmZ W n ek
rÈ dZY nX d
d„ Zdd
„ Zd#dd„Zd$dd„Zedgdfedgdfedgdfedgdfedgdfeg dfdœZdd „ Zd%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 sN t dks| dkrdS zt | ƒ}W n tk
r8 d}Y nX |dk rJ|d S dS )z"Returns a gid, given a group name.Né )r ÚKeyError©ÚnameÚresult© r ú./usr/lib64/python3.8/distutils/archive_util.pyÚ_get_gid s
r c C sN t dks| dkrdS zt | ƒ}W n tk
r8 d}Y nX |dk rJ|d S dS )z"Returns an uid, given a user name.Nr )r r
r r r r Ú_get_uid+ s
r Úgzipc s. ddddddœ}dddd d
œ}|dk r:|| ¡ kr:tdƒ‚| d
} |dkrZ| | |d¡7 } ttj | ¡|d� ddl}
t d¡ t
ˆƒ‰tˆƒ‰ ‡ ‡‡‡fdd„}|sØ|
| d|| ¡}z|j||d� W 5 |
¡ X |dk�r*tdtƒ | || }
tjdk�r|| |
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.
ZgzÚ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 k rˆ | _ ˆ| _ˆd k r(ˆ| _ˆ| _| S )N)ÚgidZgnameÚuidÚuname)Ztarinfo©r ÚgroupÚownerr r r Ú_set_uid_gida s z"make_tarball.