£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
B
    YI~dT                 @   s|   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 )    N)Command)DEBUG)get_platform)
write_file)*)get_python_version)logc            )   @   s   e Zd ZdZ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)d*g)Zd+d,d-d.d/gZd+d,d-d0Zd1d2 Zd3d4 Zd5d6 Z	d7d8 Z
d9d: Zd;d< Zd=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)z
no-autoreqNz+do not automatically calculate dependencies)z	keep-tempkz"don't clean up RPM build directory)zno-keep-tempNz&clean up RPM build directory [default])zuse-rpm-opt-flagsNz8compile with RPM_OPT_FLAGS when building from source RPM)zno-rpm-opt-flagsNz&do not pass any RPM CFLAGS to compiler)z	rpm3-modeNz"RPM 3 compatibility mode (default))z	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 modez	keep-tempzuse-rpm-opt-flagsz	rpm3-modez
no-autoreqr   )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 r6   @/opt/alt/python37/lib64/python3.7/distutils/command/bdist_rpm.pyinitialize_options   sN    zbdist_rpm.initialize_optionsc             C   s   |  dd | jd kr6| js$tdt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rtd	| j sd
| _|  dd |   d S )NZbdist)r   r   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   )r   r   )Zset_undefined_optionsr   r2   ZDistutilsOptionErrorospathjoinr   r   r   sys
executablenameZDistutilsPlatformErrorr   r   distributionhas_ext_modulesr1   finalize_package_data)r5   r6   r6   r7   finalize_options   s.    





zbdist_rpm.finalize_optionsc             C   sX  |  dd |  dd| j | j f  |  d | d t| jtr|x.dD ]&}tj	
|rR|| jkrR| j| qRW |  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%s <%s>r   r   )ZREADMEz
README.txtr   1r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r+   r,   r-   r.   r/   r4   )Zensure_stringrA   Zget_contactZget_contact_emailZensure_string_list
isinstancer   listr;   r<   existsappend_format_changelogr   Zensure_filename)r5   Zreadmer6   r6   r7   rC      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}| | n<i }x.dD ]&}t	j
| j|||< | ||  q^W |d }t	j
|d| j  }| t||  fd	|  | jrd S | jjd d  }| d
}| jrdg|_ndg|_| d
 || j_| d }|d }| || | jrft	j
| jrX| | j| ntd| j td dg}	t	j
dst	j
drdg}	| jr|	d n| 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 }d|
 d  }d!|||f }t	'|}zng }d }xB|( }|s|P |) * }||d"  |d krl|d }qlW |+ }|rt,d#t-| W d |+  X | .|	 | j/s| j0 r t1 }nd$}| j sPt	j
|d% |}| 2|| j t	j
| j|}| jjd&||f | jsxh|D ]`}t	j
|d' |}t	j
|r^| 2|| j t	j
| jt	j
3|}| jjd&||f q^W d S )(Nzbefore _get_package_data():zvendor =z
packager =zdoc_files =zchangelog =)SOURCESSPECSZBUILDRPMSSRPMSrL   z%s.speczwriting '%s'sdistZbztarZgztarr   rK   zicon file '%s' does not existzbuilding RPMsr9   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anyrN   r	   rM   )4r   printr   r   r   r   r   r   Zmkpathr;   r<   r=   r   rA   get_nameZexecuter   _make_spec_fileZ
dist_filesZreinitialize_commandr   formatsZrun_commandZget_archive_filesZ	copy_filer    rH   ZDistutilsFileErrorr   infor   rI   r   extendr   r2   abspathr0   r   popenreadlinestripsplitcloseZDistutilsExecErrorreprZspawnZdry_runrB   r   Z	move_filebasename)r5   Zspec_dirZrpm_dirr
   Z	spec_pathZsaved_dist_filesrO   sourceZ
source_dirZrpm_cmdZ
nvr_stringZsrc_rpmZnon_src_rpmZq_cmdoutZbinary_rpmsZ
source_rpmlinelstatusZ	pyversionZsrpmfilenamer9   r6   r6   r7   run  s    















zbdist_rpm.runc             C   s   t j| jt j|S )N)r;   r<   r=   r   r^   )r5   r<   r6   r6   r7   
_dist_path  s    zbdist_rpm._dist_pathc          	   C   sD  d| j   d| j  dd d| j   d| jdd dd| j   g}td	}d
dd |	 D }d}d}|||}||kr|
d |
d| d
  |dddg | jr|
d n
|
d |d| j   d| j ddg | js| j  s&|
d n|
d| j  x^dD ]V}t| | }t|trd|
d|d|f  n|d k	r,|
d||f  q,W | j  dkr|
d | j    | jr|
d!| j  | jr|
d"d| j  | jr |
d#tj| j  | jr|
d$ |dd%| j  g d&| jtjtj d' f }d(| }	| j!r\d)|	 }	d*| }
d+d,d-|	fd.d/|
fd0d1d2d3d4d5g	}xh|D ]`\}}}t| |}|s|r|dd6| g |r|t"|d7# $d
 n
|
| qW |dd8d9g | j%r|
d:d| j%  | j&r@|dd;g || j& |S )<Nz%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 |   qS )z  %s \)rZ   ).0ra   r6   r6   r7   
<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)ZVendorZPackagerZProvidesZRequiresZ	ConflictsZ	Obsoletesz%s: %s Z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_FILES)r*   r!   z&%setup -n %{name}-%{unmangled_version}Zbuildr"   installr#   )Zcleanr$   zrm -rf $RPM_BUILD_ROOT)Zverifyscriptr%   N)Zprer&   N)Zpostr'   N)Zpreunr(   N)Zpostunr)   N%rz%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z
%changelog)'rA   rR   Zget_versionreplacer   Zget_description
subprocessZ	getoutputr=   
splitlinesrI   rV   r   Zget_licenser   r4   rB   getattrlowerrF   rG   Zget_urlr   r.   r    r;   r<   r^   r3   Zget_long_descriptionr   r>   argvr1   openreadr[   r   r   )r5   Z	spec_fileZvendor_hookZproblemZfixedZ
fixed_hookZfieldvalZdef_setup_callZ	def_buildZinstall_cmdZscript_optionsZrpm_optattrdefaultr6   r6   r7   rS     s    


	




zbdist_rpm._make_spec_filec             C   s   |s|S g }x`|  dD ]N}|  }|d dkrD|d|g q|d dkr\|| q|d|  qW |d s||d= |S )Nrj   r   r   ri   rg   z  )rZ   r[   rV   rI   )r5   r   Znew_changelogra   r6   r6   r7   rJ   3  s    zbdist_rpm._format_changelogN)__name__
__module____qualname__descriptionZuser_optionsZboolean_optionsZnegative_optr8   rD   rC   re   rf   rS   rJ   r6   r6   r6   r7   r	      sp   --  )r	   )rr   r>   r;   Zdistutils.corer   Zdistutils.debugr   Zdistutils.utilr   Zdistutils.file_utilr   Zdistutils.errorsZdistutils.sysconfigr   Z	distutilsr   r	   r6   r6   r6   r7   <module>   s   