źhUdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z m Z mZddlmZdd lmZGd d eZdS) zwdistutils.command.bdist_rpm Implements the Distutils 'bdist_rpm' command (create RPM source and binary distributions).N)Command)DEBUG) write_file)DistutilsOptionErrorDistutilsPlatformErrorDistutilsFileErrorDistutilsExecError)get_python_version)logcXeZdZdZgdZgdZddddZdZd Zd Z d Z d Z d Z dZ 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-tempkz"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=Nzfinalize_package_datarBs rDfinalize_optionszbdist_rpm.finalize_optionssB ""7,HIII = > X*+VWWWGLL%@@DM ;  (!n ' _ &J  7g  (NQSQXX     0 &H   0022 '%&D " ""7,DEEE ""$$$$$rFcd|dd|d|jd|jd|d|dt |jtrGdD]D}tj |r#||jvr|j |E|d d |d |d |d | |j |_ |d|d|d|d|d|d|d|d|d|d|d|d|d|d|d|ddS)Nr&zDevelopment/Librariesr)z <>r*r+)READMEz README.txtr'1r(r%r,r-r.r/r0r1r2r3r4r5r6r8r9r:r;r<rA) ensure_stringrS get_contactget_contact_emailensure_string_list isinstancer+listrMrNexistsappend_format_changelogr,ensure_filename)rCreadmes rDrUzbdist_rpm.finalize_package_datas 7$;<<<   ,,....0A0S0S0U0U0U0U W   :&&&  ,,, dnd + + 22 2 27>>&))2fDN.J.JN))&111 9c*** 8$$$ ./// ;'''//?? V$$$ ]+++ ^,,, -... ^,,, _--- ]+++ ^,,, _--- -...  +++  +++  ,,,  0111  ,,, <(((((rFc trctdtd|jtd|jtd|jtd|j|jr|j}||nRi}dD]E}tj |j |||<|||F|d}tj |d|j z}|t ||fd |z|jrdS|j jdd}|d }|jr d g|_nd g|_|d ||j _|d }|d}||||jrWtj |jr||j|nt7d|jzt9jddg} |jr| dn2|j r| dn| d| !dd|j"zg|j#r<| !ddtj $|j zg|j%s| d|j&r| d| |d} | dz} d| zdz} d'| | |} tj(| } g}d} |)}|sna|*+}tY|d ksJ||d!||d }x|-}|rt]d"t_| z |-n#|-wxYw|0| |j1s|j 2rtg}nd#}|j stj |d$|}tj |sJ|4||jtj |j|}|j jd%||f|js|D]}tj |d&|}tj |r|4||jtj |jtj 5|}|j jd%||fdSdSdS)'Nzbefore _get_package_data():zvendor =z packager =z doc_files =z changelog =)SOURCESSPECSBUILDRPMSSRPMSrhz%s.specz writing '%s'sdistbztargztarrrgzicon file '%s' does not existz building RPMsrpmbuildz-bsz-bbz-baz--definez __python %sz _topdir %sz--cleanz--quietz%{name}-%{version}-%{release}z.src.rpmz%{arch}/z .%{arch}.rpmz%rpm -q --qf '{} {}\n' --specfile '{}'TrrzFailed to execute: %sanyrkrrj)6rprintr)r*r+r,r!rmkpathrMrNrOrrSget_nameexecuter_make_spec_file dist_filesreinitialize_commandr$formats run_commandget_archive_files copy_filer-rar r infor#rbr"extendrr?abspathr=rformatpopenreadlinestripsplitlencloser reprspawndry_runrTr move_filebasename)rCspec_dirrpm_dirr spec_pathsaved_dist_filesrlsource source_dirrpm_cmd nvr_stringsrc_rpm non_src_rpmq_cmdout binary_rpms source_rpmlineellstatus pyversionsrpmfilenamerIs rDrunz bdist_rpm.runs  1 / 0 0 0 *dk * * * , . . . - 0 0 0 - 0 0 0 > (}H KK ! ! ! !GC ( (W\\$-;;  GAJ''''w'HGLL9t7H7Q7Q7S7S+STT  D$8$8$:$:;^i=W    >  F ,7:))'22 > &$IEMM$IEM !!!'7$((**1-Y'  vz*** 9 Vw~~di(( Vty*5555()H49)TUUU !!!,   " NN5 ! ! ! !   " NN5 ! ! ! ! NN5 ! ! ! MDK$?@AAA > X NNJ rwt}7U7U(UV W W W~ & NN9 % % % : & NN9 % % %y!!! 5 z) :-> 8??      huoo KJ (||~~jjll((**3xx1}}}}""3q6***%!$QJ (YY[[F P()@4;;)NOOO P IIKKKKCIIKKKK 7|  0022 ".00 ! # Xw||GG$4jAAw~~d+++++tT]3337<< zBB!,33[)X4VWWW# &C',,wv<'    s B2Q''Q=ctj|jtj|S)N)rMrNrOrr)rCrNs rD _dist_pathzbdist_rpm._dist_paths*w||DM27+;+;D+A+ABBBrFc  d|jzd|jddzd|jzd|jddzdd|jpd zg}t jd }d d | D}d }d}|||}||kr0| d| d|zd z| gd|j r| dn| d| d|j pd zd|jzddg|js/|js| dn| d|jzdD]}t#||}t'|t(r=| d|d|v|)| d|||jr/| d|jz|jr| d|jz|jr0| d d|jz|jr:| d!t4j|jz|jr| d"| dd#|jpdgd$|jt4jt@j!d%}d&|z} |j"rd'| z} d(|z} d)d*d+| fd,d-| fd.d/d0d1d2d3g } | D]\} } }t#|| }|s|r| dd4| zg|rbtG|5}| |$%d dddn #1swxYwY| || gd5|j&r0| d6d|j&z|j'r1| dd7g| |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: UNKNOWNzrpm --eval %{__os_install_post} c<g|]}d|zS)z %s \)r).0rs rD z-bdist_rpm._make_spec_file..s% K K K$Y % K K KrFzbrp-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)VendorPackagerProvidesRequires Conflicts Obsoletesz{}: {} NzUrl: zDistribution: zBuildRequires: zIcon: z AutoReq: 0z %descriptionz{} {}rz%s buildzenv CFLAGS="$RPM_OPT_FLAGS" z>%s install -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES)r7r.z&%setup -n %{name}-%{unmangled_version}buildr/installr0)cleanr1zrm -rf $RPM_BUILD_ROOT) verifyscriptr2N)prer3N)postr4N)preunr5N)postunr6N%)rz%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z %changelog)(rSrs get_versionreplacer'get_description subprocess getoutputrO splitlinesrbr}r$ get_licenser&rArTgetattrlowerr_r`rget_urlr%r;r-rMrNrr@get_long_descriptionrrPargvr>openreadrr+r,)rC spec_file vendor_hookproblemfixed fixed_hookfieldvaldef_setup_call def_build install_cmdscript_optionsrpm_optattrdefaultfs rDruzbdist_rpm._make_spec_files> d/88:: : !2!>!>!@!@!H!Hc!R!R R (4+<+H+H+J+J J !5!5c3!?!? ?  4,<<>>K) L  !*+LMM ii K K+2H2H2J2J K K K  09 ((%88  $ $   Q R R R   9JFM N N N        > M   L M M M M   K L L Lt0<<>>K)LDJ&P$      @$4466 6  !4555   _t> ? ? ? > >E$ ..C#t$$ >   !F!FGGGG  !B    (! RW5E5Echqk5R5RSS/  ! C6BI P  N ni 0 (+ 6 ? 3 ( * , .  '5 . . "GT7$%%C .g .  g  .c?a!(()=)=>>>???????????????$$W---        > A   Wsxx'?'?? @ @ @ > -          T^ , , ,s;S##S' *S' c`|s|Sg}|dD]t}|}|ddkr|d|g:|ddkr||\|d|zu|ds|d=|S)zBFormat the changelog correctly and convert it to a list of stringsrr*rrz )rrr}rb)rCr, new_changelogrs rDrczbdist_rpm._format_changelogTs   OO%%++D11 2 2D::<rs  """""" +*****O O O O O O O O O O rF