bg<dZddlZ ddlZn #e$rdZYnwxYwddlmZddlmZddlm Z ddl m Z  ddl m Z n #e$rdZ YnwxYw dd l mZn #e$rdZYnwxYwd Zd Z ddZddZedgdfedgdfedgdfedgdfedgdfegdfdZdZ d dZdS)!zodistutils.archive_util Utility functions for creating archive files (tarballs, zip files, that sort of thing).N)log)mkpath)DistutilsExecError)spawn)getpwnam)getgrnamcvt|dS t|}n#t$rd}YnwxYw||dSdS)z"Returns a gid, given a group name.N)r KeyErrornameresults Y/opt/cloudlinux/venv/lib64/python3.11/site-packages/setuptools/_distutils/archive_util.py_get_gidr\4<t$  ay 4  ,,cvt|dS t|}n#t$rd}YnwxYw||dSdS)z"Returns an uid, given a user name.Nr )rr r s r_get_uidr+rrgzipFcX ddddd}dddd }|%||vrtd |d z} | ||dz } ttj| | dd l} tj dtt fd} |se| | d||} | || | n#| wxYw| S)aCreate a (possibly compressed) tar file from all the files under 'base_dir'. 'compress' must be "gzip" (the default), "bzip2", "xz", or None. '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. gzbz2xz)rbzip2rNz.gzz.bz2z.xz)rrrNz=bad value for 'compress': must be None, 'gzip', 'bzip2', 'xz'z.tardry_runrzCreating tar archivecH|_|_|_|_|S)N)gidgnameuiduname)tarinfor groupownerr"s r _set_uid_gidz"make_tarball.._set_uid_gidjs. ?GK!GM ?GK!GMzw|)filter)keys ValueErrorgetrospathdirnametarfilerinforropenaddclose) base_namebase_dircompressverboserr&r%tar_compression compress_ext archive_namer0r'tarr r"s `` @@r make_tarballr=8sr0 O "F%@@L 0A0A0C0C C C K   v%LL$$Xr222L 27??< ( ('::::NNNH #$$$ 5//C 5//C ll<)Ioh.G)I)IJJ  GGH\G 2 2 2 IIKKKKCIIKKKK s %DD'c (|dz}ttj||t@|rd}nd} t d|||g|n8#t $rt d|dwxYwtjd |||s t j |d tj }n1#t$r$t j |d tj }YnwxYw|5|tj krhtjtj|d }|||tjd |tj|D]\}} } | D]k} tjtj|| d }|||tjd |l| D]} tjtj|| }tj|r+|||tjd | dddn #1swxYwY|S)avCreate a zip file from all the files under 'base_dir'. The output zip file will be named 'base_name' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed and found on the default search path). If neither tool is available, raises DistutilsExecError. Returns the name of the output zip file. z.ziprNz-rz-rqzipzunable to create zip file 'zN': could neither import the 'zipfile' module nor find a standalone zip utilityz#creating '%s' and adding '%s' to itw) compressionrz adding '%s')rr-r.r/zipfilerrrr1ZipFile ZIP_DEFLATED RuntimeError ZIP_STOREDcurdirnormpathjoinwritewalkisfile) r5r6r8r zip_filename zipoptionsr?r.dirpathdirnames filenamesrs r make_zipfilerR}sv%L 27??< ( ('::::  JJJ  5*lH=w O O O O O!   %0l000   6 hOOO : Yo #73G  Y Y YolCWEWXXX Y : :ry((7++BGLL2,F,FGGDIIdD)))H]D11146GH4E4E : :0GXy (66!w// WdB0O0OPP $---5555 )::!w// Wd0K0KLL7>>$//:IIdD111H]D999 : :  : : : : : : : : : : : : : : : s1AA8!B77+C%$C%*FJJ J )r7rzgzip'ed tar-file)r7rzbzip2'ed tar-file)r7rzxz'ed tar-file)r7r7zcompressed tar file)r7Nzuncompressed tar filezZIP file)gztarbztarxztarztarr<r?c*|D]}|tvr|cSdS)zqReturns the first format from the 'format' list that is unknown. If all formats are known, returns None N)ARCHIVE_FORMATS)formatsformats rcheck_archive_formatsr[s1   ( (MMM ) 4r(c~tj}|Jtjd|tj|}|stj|| tj}d|i} t|} n!#t$rtd|dwxYw| d} | | d|dkr || d <|| d < | ||fi| } |)tjd |tj|n1#|*tjd |tj|wwxYw| S) aCreate an archive file (eg. zip or tar). 'base_name' is the name of the file to create, minus any format-specific extension; 'format' is the archive format: one of "zip", "tar", "gztar", "bztar", "xztar", or "ztar". 'root_dir' is a directory that will be the root directory of the archive; ie. we typically chdir into 'root_dir' before creating the archive. 'base_dir' is the directory where we start archiving from; ie. 'base_dir' will be the common prefix of all files and directories in the archive. 'root_dir' and 'base_dir' both default to the current directory. Returns the name of the archive file. 'owner' and 'group' are used when creating a tar archive. By default, uses the current owner and group. Nzchanging into '%s'rzunknown archive format ''rrr?r&r%zchanging back to '%s') r-getcwdrdebugr.abspathchdirrGrXr r+update) r5rZroot_dirr6r8rr&r%save_cwdkwargs format_infofuncfilenames r make_archiverisr4y{{H &111GOOI..   HX   9 !F?%f- ???=F===>>>? q>D MM+a.!!! ww4 866v66   I-x 8 8 8 HX      I-x 8 8 8 HX      Os3 BB D .D:)rFFNN)FF)NNFFNN)__doc__r-rB ImportError_logrdir_utilrerrorsrrpwdrgrpr rrr=rRrXr[rir(rrrs  NNNNGGG&&&&&&HHHHHH           BBBBJ::::|124F G235H I/02B C 457L M -.0G H "j )      999999s- :AAAAA