
    ,hU                         d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZmZmZmZ dd	lmZ dd
lmZ  G d de	      Zy)zwdistutils.command.bdist_rpm

Implements the Distutils 'bdist_rpm' command (create RPM source and binary
distributions).    N)log)ClassVar   )Command)DEBUG)DistutilsExecErrorDistutilsFileErrorDistutilsOptionErrorDistutilsPlatformError)
write_file)get_python_versionc                       e Zd ZU dZg dZg dZeee      e	d<   ddddZ
eeeef      e	d	<   d
 ZddZddZddZd Zd Zd Zy)	bdist_rpmzcreate an RPM distribution)))zbdist-base=Nz/base directory for creating built distributions)z	rpm-base=Nzdbase directory for creating RPMs (defaults to "rpm" under --bdist-base; must be specified for RPM 2))z	dist-dir=dzDdirectory to put final RPM files in (and .spec files if --spec-only))zpython=NzMpath to Python interpreter to hard-code in the .spec file [default: "python"])z
fix-pythonNzLhard-code the exact path to the current Python interpreter in the .spec file)z	spec-onlyNzonly regenerate spec file)zsource-onlyNzonly generate source RPM)zbinary-onlyNzonly generate binary RPM)z	use-bzip2Nz7use bzip2 instead of gzip to create source distribution)zdistribution-name=Nzgname of the (Linux) distribution to which this RPM applies (*not* the name of the module distribution!))zgroup=Nz9package classification [default: "Development/Libraries"])zrelease=NzRPM release number)zserial=NzRPM serial number)zvendor=NzaRPM "vendor" (eg. "Joe Blow <joe@example.com>") [default: maintainer or author from setup script])z	packager=NzBRPM packager (eg. "Jane Doe <jane@example.net>") [default: vendor])z
doc-files=Nz6list of documentation files (space or comma-separated))z
changelog=NzRPM changelog)zicon=Nzname of icon file)z	provides=Nz%capabilities provided by this package)z	requires=Nz%capabilities required by this package)z
conflicts=Nz-capabilities which conflict with this package)zbuild-requires=Nz+capabilities required to build this package)z
obsoletes=Nz*capabilities made obsolete by this package)
no-autoreqNz+do not automatically calculate dependencies)	keep-tempkz"don't clean up RPM build directory)no-keep-tempNz&clean up RPM build directory [default])use-rpm-opt-flagsNz8compile with RPM_OPT_FLAGS when building from source RPM)no-rpm-opt-flagsNz&do not pass any RPM CFLAGS to compiler)	rpm3-modeNz"RPM 3 compatibility mode (default))	rpm2-modeNzRPM 2 compatibility mode)zprep-script=Nz3Specify a script for the PREP phase of RPM building)zbuild-script=Nz4Specify a script for the BUILD phase of RPM building)zpre-install=Nz:Specify a script for the pre-INSTALL phase of RPM building)zinstall-script=Nz6Specify a script for the INSTALL phase of RPM building)zpost-install=Nz;Specify a script for the post-INSTALL phase of RPM building)zpre-uninstall=Nz<Specify a script for the pre-UNINSTALL phase of RPM building)zpost-uninstall=Nz=Specify a script for the post-UNINSTALL phase of RPM building)zclean-script=Nz4Specify a script for the CLEAN phase of RPM building)zverify-script=Nz6Specify a script for the VERIFY phase of the RPM build)zforce-arch=Nz0Force an architecture onto the RPM build process)quietqz3Run the INSTALL phase of RPM building in quiet mode)r   r   r   r   r   boolean_optionsr   r   r   )r   r   r   negative_optc                 &   d | _         d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _	        d | _
        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _        d | _         d| _!        d| _"        d| _#        d| _$        d | _%        d| _&        y )NFT)'
bdist_baserpm_basedist_dirpython
fix_python	spec_onlybinary_onlysource_only	use_bzip2distribution_namegroupreleaseserialvendorpackager	doc_files	changelogiconprep_scriptbuild_scriptinstall_scriptclean_scriptverify_scriptpre_installpost_installpre_uninstallpost_uninstallprepprovidesrequires	conflictsbuild_requires	obsoletes	keep_tempuse_rpm_opt_flags	rpm3_mode
no_autoreq
force_archr   selfs    i/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/_distutils/command/bdist_rpm.pyinitialize_optionszbdist_rpm.initialize_options   s!   !%
	 " ! !"	"!%
    Nc                    | j                  dd       | j                  F| j                  st        d      t        j
                  j                  | j                  d      | _        | j                  *| j                  rt        j                  | _        nd| _        n| j                  rt        d      t        j                  dk7  rt        dt        j                         | j                  r| j                  rt        d	      | j                   j#                         sd
| _        | j                  dd       | j'                          y )Nbdist)r   r   z)you must specify --rpm-base in RPM 2 moderpmpython3z8--python and --fix-python are mutually exclusive optionsposixz7don't know how to create RPM distributions on platform z6cannot supply both '--source-only' and '--binary-only'F)r    r    )set_undefined_optionsr   rA   r
   ospathjoinr   r!   r"   sys
executablenamer   r$   r%   distributionhas_ext_modulesr@   finalize_package_datarD   s    rF   finalize_optionszbdist_rpm.finalize_options   s	   ""7,HI== >>*+VWWGGLL%@DM;;!nn'__&J  77g(I"''S   0 0&H 
   002%*D"""7,DE""$rH   c                    | j                  dd       | j                  d| j                  j                          d| j                  j                          d       | j                  d       | j	                  d       t        | j                  t              rQdD ]L  }t        j                  j                  |      s#|| j                  vs2| j                  j                  |       N | j                  d	d
       | j                  d       | j                  d       | j                  d       | j                  | j                        | _        | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j                  d       | j	                  d       | j	                  d       | j	                  d       | j	                  d       | j	                  d       | j                  d       y )Nr(   zDevelopment/Librariesr+   z <>r,   r-   )READMEz
README.txtr)   1r*   r'   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r:   r;   r<   r=   r>   rC   )ensure_stringrU   get_contactget_contact_emailensure_string_list
isinstancer-   listrO   rP   existsappend_format_changelogr.   ensure_filename)rE   readmes     rF   rW   zbdist_rpm.finalize_package_data   s   7$;<  ,,./r$2C2C2U2U2W1XXYZ	
 	:&,dnnd+2 277>>&)fDNN.JNN))&12 	9c*8$./;'//?V$]+^,-.^,_-]+^,_--. 	
+
+, 01,<(rH   c                 Z   t         rct        d       t        d| j                         t        d| j                         t        d| j                         t        d| j
                         | j                  r| j                  }| j                  |       nOi }dD ]C  }t        j                  j                  | j                  |      ||<   | j                  ||          E |d   }t        j                  j                  || j                  j                          d      }| j                  t         || j#                         fd	| d
       | j                  ry | j                  j$                  d d  }| j'                  d      }| j(                  r	dg|_        ndg|_        | j-                  d       || j                  _        |j/                         d   }d   }| j1                  ||       | j2                  r_t        j                  j5                  | j2                        r| j1                  | j2                  |       nt7        d| j2                   d      t9        j:                  d       dg}	| j<                  r|	j?                  d       n/| j@                  r|	j?                  d       n|	j?                  d       |	jC                  dd| jD                   g       | jF                  r=|	jC                  ddt        j                  jI                  | j                         g       | jJ                  s|	j?                  d       | jL                  r|	j?                  d       |	j?                  |       d}
|
dz   }d|
z   dz   }d | d!| d"| d
}t        jN                  |      }	 g }d }	 |jQ                         }|snJ|jS                         jU                         }tW        |      d#k(  sJ |j?                  |d$          ||d   }]|jY                         }|rt[        d%|      	 |jY                          | j]                  |	       | j^                  s| j                  ja                         rtc               }nd&}| j@                  st        j                  j                  |d'   |      }t        j                  j5                  |      sJ | je                  || j                         t        j                  j                  | j                  |      }| j                  j$                  j?                  d(||f       | j<                  s|D ]  }t        j                  j                  |d)   |      }t        j                  j5                  |      sF| je                  || j                         t        j                  j                  | j                  t        j                  jg                  |            }| j                  j$                  j?                  d(||f        y y y # |jY                          w xY w)*Nzbefore _get_package_data():zvendor =z
packager =zdoc_files =zchangelog =)SOURCESSPECSBUILDRPMSSRPMSrj   z.specz	writing ''sdistbztargztarr   ri   zicon file 'z' does not existzbuilding RPMsrpmbuildz-bsz-bbz-baz--definez	__python z_topdir z--cleanz--quietz%{name}-%{version}-%{release}z.src.rpmz%{arch}/z.%{arch}.rpmzrpm -q --qf ' z\n' --specfile 'r      zFailed to execute: anyrm   r   rl   )4r   printr+   r,   r-   r.   r#   r    mkpathrO   rP   rQ   r   rU   get_nameexecuter   _make_spec_file
dist_filesreinitialize_commandr&   formatsrun_commandget_archive_files	copy_filer/   rc   r	   r   infor%   rd   r$   extendr!   rA   abspathr?   r   popenreadlinestripsplitlencloser   spawndry_runrV   r   	move_filebasename)rE   spec_dirrpm_dirr   	spec_pathsaved_dist_filesro   source
source_dirrpm_cmd
nvr_stringsrc_rpmnon_src_rpmq_cmdoutbinary_rpms
source_rpmlineellstatus	pyversionsrpmfilenamerK   s                           rF   runzbdist_rpm.run  s   /0*dkk*,.-0-0 >>}}HKK!GC (WW\\$--;
GAJ'( w'H GGLLd.?.?.H.H.J-K5+QR	D$8$8$:;yST=U	
 >>  ,,77:))'2>>$IEM$IEM!'7$((*1-Y'
vz*99ww~~dii(tyy*5(;tyykAQ)RSS 	!,NN5!NN5!NN5!
i}$=>?>>NNJ(277??4==3Q2R(STU~~NN9%::NN9%y!
 5
z) :-> 	;-7G	{RSThhuo	KJ||~jjl((*3x1}$""3q6*%!$QJ  YY[F(+>ui)HII  IIK

7||  002.0	!	##ww||GG$4jAww~~d++tT]]377<<zB!!,,33[)X4VW##& 	C'',,wv<Cww~~c*sDMM:#%77<<rww?O?OPS?T#U))44;;'%$= 	 $ 	 IIKs   BX X*c                     t         j                  j                  | j                  t         j                  j	                  |            S )N)rO   rP   rQ   r    r   )rE   rP   s     rF   
_dist_pathzbdist_rpm._dist_path  s*    ww||DMM277+;+;D+ABBrH   c           	      
   d| j                   j                         z   d| j                   j                         j                  dd      z   d| j                   j                         z   d| j                  j                  dd      z   dd| j                   j                         xs d	z   g}t        j                  d
      }dj                  |j                         D cg c]  }d|j                          d c}      }d}d}|j                  ||      }||k7  r(|j                  d       |j                  d|z   dz          |j                  g d       | j                  r|j                  d       n|j                  d       |j                  d| j                   j                         xs d	z   d| j                  z   ddg       | j                   s,| j                   j#                         s0|j                  d       n|j                  d| j                           dD ]v  }t%        | |j'                               }t)        |t*              r1|j                  dj-                  |dj                  |                   ^|a|j                  | d|        x | j                   j/                         r,|j                  d | j                   j/                         z          | j0                  r|j                  d!| j0                  z          | j2                  r-|j                  d"dj                  | j2                        z          | j4                  r;|j                  d#t6        j8                  j;                  | j4                        z          | j<                  r|j                  d$       |j                  dd%| j                   j?                         xs dg       | j@                   dt6        j8                  j;                  tB        jD                  d&          }	|	 d'}
| jF                  rd(|
z   }
|	 d)}d*d+d,|
fd-d.|fd/d0d1d2d3d4g	}|D ]  \  }}}t%        | |      }|s|s|j                  dd5|z   g       |rCtI        |      5 }|j                  |jK                         jM                  d             ddd       s|j                  |        |j                  g d6       | jN                  r-|j                  d7dj                  | jN                        z          | jP                  r.|j                  dd8g       |j                  | jP                         |S c c}w # 1 sw Y   xY w)9ziGenerate the text of an RPM spec file and return it as a
        list of strings (one per line).
        z%define name z%define version -_z%define unmangled_version z%define release  z	Summary: UNKNOWNzrpm --eval %{__os_install_post}
  z \zbrp-python-bytecompile \
z%brp-python-bytecompile %{__python} \
z3# Workaround for https://bugs.python.org/issue14443z%define __os_install_post )zName: %{name}zVersion: %{version}zRelease: %{release}z-Source0: %{name}-%{unmangled_version}.tar.bz2z,Source0: %{name}-%{unmangled_version}.tar.gzz	License: zGroup: z>BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildrootzPrefix: %{_prefix}zBuildArch: noarchzBuildArch: )VendorPackagerProvidesRequires	Conflicts	Obsoletesz{}: {}rs   Nz: zUrl: zDistribution: zBuildRequires: zIcon: z
AutoReq: 0z%descriptionr   z buildzenv CFLAGS="$RPM_OPT_FLAGS" z< install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES)r9   r0   z&%setup -n %{name}-%{unmangled_version}buildr1   installr2   )cleanr3   zrm -rf $RPM_BUILD_ROOT)verifyscriptr4   N)prer5   N)postr6   N)preunr7   N)postunr8   N%)r   z%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z
%changelog))rU   rx   get_versionreplacer)   get_description
subprocess	getoutputrQ   
splitlinesr   rd   r   r&   get_licenser(   rC   rV   getattrlowerra   rb   formatget_urlr'   r=   r/   rO   rP   r   rB   get_long_descriptionr!   rR   argvr@   openreadr   r-   r.   )rE   	spec_filevendor_hookr   problemfixed
fixed_hookfieldvaldef_setup_call	def_buildinstall_cmdscript_optionsrpm_optattrdefaultfs                    rF   rz   zbdist_rpm._make_spec_file  s    d//88::!2!2!>!>!@!H!Hc!RR(4+<+<+H+H+JJ!5!5c3!??4,,<<>K)L
	 !**+LM ii/:/E/E/G!
'+bc"!
  09 ((%8
$RS9JFMN 	 
 	 >>LMKL4,,88:GiH

"L 	
 	 $$446  !45{4??*;<=
 	4E $.C#t$  !FG  E7"SE!23	4 $$&Wt'8'8'@'@'BBC!!-0F0FFG.$:M:M1NNO99X(8(8(CCD??\*224:
 	$ !KK="''*:*:388A;*G)HI%&f-	!!6BI (((de Nni0(+6?3(*,.

 '5 	."GT7 $%Cg  'M"  c ?a!(()=>? ? $$W-	.  	 
 	 >>Wsxx'??@>>  T^^,k!
~? ?s   U	6/UU	c                    |s|S g }|j                         j                  d      D ]\  }|j                         }|d   dk(  r|j                  d|g       /|d   dk(  r|j                  |       I|j                  d|z          ^ |d   s|d= |S )zBFormat the changelog correctly and convert it to a list of stringsr   r   *r   r   r   )r   r   r   rd   )rE   r.   new_changelogr   s       rF   re   zbdist_rpm._format_changelogD  s    OO%++D1 	2D::<DAw#~$$b$Z0aC$$T*$$TD[1	2 Qa rH   )returnN)__name__
__module____qualname__descriptionuser_optionsr   r   rb   str__annotations__r   dictrG   rX   rW   r   r   rz   re    rH   rF   r   r      sx    .KoLb,OXd3i(  $/ .L(4S>* +Z%B,)\~@CiVrH   r   )__doc__rO   r   rR   distutils._logr   typingr   corer   debugr   errorsr   r	   r
   r   	file_utilr   	sysconfigr   r   r   rH   rF   <module>r      sA   
 
  
      # *~ ~rH   