o ?Og!Tã@sr ddlZddlZddlZddlmZddlmZddlmZddl Tddl m Z ddl m Z Gdd „d eƒZdS) éN)ÚCommand)ÚDEBUG)Ú write_file)Ú*)Úget_python_version)Úlogc@sdeZdZdZgd¢Zgd¢ZddddœZdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dS)Ú bdist_rpmzcreate 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))zpython=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-onlyNzonly regenerate spec file)z source-onlyNzonly generate source RPM)z binary-onlyNzonly generate binary RPM)z use-bzip2Nz7use bzip2 instead of gzip to create source distribution)zdistribution-name=Nzgname of the (Linux) distribution to which this RPM applies (*not* the name of the module distribution!))zgroup=Nz9package classification [default: "Development/Libraries"])zrelease=NzRPM release number)zserial=NzRPM serial number)zvendor=NzaRPM "vendor" (eg. "Joe Blow ") [default: maintainer or author from setup script])z packager=NzBRPM packager (eg. "Jane Doe ") [default: vendor])z doc-files=Nz6list of documentation files (space or comma-separated))z changelog=Nz RPM changelog)zicon=Nzname 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)zbuild-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-modeNzRPM 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)zinstall-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)zpre-uninstall=NzÚfinalize_options´s6  ÿ  ÿ ÿ ÿ   zbdist_rpm.finalize_optionscCsT| dd¡| dd|j ¡|j ¡f¡| d¡| d¡t|jtƒrr#r$)ZREADMEz README.txtr Ú1r!rr%r&r'r(r)r*r+r,r-r.r/r1r2r3r4r5r:)Z ensure_stringrHZ get_contactZget_contact_emailZensure_string_listÚ isinstancer$ÚlistrBrCÚexistsÚappendÚ_format_changelogr%Zensure_filename)r<Zreadmer=r=r>rJÓsD  ÿÿ    €                   zbdist_rpm.finalize_package_datacCsœtrtdƒtd|jƒtd|jƒtd|jƒtd|jƒ|jr*|j}| |¡ni}dD]}t j   |j |¡||<| ||¡q.|d}t j   |d|j  ¡¡}| t|| ¡fd |¡|jrddS|j jdd…}| d ¡}|jryd g|_nd g|_| d ¡||j _| ¡d }|d}| ||¡|jr¯t j  |j¡r¨| |j|¡ntd|jƒ‚t d¡dg} |jrÀ|  d¡n|j rÉ|  d¡n|  d¡|  !dd|j"g¡|j#ré|  !ddt j  $|j ¡g¡|j%sñ|  d¡|j&rù|  d¡|  |¡d} | d} d| d} d| | |f} t  '| ¡}z:g}d} | (¡}|s$n| )¡ *¡}| |d ¡|dur:|d }q| +¡}|rKt,d!t-| ƒƒ‚W| +¡n| +¡w| .| ¡|j/sÈ|j  0¡rit1ƒ}nd"}|j s‘t j   |d#|¡}| 2||j¡t j   |j|¡}|j j d$||f¡|jsÊ|D]4}t j   |d%|¡}t j  |¡rÆ| 2||j¡t j   |jt j  3|¡¡}|j j d$||f¡q—dSdSdS)&Nzbefore _get_package_data():zvendor =z packager =z doc_files =z changelog =)ÚSOURCESÚSPECSZBUILDÚRPMSÚSRPMSrSz%s.specz writing '%s'ÚsdistZbztarZgztarrrRzicon file '%s' does not existz building RPMsZrpmbuildz-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'TrzFailed to execute: %sÚanyrUrrT)4rÚprintr"r#r$r%rrZmkpathrBrCrDrrHÚget_nameZexecuterÚ_make_spec_fileZ dist_filesZreinitialize_commandrZformatsZ run_commandZget_archive_filesZ copy_filer&rOZDistutilsFileErrorrÚinforrPrÚextendrr8Úabspathr6rÚpopenÚreadlineÚstripÚsplitÚcloseZDistutilsExecErrorÚreprZspawnZdry_runrIrZ move_fileÚbasename)r<Zspec_dirZrpm_dirr Z spec_pathZsaved_dist_filesrVÚsourceZ source_dirZrpm_cmdZ nvr_stringZsrc_rpmZ non_src_rpmZq_cmdÚoutZ binary_rpmsZ source_rpmÚlineÚlZstatusZ pyversionZsrpmÚfilenamer@r=r=r>ÚrunsÚ      ÿÿý     ÿ    ÿ    ÿ   ÷ ÿ  ÿ  ÿÿ€ëz bdist_rpm.runcCstj |jtj |¡¡S)N)rBrCrDrrd)r<rCr=r=r>Ú _dist_path„szbdist_rpm._dist_pathc CsL d|j ¡d|j ¡ dd¡d|j ¡d|j dd¡dd|j ¡g}t d ¡}d  d d „|  ¡Dƒ¡}d }d}| ||¡}||krU|  d¡|  d|d ¡|  gd¢¡|j re|  d¡n|  d¡|  d|j  ¡d|jddg¡|js‰|j ¡sˆ|  d¡n|  d|j¡dD](}t|| ¡ƒ}t|tƒr®|  d|d |¡f¡q“|dur»|  d||f¡q“|j ¡dkrÍ|  d|j ¡¡|jrØ|  d|j¡|jræ|  d d |j¡¡|jrõ|  d!tj |j¡¡|jrý|  d"¡|  dd#|j ¡g¡d$|jtj tj d%¡f}d&|} |j!r"d'| } d(|} d)d*d+| fd,d-| fd.d/d0d1d2d3g } | D]C\} } }t|| ƒ}|sI|r{|  dd4| g¡|rvt"|ƒ}|  | #¡ $d ¡¡Wdƒn 1sowYq9|  |¡q9|  gd5¢¡|j%r“|  d6d |j%¡¡|j&r¤|  dd7g¡|  |j&¡|S)8Nz %define name z%define version ú-Ú_z%define unmangled_version z%define release Úz Summary: zrpm --eval %{__os_install_post}Ú cSsg|]}d| ¡‘qS)z %s \)r`)Ú.0rgr=r=r>Ú ›sÿz-bdist_rpm._make_spec_file..zbrp-python-bytecompile \ z%brp-python-bytecompile %{__python} \ z2# Workaround for http://bugs.python.org/issue14443z%define __os_install_post )z Name: %{name}zVersion: %{version}zRelease: %{release}z-Source0: %{name}-%{unmangled_version}.tar.bz2z,Source0: %{name}-%{unmangled_version}.tar.gzz License: zGroup: z>BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildrootzPrefix: %{_prefix}zBuildArch: noarchz BuildArch: %s)ZVendorZPackagerZProvidesZRequiresZ ConflictsZ Obsoletesz%s: %sú ZUNKNOWNzUrl: zDistribution: zBuildRequires: zIcon: z AutoReq: 0z %descriptionz%s %srz%s buildzenv CFLAGS="$RPM_OPT_FLAGS" z>%s install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES)r0r'z&%setup -n %{name}-%{unmangled_version}Zbuildr(Zinstallr))Zcleanr*zrm -rf $RPM_BUILD_ROOT)Z verifyscriptr+N)Zprer,N)Zpostr-N)Zpreunr.N)Zpostunr/Nú%)rnz%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z %changelog)'rHrYZ get_versionÚreplacer Zget_descriptionÚ subprocessZ getoutputrDÚ splitlinesrPr\rZ get_licenserr:rIÚgetattrÚlowerrMrNZget_urlrr4r&rBrCrdr9Zget_long_descriptionrrEÚargvr7ÚopenÚreadrar$r%)r<Z spec_fileZ vendor_hookZproblemZfixedZ fixed_hookZfieldÚvalZdef_setup_callZ def_buildZ install_cmdZscript_optionsZrpm_optÚattrÚdefaultÚfr=r=r>rZ‡sÄ   ú ÿ      ü  € € ÿ ýÿ÷  þ ÿ€ €þ zbdist_rpm._make_spec_filecCs~ |s|Sg}| ¡ d¡D]'}| ¡}|ddkr"| d|g¡q|ddkr.| |¡q| d|¡q|ds=|d=|S)Nrorrrnrlz )r`rar\rP)r<r%Z new_changelogrgr=r=r>rQ0s   zbdist_rpm._format_changelogN)Ú__name__Ú __module__Ú __qualname__Ú descriptionZ user_optionsZboolean_optionsZ negative_optr?rKrJrjrkrZrQr=r=r=r>rs"mþ-- *r)rurErBZdistutils.corerZdistutils.debugrZdistutils.file_utilrZdistutils.errorsZdistutils.sysconfigrZ distutilsrrr=r=r=r>Ús