B hêBË›Úrã@s€dZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl Tddl mZdd lmZGd d „d eƒZdS) 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¸eZdZdZdddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*g)Zd+d,d-d.d/gZd+d,d-d0œZd1d2„Zd3d4„Zd5d6„Z d7d8„Z d9d:„Z d;d<„Z d=d>„Z d?S)@Ú 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)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])zuse-rpm-opt-flagsNz8compile with RPM_OPT_FLAGS when building from source RPM)zno-rpm-opt-flagsNz&do not pass any RPM CFLAGS to compiler)z rpm3-modeNz"RPM 3 compatibility mode (default))z 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/opt/alt/python37/lib/python3.7/distutils/command/bdist_rpm.pyÚinitialize_optionsˆsNzbdist_rpm.initialize_optionscCsº| dd¡|jdkr6|js$tdƒ‚tj |jd¡|_|jdkrX|j rPt j |_qfd|_n|j rftdƒ‚tj dkr~t dtj ƒ‚|jr’|jr’td ƒ‚|j ¡s¢d |_| dd ¡| ¡dS) NZbdist)rrz)you must specify --rpm-base in RPM 2 modeÚrpmZpython3z8--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)rr)Zset_undefined_optionsrr2ZDistutilsOptionErrorÚosÚpathÚjoinrrrÚsysÚ executableÚnameZDistutilsPlatformErrorrrÚ distributionÚhas_ext_modulesr1Úfinalize_package_data)r5r6r6r7Úfinalize_optionsµs.         zbdist_rpm.finalize_optionscCsX| dd¡| dd|j ¡|j ¡f¡| d¡| d¡t|jtƒr|x.dD]&}tj   |¡rR||jkrR|j  |¡qRW| dd ¡| d ¡| d ¡| d ¡|  |j ¡|_ | d ¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡| d¡dS)NrzDevelopment/Librariesrz%s <%s>rr)ZREADMEz README.txtrÚ1rrrr r!r"r#r$r%r&r'r(r)r+r,r-r.r/r4)Z ensure_stringrAZ get_contactZget_contact_emailZensure_string_listÚ isinstancerÚlistr;r<ÚexistsÚappendÚ_format_changelogrZensure_filename)r5Zreadmer6r6r7rCÔs>                         zbdist_rpm.finalize_package_datacCsêtrŸsz-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ú 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_FILES)r*r!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ú%Úrz%files -f INSTALLED_FILESz%defattr(-,root,root)z%doc z %changelog)'rArSZ get_versionÚreplacerZget_descriptionÚ subprocessZ getoutputr=Ú splitlinesrIrVrZ get_licenserr4rBÚgetattrÚlowerrFrGZget_urlrr.r r;r<r`r3Zget_long_descriptionrr>Úargvr1ÚopenÚreadr[rr)r5Z spec_fileZ vendor_hookZproblemZfixedZ fixed_hookZfieldÚvalZdef_setup_callZ def_buildZ install_cmdZscript_optionsZrpm_optÚattrÚdefaultr6r6r7rT‹s°                    zbdist_rpm._make_spec_filecCs€|s|Sg}x`| ¡ d¡D]N}| ¡}|ddkrD| d|g¡q|ddkr\| |¡q| d|¡qW|ds||d=|S)zKFormat the changelog correctly and convert it to a list of strings rkrrrjrhz )rZr[rVrI)r5rZ new_changelogrcr6r6r7rJ3s   zbdist_rpm._format_changelogN)Ú__name__Ú __module__Ú __qualname__Z descriptionZ user_optionsZboolean_optionsZ negative_optr8rDrCrfrgrTrJr6r6r6r7r sp--)r )Ú__doc__rrr>r;Zdistutils.corerZdistutils.debugrZdistutils.utilrZdistutils.file_utilrZdistutils.errorsZdistutils.sysconfigrZ distutilsrr r6r6r6r7Ús