+eT@sdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl Tddl mZdd lmZGd d d eZdS) 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+@seZdZdZdfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddddddddddddg)Zd4d9d=d2dUgZid4d76d9d;6d=d?6ZdXdYZdZd[Zd\d]Z d^d_Z d`daZ dbdcZ dddeZ dS) bdist_rpmzcreate 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=dDdirectory 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-pythonLhard-code the exact path to the current Python interpreter in the .spec file spec-onlyonly regenerate spec file source-onlyonly generate source RPM binary-onlyonly generate binary RPM use-bzip27use bzip2 instead of gzip to create source distributiondistribution-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 numberserial=RPM serial numbervendor=aRPM "vendor" (eg. "Joe Blow ") [default: maintainer or author from setup script] packager=ARPM packager (eg. "Jane Doe ")[default: vendor] doc-files=6list of documentation files (space or comma-separated) changelog= RPM changelogicon=name of icon file provides=%capabilities provided by this package requires=%capabilities required by this package conflicts=-capabilities which conflict with this packagebuild-requires=+capabilities required to build this package obsoletes=*capabilities made obsolete by this package no-autoreq+do not automatically calculate dependencies keep-tempk"don't clean up RPM build directory no-keep-temp&clean up RPM build directory [default]use-rpm-opt-flags8compile with RPM_OPT_FLAGS when building from source RPMno-rpm-opt-flags&do not pass any RPM CFLAGS to compiler rpm3-mode"RPM 3 compatibility mode (default) rpm2-modeRPM 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 buildinginstall-script=6Specify a script for the INSTALL phase of RPM building post-install=;Specify a script for the post-INSTALL phase of RPM buildingpre-uninstall=rnroREADME README.txtrk1rlrirprqrrrsrtrurvrwrxryrzr|r}r~rrr)rr)Z ensure_stringrZ get_contactZget_contact_emailZensure_string_list isinstancerolistrrexistsappend_format_changelogrpZensure_filename)rZreadmerrrrs>    !                  zbdist_rpm.finalize_package_datac CsUtrStdtd|jtd|jtd|jtd|jn|jru|j}|j|nNi}x;d)D]3}t j j |j |||<|j||qW|d}t j j |d |j j}|jt||jfd ||jrdS|j jdd}|jd }|jrRdg|_n dg|_|jd ||j _|jd}|d}|j|||jrt j j|jr|j|j|qtd|jntjddg} t j jds%t j jdr1dg} n|jrJ| jdn&|j rc| jdn | jd| j!dd|j"g|j#r| j!ddt j j$|j gn|j%s| jdn|j&r| jdn| j|d} | d } d!| d"} d#| | |f} t j'| }zg}d}xn|j(}|scPn|j)j*}t+|d$kst,|j|d%|dkrM|d}qMqMW|j-}|rt.d&t/| nWd|j-X|j0| |j1sQ|j j2r&t3}nd'}|j st j j |d |}t j j|sft,|j4||jt j j |j|}|j jjd(||fn|jsQx|D]}t j j |d |}t j j|r|j4||jt j j |jt j j5|}|j jjd(||fqqWqQndS)*Nzbefore _get_package_data():zvendor =z packager =z doc_files =z changelog =SOURCESSPECSBUILDRPMSSRPMSz%s.specz writing '%s'sdistZbztarZgztarrzicon file '%s' does not existz building RPMsrz/usr/bin/rpmbuildz /bin/rpmbuildZrpmbuildz-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_zFailed to execute: %sanyr )rrrrr)6rprintrmrnrorprerbZmkpathrrrrarget_nameZexecuter_make_spec_fileZ dist_filesZreinitialize_commandrhZformatsZ run_commandZget_archive_filesZ copy_filerqrZDistutilsFileErrorrinforgrrfextendrcrabspathrr\popenreadlinestripsplitlenAssertionErrorcloseZDistutilsExecErrorreprZspawnZdry_runrrZ move_filebasename)rZspec_dirZrpm_dirrZ spec_pathZsaved_dist_filesrsourceZ source_dirZrpm_cmdZ nvr_stringZsrc_rpmZ non_src_rpmZq_cmdoutZ binary_rpmsZ source_rpmlinelZstatusZ pyversionZsrpmfilenamerrrrruns                                         z bdist_rpm.runcCs"tjj|jtjj|S)N)rrrrbr)rrrrr _dist_pathszbdist_rpm._dist_pathc Csod|jjd|jjjddd|jjd|jjdddd|jjg}tjd }d jd d |j D}d }d}|j||}||kr|j d|j d|d n|j dddg|j r|j dn |j d|j d|jj d|jddg|js|jjs|j dqn|j d|jx{dKD]s}t||j}t|tr|j d"|d#j|fq|d$k r|j d"||fqqW|jjd%krC|j d&|jjn|jrc|j d'|jn|jr|j d(d#j|jn|jr|j d)tjj|jn|jr|j d*n|j dd+|jjgd,|jtjjtj d-f}d.|} |j!r6d/| } nd0|} dLd4d5| fd6d7| fdMdNdOdPdQdRg } x| D]\} } }t|| }|s|rz|j ddE| g|r|j t"|dFj#j$d q|j |qzqzW|j ddGdHg|j%r<|j dId#j|j%n|j&rk|j ddJg|j |j&n|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: zrpm --eval %{__os_install_post} cSs g|]}d|jqS)z %s \)r).0rrrr 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: %sVendorPackagerProvidesRequires Conflicts Obsoletesz%s: %s NZUNKNOWNzUrl: 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_FILESr{rr&%setup -n %{name}-%{unmangled_version}ZbuildrsZinstallrtcleanrurm -rf $RPM_BUILD_ROOT verifyscriptrvprerwpostrxpreunrypostunrz%rz%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z %changelog)rrrrrr)zprepz prep_scriptr)rz clean_scriptr)rz verify_scriptN)rz pre_installN)rz post_installN)rz pre_uninstallN)rzpost_uninstallN)'rrZ get_versionreplacerkZget_description subprocessZ getoutputr splitlinesrrrhZ get_licenserjrrgetattrlowerrrZget_urlrirrqrrrrZget_long_descriptionrcrargvropenreadrrorp)rZ spec_fileZ vendor_hookZproblemZfixedZ fixed_hookZfieldvalZdef_setup_callZ def_buildZ install_cmdZscript_optionsZrpm_optattrdefaultrrrrs          #     # &       (     zbdist_rpm._make_spec_filecCs|s |Sg}x|jjdD]i}|j}|ddkr^|jd|gq&|ddkr~|j|q&|jd|q&W|ds|d=n|S)zKFormat the changelog correctly and convert it to a list of strings rrrrrz )rrrr)rrpZ new_changelogrrrrr3s   zbdist_rpm._format_changelog)r Nr )r Nr )rrr)rNr)rNr)rNr)rNr)rNr)rNr)rNr)rNr )r!Nr")r#Nr$)r%Nr&)r'Nr()r)Nr*)r+Nr,)r-Nr.)r/Nr0)r1Nr2)r3Nr4)r5Nr6)r7Nr8)r9Nr:)r;r<r=)r>Nr?)r@NrA)rBNrC)rDNrE)rFNrG)rHNrI)rJNrK)rLNrM)rNNrO)rPNrQ)rRNrS)rTNrU)rVNrW)rXNrY)rZNr[)zquietr]r^)__name__ __module__ __qualname__Z descriptionZ user_optionsZboolean_optionsZ negative_optrrrrrrrrrrrr s       -  -  r )__doc__rrrZdistutils.corerZdistutils.debugrZdistutils.utilrZdistutils.file_utilrZdistutils.errorsZdistutils.sysconfigrZ distutilsrr rrrrs$