fedora-python / pyp2rpm

Tool to convert a package from PyPI to RPM SPECFILE or to generate SRPM.
MIT License
123 stars 39 forks source link

missing new line #258

Closed falon closed 3 years ago

falon commented 3 years ago

Hello,

I modified the epel7.spec in %install as following:

{%- for pv in data.python_versions + [data.base_python_version] %}
{%- if pv == data.base_python_version and data.python_versions and data.scripts %}
rm -rf %{buildroot}%{_bindir}/*
{%- endif %}
%{__python{{ pv }}} setup.py install --skip-build --root %{buildroot}
{%- endfor -%}

mv %{buildroot}%{_sysconfdir}/%{pypi_name}/%{pypi_name}.conf.dist %{buildroot}%{_sysconfdir}/%{pypi_name}/%{pypi_name}.conf
install -d -Cm 0755 %{buildroot}%{_unitdir}

I only added the mv line before "install -d -Cm 0755...".

When I run pyp2rpm -o epel7 -t epel7 -b 3 -s dist/<%{pypi_name}>-0.1.post8.tar.gz

I see:

INFO  Pyp2rpm initialized.
INFO  Using /root/rpmbuild/SOURCES as directory to save source.
INFO  Local file: dist/<%{pypi_name}>-0.1.post8.tar.gz copyed to /root/rpmbuild/SOURCES/<%{pypi_name}>-0.1.post8.tar.gz.
INFO  Getting metadata from setup.py using SetupPyMetadataExtractor.
WARNING  Dnf module not found, please dnf install python3-dnf to improve accuracy of name conversion.
INFO  Running extract_dist command with: /usr/bin/python3.8
WARNING  Client is None, it was probably disabled
INFO  Using name: python-<%{pypi_name}>.spec for specfile.
INFO  Specfile saved at: /root/rpmbuild/SPECS/python-<%{pypi_name}>.spec.
INFO  That's all folks!

# dnf list python3-dnf

Installed Packages
python3-dnf.noarch                                             4.2.23-4.el8                                             @rhel-8-for-x86_64-baseos-rpms

The problem is the following: the built spec by pyp2rpm contains:

%install
%{__python3} setup.py install --skip-build --root %{buildroot}mv %{buildroot}%{_sysconfdir}/%{pypi_name}/%{pypi_name}.conf.dist %{buildroot}%{_sysconfdir}/%{pypi_name}/%{pypi_name}.conf
install -d -Cm 0755 %{buildroot}%{_unitdir}
[...]

The issue is that no new line is inserted before the mv command.

The issue is the same for fedora.spec too.

gordonmessmer commented 3 years ago

I think the issue is that you're inserting those lines after "{%- endfor -%}" and before another tag. The '-' character in the closing character group indicates that whitespace after the tag should be discarded.

Try changing that to "{%- endfor %}" and see if you get the output that you want.