Setuptools: bdist_rpm fails when installing man pages

Created on 18 Feb 2018  路  7Comments  路  Source: pypa/setuptools

Hello I noticed that this issue has not been fixed yet?
The reason for this failure is

1) bdist_rpm generates a .spec file with the following
install command:
python setup.py install --root=$RPM_BUILD_ROOT
--record=INSTALLED_FILES
.. and the following files section
%files -f INSTALLED_FILES

2) if the setup.py installed any man pages, then after
%install and before %files rpm runs brp-compress (usually
found in /usr/lib/rpm/brp-compress) which compresses all man
pages with gzip.

3) Now the man pages have a '.gz' suffix, but the
INSTALLED_FILES file lists them still without the suffix.
The %files section of the rpm .spec file will fail.

The proposed solution seems to work.

diff --git a/setuptools/command/bdist_rpm.py b/setuptools/command/bdist_rpm.py
index 70730927..eee85795 100755
--- a/setuptools/command/bdist_rpm.py
+++ b/setuptools/command/bdist_rpm.py
@@ -31,6 +31,9 @@ class bdist_rpm(orig.bdist_rpm):
             ).replace(
                 "setup.py install ",
                 "setup.py install --single-version-externally-managed "
+            ).replace(
+                "--record=INSTALLED_FILES",
+                "--record=INSTALLED_FILES;sed -i -e 's:\\.gz$:\\.gz:;t;s:\\(/man/man.*/.*\):\\1.gz:' INSTALLED_FILES"
             ).replace(
                 "%setup",
                 "%setup -n %{name}-%{unmangled_version}"

Any thoughts?

Needs Triage bug

Most helpful comment

Any chance to get this fixed? We're impacted...

All 7 comments

The proposed patch is the wrong one.
It _Assumes_ the compressed format IS .gz.
That is a flawed assumption.

Debian uses the suffix 芦.gz禄
Mandriva (when it existed) used 芦.lzma禄.
OpenMandriva and Mageia use 芦.xz禄.

One should assume that the manpage compression suffix differ among distros.

I think I just stumbled across the solution, on Stack Overflow.

Apparently one can define the compression used, by adding two 芦%define禄 lines in the spec.
Specifically these ones:
%define _source_payload w9.gzdio
%define _binary_payload w9.gzdio

Adding those to the top of the spec file overrides the distribution's prefered manpage compression, and use 芦.gz禄 as suffix

I was thinking about the comparability issue with Windows (sed might not be available there).

But one don't create rpm's on Windows?
This issue is explisitly for creating RPM files.

One of the comments from the link above suggests changing .gz to *.


diff --git a/setuptools/command/bdist_rpm.py b/setuptools/command/bdist_rpm.py
index 70730927..dc595dae 100755
--- a/setuptools/command/bdist_rpm.py
+++ b/setuptools/command/bdist_rpm.py
@@ -31,6 +31,9 @@ class bdist_rpm(orig.bdist_rpm):
             ).replace(
                 "setup.py install ",
                 "setup.py install --single-version-externally-managed "
+            ).replace(
+                "--record=INSTALLED_FILES",
+                "--record=INSTALLED_FILES;sed -i -e 's:\\.gz$:\\.gz:;t;s:\\(/man/man.*/.*\):\\1.*:' INSTALLED_FILES"
             ).replace(
                 "%setup",
                 "%setup -n %{name}-%{unmangled_version}"

In such case do we still need the 芦%define禄 lines in the spec?

Any chance to get this fixed? We're impacted...

Sorry you're impacted. What's needed is a viable solution and we can roll it into a release. I'm uneasy about the proposed patch, which seems to be injecting a command around an option. Already, the line-by-line hack is kinda ugly, but this adds a second-order hack on that hack. If that's the best hack available, I guess that's acceptable, but in that case, I'd like at least for there to be a comment explaining what the hack is doing. I don't know if it's possible, but I'd rather see a patch that doesn't interleave so many concerns... even just inserting another line for the sed command would be substantially better than injecting it into another command and relying on ; to split those into two.

Was this page helpful?
0 / 5 - 0 ratings