
     f V                         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mZmZmZ ddlmZ dd	lmZ  G d
 de          ZdS )zwdistutils.command.bdist_rpm

Implements the Distutils 'bdist_rpm' command (create RPM source and binary
distributions).    N   )Command)DEBUG)
write_file)DistutilsOptionErrorDistutilsPlatformErrorDistutilsFileErrorDistutilsExecError)get_python_version)logc                   X    e Zd ZdZg dZg dZddddZd Zd	 Zd
 Z	d Z
d Zd Zd ZdS )	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   r   r   r   )r   r   r   c                 (   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| _&        d S )Nr      )'
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    j/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/setuptools/_distutils/command/bdist_rpm.pyinitialize_optionszbdist_rpm.initialize_options   s%   !%
	 " ! !"	"!"


    c                 b   |                      dd           | j        @| j        st          d          t          j                            | j        d          | _        | j        !| j	        rt          j        | _        nd| _        n| j	        rt          d          t          j        dk    rt          dt          j        z            | j        r| j        rt          d	          | j                                        sd
| _        |                      dd           |                                  d S )Nbdist)r   r   z)you must specify --rpm-base in RPM 2 moderpmpython3z8--python and --fix-python are mutually exclusive optionsposixz9don't know how to create RPM distributions on platform %sz6cannot supply both '--source-only' and '--binary-only'r   )r   r   )set_undefined_optionsr   r?   r   ospathjoinr   r   r    sys
executablenamer   r"   r#   distributionhas_ext_modulesr>   finalize_package_datarB   s    rD   finalize_optionszbdist_rpm.finalize_options   sB   ""7,HIII= > X*+VWWWGLL%@@DM; (!n'_ 	&J   7g(NQSQXX    	 0 	&H  
  0022 	'%&D"""7,DEEE""$$$$$rF   c                 d   |                      dd           |                      d| j                                        d| j                                        d           |                      d           |                     d           t          | j        t                    rGdD ]D}t          j	        
                    |          r#|| j        vr| j                            |           E|                      d	d
           |                      d           |                      d           |                      d           |                     | j                  | _        |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                     d           |                      d           d S )Nr&   zDevelopment/Librariesr)   z <>r*   r+   )READMEz
README.txtr'   1r(   r%   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r8   r9   r:   r;   r<   rA   )ensure_stringrS   get_contactget_contact_emailensure_string_list
isinstancer+   listrM   rN   existsappend_format_changelogr,   ensure_filename)rC   readmes     rD   rU   zbdist_rpm.finalize_package_data   s   7$;<<< ,,....0A0S0S0U0U0U0UW	
 	
 	

 	:&&&,,,dnd++ 	22 2 27>>&)) 2fDN.J.JN))&1119c***8$$$.///;'''//??V$$$]+++^,,,-...^,,,_---]+++^,,,_----... 	
+++
+++,,, 0111,,,<(((((rF   c                    t           rct          d           t          d| j                   t          d| j                   t          d| j                   t          d| j                   | j        r| j        }|                     |           nRi }dD ]E}t          j
                            | j        |          ||<   |                     ||                    F|d         }t          j
                            |d| j                                        z            }|                     t           ||                                 fd	|z             | j        rd S | j        j        d d          }|                     d
          }| j        r	dg|_        ndg|_        |                     d
           || j        _        |                                d         }|d         }|                     ||           | j        rWt          j
                            | j                  r|                     | j        |           nt7          d| j        z            t9          j        d           dg}	| j        r|	                    d           n2| j         r|	                    d           n|	                    d           |	!                    dd| j"        z  g           | j#        r<|	!                    ddt          j
        $                    | j                  z  g           | j%        s|	                    d           | j&        r|	                    d           |	                    |           d}
|
dz   }d|
z   dz   }d'                    |||          }t          j(        |          }	 g }d }	 |)                                }|sna|*                                +                                }tY          |          d k    sJ |                    |d!                    ||d         }x|-                                }|rt]          d"t_          |          z            	 |-                                 n# |-                                 w xY w| 0                    |	           | j1        s| j        2                                rtg                      }nd#}| j         st          j
                            |d$         |          }t          j
                            |          sJ | 4                    || j                   t          j
                            | j        |          }| j        j                            d%||f           | j        s|D ]}t          j
                            |d&         |          }t          j
                            |          r| 4                    || j                   t          j
                            | j        t          j
        5                    |                    }| j        j                            d%||f           d S d S d S )'Nzbefore _get_package_data():zvendor =z
packager =zdoc_files =zchangelog =)SOURCESSPECSBUILDRPMSSRPMSrh   z%s.speczwriting '%s'sdistbztargztarr   rg   zicon file '%s' does not existzbuilding RPMsrpmbuildz-bsz-bbz-baz--definez__python %sz
_topdir %sz--cleanz--quietz%{name}-%{version}-%{release}z.src.rpmz%{arch}/z.%{arch}.rpmz%rpm -q --qf '{} {}\n' --specfile '{}'Tr   r   zFailed to execute: %sanyrk   r   rj   )6r   printr)   r*   r+   r,   r!   r   mkpathrM   rN   rO   r   rS   get_nameexecuter   _make_spec_file
dist_filesreinitialize_commandr$   formatsrun_commandget_archive_files	copy_filer-   ra   r	   r   infor#   rb   r"   extendr   r?   abspathr=   r   formatpopenreadlinestripsplitlencloser
   reprspawndry_runrT   r   	move_filebasename)rC   spec_dirrpm_dirr   	spec_pathsaved_dist_filesrl   source
source_dirrpm_cmd
nvr_stringsrc_rpmnon_src_rpmq_cmdoutbinary_rpms
source_rpmlineellstatus	pyversionsrpmfilenamerI   s                           rD   runzbdist_rpm.run  s    	1/000*dk***,...-000-000 > 	(}HKK!!!!GC ( (W\\$-;;
GAJ''''w'H GLL9t7H7Q7Q7S7S+STT	D$8$8$:$:;^i=W	
 	
 	
 > 	F  ,7:))'22> 	&$IEMM$IEM!!!'7$((**1-Y'
vz***9 	Vw~~di(( Vty*5555()H49)TUUU 	!!!, 	"NN5!!!! 	"NN5!!!!NN5!!!
MDK$?@AAA> 	XNNJrwt}7U7U(UVWWW~ 	&NN9%%%: 	&NN9%%%y!!!
 5
z) :->8??
 
 huoo	KJ	(||~~ jjll((**3xx1}}}}""3q6***%!$QJ	( YY[[F P()@4;;)NOOOP IIKKKKCIIKKKK

7| 	 0022 ".00		!	# Xw||GG$4jAAw~~d+++++tT]3337<<zBB!,33[)X4VWWW# &  C',,wv<<Cw~~c** sDM:::#%7<<rw?O?OPS?T?T#U#U)4;;()X>  '	 	  s   B2Q' 'Q=c                     t           j                            | j        t           j                            |                    S )N)rM   rN   rO   r   r   )rC   rN   s     rD   
_dist_pathzbdist_rpm._dist_path  s*    w||DM27+;+;D+A+ABBBrF   c           	         d| j                                         z   d| j                                                             dd          z   d| j                                         z   d| j                            dd          z   dd| j                                         pd	z   g}t          j        d
          }d                    d |	                                D                       }d}d}|                    ||          }||k    r0|
                    d           |
                    d|z   dz              |                    g d           | j        r|
                    d           n|
                    d           |                    d| j                                         pd	z   d| j        z   ddg           | j        s/| j                                         s|
                    d           n|
                    d| j        z             dD ]}t#          | |                                          }t'          |t(                    r=|
                    d                    |d                    |                               v|)|
                    d                    ||                     | j                                         r/|
                    d| j                                         z              | j        r|
                    d| j        z              | j        r0|
                    d d                    | j                  z              | j        r:|
                    d!t4          j                            | j                  z              | j        r|
                    d"           |                    dd#| j                                         pdg           d$                    | j        t4          j                            t@          j!        d%                             }d&|z  }	| j"        rd'|	z   }	d(|z  }
d)d*d+|	fd,d-|
fd.d/d0d1d2d3g	}|D ]\  }}}t#          | |          }|s|r|                    dd4|z   g           |rbtG          |          5 }|                    |$                                %                    d                     ddd           n# 1 swxY w Y   |
                    |           |                    g d5           | j&        r0|
                    d6d                    | j&                  z              | j'        r1|                    dd7g           |                    | j'                   |S )8ziGenerate 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}
c                 <    g | ]}d |                                 z  S )z  %s \)r   ).0r   s     rD   
<listcomp>z-bdist_rpm._make_spec_file.<locals>.<listcomp>  s%    KKK$Y%KKKrF   zbrp-python-bytecompile \
z%brp-python-bytecompile %{__python} \
z2# Workaround for http://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: %s)VendorPackagerProvidesRequires	Conflicts	Obsoletesz{}: {} NzUrl: zDistribution: zBuildRequires: zIcon: z
AutoReq: 0z%descriptionz{} {}r   z%s buildzenv CFLAGS="$RPM_OPT_FLAGS" z>%s install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES)r7   r.   z&%setup -n %{name}-%{unmangled_version}buildr/   installr0   )cleanr1   zrm -rf $RPM_BUILD_ROOT)verifyscriptr2   N)prer3   N)postr4   N)preunr5   N)postunr6   N%)r   z%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z
%changelog)(rS   rs   get_versionreplacer'   get_description
subprocess	getoutputrO   
splitlinesrb   r}   r$   get_licenser&   rA   rT   getattrlowerr_   r`   r   get_urlr%   r;   r-   rM   rN   r   r@   get_long_descriptionr   rP   argvr>   openreadr   r+   r,   )rC   	spec_filevendor_hookproblemfixed
fixed_hookfieldvaldef_setup_call	def_buildinstall_cmdscript_optionsrpm_optattrdefaultfs                   rD   ru   zbdist_rpm._make_spec_file  s>    d/88:::!2!>!>!@!@!H!Hc!R!RR(4+<+H+H+J+JJ!5!5c3!?!??4,<<>>K)L
	 !*+LMM iiKK+2H2H2J2JKKK
 
 09 ((%88
$$QRRR9JFMNNN 	  	
 	
 	
 > 	MLMMMMKLLLt0<<>>K)LDJ&P$		
 	
 	
  	@$4466 6  !4555_t>???
 	> 	>E $..C#t$$ >  !F!FGGGG  !<!<===$$&& 	DWt'8'@'@'B'BBCCC! 	H-0FFGGG 	P.$:M1N1NNOOO9 	EX(8(8(C(CCDDD? 	+\***!6688>B	
 	
 	
( !RW5E5Echqk5R5RSS/	! 	C6BI P
 Nni0(+6?3(*,.

 )7 	. 	.$WdG $%%C .g .  g    .c ?a!(()=)=>>>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $$W--- 	  	
 	
 	
 > 	AWsxx'?'??@@@> 	-    T^,,,s   ;S##S'	*S'	c                 `   |s|S g }|                                                     d          D ]t}|                                 }|d         dk    r|                    d|g           :|d         dk    r|                    |           \|                    d|z              u|d         s|d= |S )zBFormat the changelog correctly and convert it to a list of stringsr   r   *r   r   z  )r   r   r}   rb   )rC   r,   new_changelogr   s       rD   rc   zbdist_rpm._format_changelogU  s     	OO%%++D11 	2 	2D::<<DAw#~~$$b$Z0000aC$$T****$$TD[1111 Q 	!a rF   N)__name__
__module____qualname__descriptionuser_optionsboolean_optionsnegative_optrE   rV   rU   r   r   ru   rc    rF   rD   r   r      s        .Ko o oLb  O $/  L+ + +Z% % %B-) -) -)^@ @ @DC C Cw w wr    rF   r   )__doc__r   rP   rM   corer   debugr   	file_utilr   errorsr   r   r	   r
   	sysconfigr   distutils._logr   r   r   rF   rD   <module>r      s   
     



 				             " " " " " "            + * * * * *      P	 P	 P	 P	 P	 P	 P	 P	 P	 P	rF   