
    ϶vgT                         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)log   )Command)DEBUG)DistutilsExecErrorDistutilsFileErrorDistutilsOptionErrorDistutilsPlatformError)
write_file)get_python_versionc                   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 )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    d/var/www/pixelcanvas.ch/venv/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                   | 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posixz7don't know how to create RPM distributions on platform z6cannot supply both '--source-only' and '--binary-only'F)r   r   )set_undefined_optionsr   r>   r	   ospathjoinr   r   r   sys
executablenamer
   r!   r"   distributionhas_ext_modulesr=   finalize_package_datarA   s    rC   finalize_optionszbdist_rpm.finalize_options   sC   ""7,HIII= > X*+VWWWGLL%@@DM; (!n'_ 	&J   7g(S"'SS    	 0 	&H  
  0022 	+%*D"""7,DEEE""$$$$$rE   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.   r/   r0   r1   r2   r3   r4   r5   r7   r8   r9   r:   r;   r@   )ensure_stringrR   get_contactget_contact_emailensure_string_list
isinstancer*   listrL   rM   existsappend_format_changelogr+   ensure_filename)rB   readmes     rC   rT   zbdist_rpm.finalize_package_data   s   7$;<<< ,,..ZZ$2C2U2U2W2WZZZ	
 	
 	
 	:&&&,,,dnd++ 	22 2 27>>&)) 2fDN.J.JN))&1119c***8$$$.///;'''//??V$$$]+++^,,,-...^,,,_---]+++^,,,_----... 	
+++
+++,,, 0111,,,<(((((rE   c                 n   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
                            || j                                         d          }|                     t           ||                                 fd	| d
           | j        rd S | j        j        d d          }|                     d          }| j        r	dg|_        ndg|_        |                     d           || j        _        |                                d         }|d         }|                     ||           | j        rXt          j
                            | j                  r|                     | j        |           nt7          d| j         d          t9          j        d           dg}	| j        r|	                    d           n2| j         r|	                    d           n|	                    d           |	!                    dd| j"         g           | j#        r<|	!                    ddt          j
        $                    | j                   g           | j%        s|	                    d           | j&        r|	                    d           |	                    |           d}
|
dz   }d|
z   dz   }d | d!| d"| d
}t          j'        |          }	 g }d }	 |(                                }|sna|)                                *                                }tW          |          d$k    sJ |                    |d%                    ||d         }x|,                                }|rt[          d&|          	 |,                                 n# |,                                 w xY w| .                    |	           | j/        s| j        0                                rtc                      }nd'}| j         st          j
                            |d(         |          }t          j
                            |          sJ | 2                    || j                   t          j
                            | j        |          }| j        j                            d)||f           | j        s|D ]}t          j
                            |d*         |          }t          j
                            |          r| 2                    || j                   t          j
                            | j        t          j
        3                    |                    }| 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SRPMSrg   z.specz	writing ''sdistbztargztarr   rf   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 'Tr      zFailed to execute: anyrj   r   ri   )4r   printr(   r)   r*   r+   r    r   mkpathrL   rM   rN   r   rR   get_nameexecuter   _make_spec_file
dist_filesreinitialize_commandr#   formatsrun_commandget_archive_files	copy_filer,   r`   r   r   infor"   ra   r!   extendr   r>   abspathr<   r   popenreadlinestripsplitlencloser   spawndry_runrS   r   	move_filebasename)rB   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filenamerH   s                           rC   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d.?.H.H.J.J+Q+Q+QRR	D$8$8$:$:;=U=U=U=U	
 	
 	
 > 	F  ,7:))'22> 	&$IEMM$IEM!!!'7$((**1-Y'
vz***9 	Tw~~di(( Tty*5555()Rty)R)R)RSSS 	!!!, 	"NN5!!!! 	"NN5!!!!NN5!!!
$=$=$=>???> 	VNNJ(S27??4=3Q3Q(S(STUUU~ 	&NN9%%%: 	&NN9%%%y!!!
 5
z) :->TTT;TT	TTThuoo	KJ	(||~~ jjll((**3xx1}}}}""3q6***%!$QJ	( YY[[F J()Hu)H)HIIIJ 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;;'%$=   '	 	
 
	 	s   B%Q Q'c                     t           j                            | j        t           j                            |                    S )N)rL   rM   rN   r   r   )rB   rM   s     rC   
_dist_pathzbdist_rpm._dist_path  s*    w||DM27+;+;D+A+ABBBrE   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                    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           | j         dt4          j                            t@          j!        d%                    }| d&}	| j"        rd'|	z   }	| d(}
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 |                                  dS )  z \)r   ).0r   s     rC   
<listcomp>z-bdist_rpm._make_spec_file.<locals>.<listcomp>  s9     !
 !
 !
'+""""!
 !
 !
rE   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{}: {}rp   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)r6   r-   z&%setup -n %{name}-%{unmangled_version}buildr.   installr/   )cleanr0   zrm -rf $RPM_BUILD_ROOT)verifyscriptr1   N)prer2   N)postr3   N)preunr4   N)postunr5   N%)r   z%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z
%changelog)(rR   ru   get_versionreplacer&   get_description
subprocess	getoutputrN   
splitlinesra   r   r#   get_licenser%   r@   rS   getattrlowerr^   r_   formatget_urlr$   r:   r,   rL   rM   r   r?   get_long_descriptionr   rO   argvr=   openreadr   r*   r+   )rB   	spec_filevendor_hookproblemfixed
fixed_hookfieldvaldef_setup_call	def_buildinstall_cmdscript_optionsrpm_optattrdefaultfs                   rC   rw   zbdist_rpm._make_spec_file  sP    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 !
 !
/:/E/E/G/G!
 !
 !
   09 ((%88
$$RSSS9JFMNNN 	 
 
 
 	 	 	 > 	MLMMMMKLLL4,88::GiH
"L 	
 	 	 	  	>$4466 6  !4555<4?<<===
 	4 	4E $..C#t$$ 4  !F!FGGGG  E!2!2S!2!2333$$&& 	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? 	+\***2244:
 	 	 	$ !KII"'*:*:38A;*G*GII%---	! 	C6BI (eee Nni0(+6?3(*,.

 '5 	. 	."GT7 $%%C 	.g 	.  'M"     .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   r   )r   r   r   ra   )rB   r+   new_changelogr   s       rC   rb   zbdist_rpm._format_changelogC  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 rE   N)__name__
__module____qualname__descriptionuser_optionsboolean_optionsnegative_optrD   rU   rT   r   r   rw   rb    rE   rC   r   r      s        .Ko o oLb  O $/  L+ + +Z% % %B,) ,) ,)\~ ~ ~@C C Ci i iV    rE   r   )__doc__rL   r   rO   distutils._logr   corer   debugr   errorsr   r   r	   r
   	file_utilr   	sysconfigr   r   r   rE   rC   <module>r      s   
 
			     



                              # " " " " " * * * * * *~ ~ ~ ~ ~ ~ ~ ~ ~ ~rE   