509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3

  \§T  ã               @   s€   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T ddlmZ dd	lmZ G d
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)Úget_platform)Ú
write_file)Ú*)Úget_python_version)Úlogc            +   @   s¸   e Zd ZdZdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd€d�d‚dƒd„d…d†d‡dˆd‰dŠd‹dŒd�dŽd�g)Zd4d9d=d2dUgZd4d9d=dXœZdYdZ„ Zd[d\„ Zd]d^„ Z	d_d`„ Z
dadb„ Zdcdd„ Zdedf„ ZdS )�Ú	bdist_rpmzcreate an RPM distributionúbdist-base=Nú/base directory for creating built distributionsú	rpm-base=údbase directory for creating RPMs (defaults to "rpm" under --bdist-base; must be specified for RPM 2)ú	dist-dir=ÚdúDdirectory to put final RPM files in (and .spec files if --spec-only)úpython=úMpath to Python interpreter to hard-code in the .spec file (default: "python")ú
fix-pythonúLhard-code the exact path to the current Python interpreter in the .spec fileú	spec-onlyúonly regenerate spec fileúsource-onlyúonly generate source RPMúbinary-onlyúonly generate binary RPMú	use-bzip2ú7use bzip2 instead of gzip to create source distributionúdistribution-name=úgname of the (Linux) distribution to which this RPM applies (*not* the name of the module distribution!)úgroup=ú9package classification [default: "Development/Libraries"]úrelease=úRPM release numberúserial=úRPM serial numberúvendor=úaRPM "vendor" (eg. "Joe Blow <joe@example.com>") [default: maintainer or author from setup script]ú	packager=úBRPM packager (eg. "Jane Doe <jane@example.net>") [default: vendor]ú
doc-files=ú6list of documentation files (space or comma-separated)ú
changelog=úRPM changelogúicon=úname of icon fileú	provides=ú%capabilities provided by this packageú	requires=ú%capabilities required by this packageú
conflicts=ú-capabilities which conflict with this packageúbuild-requires=ú+capabilities required to build this packageú
obsoletes=ú*capabilities made obsolete by this packageú
no-autoreqú+do not automatically calculate dependenciesú	keep-tempÚkú"don't clean up RPM build directoryúno-keep-tempú&clean up RPM build directory [default]úuse-rpm-opt-flagsú8compile with RPM_OPT_FLAGS when building from source RPMúno-rpm-opt-flagsú&do not pass any RPM CFLAGS to compilerú	rpm3-modeú"RPM 3 compatibility mode (default)ú	rpm2-modeúRPM 2 compatibility modeúprep-script=ú3Specify a script for the PREP phase of RPM buildingúbuild-script=ú4Specify a script for the BUILD phase of RPM buildingúpre-install=ú:Specify a script for the pre-INSTALL phase of RPM buildingúinstall-script=ú6Specify a script for the INSTALL phase of RPM buildingúpost-install=ú;Specify a script for the post-INSTALL phase of RPM buildingúpre-uninstall=ú<Specify a script for the pre-UNINSTALL phase of RPM buildingúpost-uninstall=ú=Specify a script for the post-UNINSTALL phase of RPM buildingúclean-script=ú4Specify a script for the CLEAN phase of RPM buildingúverify-script=ú6Specify a script for the VERIFY phase of the RPM buildúforce-arch=ú0Force an architecture onto the RPM build processÚquietÚqú3Run the INSTALL phase of RPM building in quiet mode)zno-keep-tempzno-rpm-opt-flagsz	rpm2-modec             C   sî   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\   )Úself© r‡   ú3/usr/lib64/python3.6/distutils/command/bdist_rpm.pyÚinitialize_optionsˆ   sN    zbdist_rpm.initialize_optionsc             C   sº   | j ddƒ | jd kr6| js$tdƒ‚tjj| jdƒ| _| jd krX| j	rPt
j| _qfd| _n| j	rftdƒ‚tjdkr~tdtj ƒ‚| jr’| jr’td	ƒ‚| jjƒ s¢d
| _| j ddƒ | jƒ  d S )NZbdistr`   z)you must specify --rpm-base in RPM 2 modeÚrpmZ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   rb   )r`   r`   )rb   rb   )Zset_undefined_optionsra   rƒ   ZDistutilsOptionErrorÚosÚpathÚjoinr`   rc   rd   ÚsysÚ
executableÚnameZDistutilsPlatformErrorrf   rg   ÚdistributionÚhas_ext_modulesr‚   Úfinalize_package_data)r†   r‡   r‡   rˆ   Úfinalize_optionsµ   s.    





zbdist_rpm.finalize_optionsc             C   sX  | j ddƒ | j dd| jjƒ | jjƒ f ƒ | j dƒ | jdƒ t| jtƒr|x.dD ]&}tj	j
|ƒrR|| jkrR| jj|ƒ qRW | 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ƒ d S )Nrj   zDevelopment/Librariesrm   z%s <%s>rn   ro   ÚREADMEú
README.txtrk   Ú1rl   ri   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r|   r}   r~   r   r€   r…   )r–   r—   )Zensure_stringr’   Zget_contactZget_contact_emailZensure_string_listÚ
isinstancero   ÚlistrŒ   r�   ÚexistsÚappendÚ_format_changelogrp   Zensure_filename)r†   Zreadmer‡   r‡   rˆ   r”   Ô   s>    





















zbdist_rpm.finalize_package_datac             C   sì  t r<tdƒ td| jƒ td| jƒ td| jƒ td| jƒ | jrT| j}| j|ƒ n<i }x.d)D ]&}t	j
j| j|ƒ||< | j|| ƒ q^W |d }t	j
j|d| jjƒ  ƒ}| jt|| jƒ fd| ƒ | jrÌd S | jjd d … }| jdƒ}| j� rødg|_ndg|_| jdƒ || j_|jƒ d }|d }| j||ƒ | j�rht	j
j| jƒ�rZ| j| j|ƒ ntd| j ƒ‚tjdƒ dg}	t	j
jdƒ�s”t	j
jdƒ�ršdg}	| j�r®|	jdƒ n| j �rÂ|	jdƒ n
|	jdƒ |	j!dd| j" gƒ | j#�r|	j!ddt	j
j$| jƒ gƒ | j%�s|	jdƒ | j&�r(|	jdƒ |	j|ƒ d}
|
d  }d!|
 d" }d#|||f }t	j'|ƒ}z€g }d }xT|j(ƒ }|�s~P |j)ƒ j*ƒ }t+|ƒd$k�sœt,‚|j|d% ƒ |d k�rn|d }�qnW |j-ƒ }|�ràt.d&t/|ƒ ƒ‚W d |j-ƒ  X | j0|	ƒ | j1�sè| jj2ƒ �rt3ƒ }nd'}| j �svt	j
j|d
 |ƒ}t	j
j|ƒ�sDt,‚| j4|| jƒ t	j
j| j|ƒ}| jjjd(||fƒ | j�sèxh|D ]`}t	j
j|d	 |ƒ}t	j
j|ƒ�r„| j4|| jƒ t	j
j| jt	j
j5|ƒƒ}| jjjd(||fƒ �q„W d S )*Nzbefore _get_package_data():zvendor =z
packager =zdoc_files =zchangelog =ÚSOURCESÚSPECSÚBUILDÚRPMSÚSRPMSz%s.speczwriting '%s'ÚsdistZbztarZgztarr   zicon file '%s' does not existzbuilding RPMsrŠ   z/usr/bin/rpmbuildz/bin/rpmbuildZrpmbuildz-bsz-bbz-baz--definez__python %sz
_topdir %sz--cleanz--quietz%{name}-%{version}-%{release}z.src.rpmz%{arch}/z.%{arch}.rpmz%rpm -q --qf '%s %s\n' --specfile '%s'é   r_   zFailed to execute: %sÚanyr	   )rž   rŸ   r    r¡   r¢   )6r   Úprintrm   rn   ro   rp   re   rb   ZmkpathrŒ   r�   rŽ   ra   r’   Úget_nameZexecuter   Ú_make_spec_fileZ
dist_filesZreinitialize_commandrh   ZformatsZrun_commandZget_archive_filesZ	copy_filerq   r›   ZDistutilsFileErrorr   Úinforg   rœ   rf   Úextendrc   rƒ   Úabspathr�   r\   ÚpopenÚreadlineÚstripÚsplitÚlenÚAssertionErrorÚcloseZDistutilsExecErrorÚreprZspawnZdry_runr“   r   Z	move_fileÚbasename)r†   Zspec_dirZrpm_dirr   Z	spec_pathZsaved_dist_filesr£   ÚsourceZ
source_dirZrpm_cmdZ
nvr_stringZsrc_rpmZnon_src_rpmZq_cmdÚoutZbinary_rpmsZ
source_rpmÚlineÚlZstatusZ	pyversionZsrpmÚfilenamerŠ   r‡   r‡   rˆ   Úrun  sÆ    















zbdist_rpm.runc             C   s   t jj| jt jj|ƒƒS )N)rŒ   r�   rŽ   rb   r´   )r†   r�   r‡   r‡   rˆ   Ú
_dist_pathˆ  s    zbdist_rpm._dist_pathc             C   sD  d| j jƒ  d| j jƒ jddƒ d| j jƒ  d| jjddƒ dd| j jƒ  g}tjd	ƒ}d
jdd„ |j	ƒ D ƒƒ}d}d}|j||ƒ}||kr¨|j
dƒ |j
d| d
 ƒ |jdddgƒ | jrÊ|j
dƒ n
|j
dƒ |jd| j jƒ  d| j ddgƒ | j�s| j jƒ �s&|j
dƒ n|j
d| j ƒ x^dKD ]V}t| |jƒ ƒ}t|tƒ�rd|j
d"|d#j|ƒf ƒ n|d$k	�r,|j
d"||f ƒ �q,W | j jƒ d%k�rª|j
d&| j jƒ  ƒ | j�rÂ|j
d'| j ƒ | j�rà|j
d(d#j| jƒ ƒ | j�r |j
d)tjj| jƒ ƒ | j�r|j
d*ƒ |jdd+| j jƒ gƒ d,| jtjjtj d- ƒf }d.| }	| j!�r\d/|	 }	d0| }
dLd4d5|	fd6d7|
fdMdNdOdPdQdRg	}xh|D ]`\}}}t| |ƒ}|�s¬|�rŒ|jddE| gƒ |�rà|jt"|dFƒj#ƒ j$d
ƒƒ n
|j
|ƒ �qŒW |jddGdHgƒ | j%�r|j
dId#j| j%ƒ ƒ | j&�r@|jddJgƒ |j| j&ƒ |S )SziGenerate 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: zrpm --eval %{__os_install_post}Ú
c             S   s   g | ]}d |j ƒ  ‘qS )z  %s \)r®   )Ú.0r·   r‡   r‡   rˆ   ú
<listcomp>Ÿ  s   z-bdist_rpm._make_spec_file.<locals>.<listcomp>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%s: %sú NZUNKNOWNzUrl: zDistribution: zBuildRequires: zIcon: z
AutoReq: 0z%descriptionz%s %sr   z%s buildzenv CFLAGS="$RPM_OPT_FLAGS" z>%s install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILESr{   rr   ú&%setup -n %{name}-%{unmangled_version}Zbuildrs   Zinstallrt   Úcleanru   úrm -rf $RPM_BUILD_ROOTÚverifyscriptrv   Úprerw   Úpostrx   Úpreunry   Úpostunrz   ú%Úrz%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z
%changelog)rÂ   rÃ   rÄ   rÅ   rÆ   rÇ   )r{   rr   rÉ   )rÊ   ru   rË   )rÌ   rv   N)rÍ   rw   N)rÎ   rx   N)rÏ   ry   N)rÐ   rz   N)'r’   r§   Zget_versionÚreplacerk   Zget_descriptionÚ
subprocessZ	getoutputrŽ   Ú
splitlinesrœ   rª   rh   Zget_licenserj   r…   r“   ÚgetattrÚlowerr™   rš   Zget_urlri   r   rq   rŒ   r�   r´   r„   Zget_long_descriptionrc   r�   Úargvr‚   ÚopenÚreadr¯   ro   rp   )r†   Z	spec_fileZvendor_hookZproblemZfixedZ
fixed_hookZfieldÚvalZdef_setup_callZ	def_buildZinstall_cmdZscript_optionsZrpm_optÚattrÚdefaultr‡   r‡   rˆ   r¨   ‹  sº    


	
    


zbdist_rpm._make_spec_filec             C   s€   |s|S g }x`|j ƒ jdƒD ]N}|j ƒ }|d dkrD|jd|gƒ q|d dkr\|j|ƒ q|jd| ƒ qW |d s||d= |S )zKFormat the changelog correctly and convert it to a list of strings
        r¿   r   r   r¾   r¼   z  )r®   r¯   rª   rœ   )r†   rp   Znew_changelogr·   r‡   r‡   rˆ   r�   3  s    zbdist_rpm._format_changelog)r
   Nr   )r   Nr   )r   r   r   )r   Nr   )r   Nr   )r   Nr   )r   Nr   )r   Nr   )r   Nr   )r   Nr   )r   Nr    )r!   Nr"   )r#   Nr$   )r%   Nr&   )r'   Nr(   )r)   Nr*   )r+   Nr,   )r-   Nr.   )r/   Nr0   )r1   Nr2   )r3   Nr4   )r5   Nr6   )r7   Nr8   )r9   Nr:   )r;   r<   r=   )r>   Nr?   )r@   NrA   )rB   NrC   )rD   NrE   )rF   NrG   )rH   NrI   )rJ   NrK   )rL   NrM   )rN   NrO   )rP   NrQ   )rR   NrS   )rT   NrU   )rV   NrW   )rX   NrY   )rZ   Nr[   )r\   r]   r^   )Ú__name__Ú
__module__Ú__qualname__ZdescriptionZuser_optionsZboolean_optionsZnegative_optr‰   r•   r”   rº   r»   r¨   r�   r‡   r‡   r‡   rˆ   r	      sÂ                                            --  )r	   )Ú__doc__rÔ   r�   rŒ   Zdistutils.corer   Zdistutils.debugr   Zdistutils.utilr   Zdistutils.file_utilr   Zdistutils.errorsZdistutils.sysconfigr   Z	distutilsr   r	   r‡   r‡   r‡   rˆ   Ú<module>   s   