3 \F! @s@ddlZddlmZddlZy ddlZWnek r@dZYnXddlmZddlm Z ddl m Z ddl m Z yddlmZWnek rdZYnXyddlmZWnek rdZYnXd d Zd d Zd ddZd!ddZed"gdfed#gdfed$gdfed%gdfed&gdfegdfdZddZd'ddZdS)(N)warn)DistutilsExecError)spawn)mkpath)log)getpwnam)getgrnamc CsNtdks|dkrdSy t|}Wntk r8d}YnX|dk rJ|dSdS)N)rKeyError)nameresultr ./usr/lib64/python3.6/distutils/archive_util.py_get_gids  rc CsNtdks|dkrdSy t|}Wntk r8d}YnX|dk rJ|dSdS)Nr )rr )r r r r r_get_uid+s  rgzipc s.dddddd}dddd d }|dk r:||jkr:td |d } |d krZ| |j|d7} ttjj| |dddl} tj dt t fdd} |s| j | d||} z| j || dWd| jX|d kr*tdt| ||} tjdkr|| | g}n |d| g}t||d| S| S)NZgzbz2xz)rbzip2rNcompressz.gzz.bz2z.xzz.Z)rrrrzKbad value for 'compress': must be None, 'gzip', 'bzip2', 'xz' or 'compress'z.tarr)dry_runrzCreating tar archivecs,dk r|_|_dk r(|_|_|S)N)gidZgnameuiduname)Ztarinfo)rgroupownerrr r _set_uid_gidasz"make_tarball.._set_uid_gidzw|%s)filterz'compress' will be deprecated.Zwin32z-f)keys ValueErrorgetrospathdirnametarfilerinforropenaddcloserPendingDeprecationWarningsysplatformr) base_namebase_dirrverboserrrZtar_compressionZ compress_extZ archive_namer%rtarZcompressed_namecmdr )rrrrr make_tarball7s<          r2c Cs|d}ttjj||dtdkrp|r.d}nd}ytd|||g|dWn tk rjtd|YnXn:tjd|||sytj |dtj d }Wn&t k rtj |dtj d }YnX|tj krtjjtjj|d }|j||tjd |xtj|D]\}} } x>| D]6} tjjtjj|| d }|j||tjd |qWxJ| D]B} tjjtjj|| }tjj|rV|j||tjd |qVWqW|j|S) Nz.zip)rz-rz-rqzipzkunable to create zip file '%s': could neither import the 'zipfile' module nor find a standalone zip utilityz#creating '%s' and adding '%s' to itw)Z compressionrz adding '%s')rr"r#r$zipfilerrrr&ZZipFileZ ZIP_DEFLATED RuntimeErrorZ ZIP_STOREDcurdirnormpathjoinwritewalkisfiler)) r-r.r/rZ zip_filenameZ zipoptionsr3r#dirpathZdirnames filenamesr r r r make_zipfilesJ          r?rzgzip'ed tar-filerzbzip2'ed tar-filerzxz'ed tar-filezcompressed tar filezuncompressed tar filezZIP file)ZgztarZbztarZxztarZztarr0r3cCsx|D]}|tkr|SqWdS)N)ARCHIVE_FORMATS)Zformatsformatr r rcheck_archive_formatss rBcCstj}|dk r6tjd|tjj|}|s6tj||dkrDtj}d|i} y t|} Wn t k rxt d|YnX| d} x| dD]\} } | | | <qW|dkr|| d<|| d<z| ||f| }Wd|dk rtjd |tj|X|S) Nzchanging into '%s'rzunknown archive format '%s'rr3rrzchanging back to '%s') r"getcwdrdebugr#abspathchdirr7r@r r )r-rAZroot_dirr.r/rrrZsave_cwdkwargsZ format_infofuncargvalfilenamer r r make_archives2       rM)rrrNN)rr)rr)rr)rr)rr)rN)NNrrNN)r"warningsrr+r5 ImportErrorZdistutils.errorsrZdistutils.spawnrZdistutils.dir_utilrZ distutilsrpwdrZgrprrrr2r?r@rBrMr r r rs@            G =