从 .so 文件中删除路径,以便 RPM check-buildroot 成功
Removing paths from .so files so that RPM check-buildroot succeeds
我正在将一些 Python 库打包为 RPM。一些库仅可作为源代码分发(无轮子)。
在我的 RPM 规范中我这样做:
pip install --root=%{buildroot} --prefix=/x/y tornado
当 rpmbuild
完成 运行s check-buildroot
时,构建失败并出现如下错误:
Binary file /a/b/c/BUILDROOT/my-rpm-1.0.0-1.el7.x86_64/x/y/lib64/python2.7/site-packages/tornado/speedups.so matches
如果 运行 strings tornado.so | grep BUILDROOT
.
,我会看到列出的 %{buildroot}
路径
如何清理 .so
文件?或者更一般地说,我怎样才能让 check-buildroot
通过?
我想出了如何从 SO 文件中删除路径。
我确定路径是使用此命令嵌入的调试信息:
readelf --debug-dump=line speedups.so | less
strip
命令可以从 SO 文件中删除调试信息,因此我将其添加到我的 RPM 规范中:
BuildRequires: binutils
set +e
find "%{buildroot}{%_prefix}/lib64/python2.7/site-packages" -type f -name "*.so" | while read so_file
do
strip --strip-debug "$so_file"
done
set -e
注意:strip
某些 SO 文件存在段错误,原因尚不清楚。我使用 set +e
禁用了立即退出,以便构建忽略它们。
我正在将一些 Python 库打包为 RPM。一些库仅可作为源代码分发(无轮子)。
在我的 RPM 规范中我这样做:
pip install --root=%{buildroot} --prefix=/x/y tornado
当 rpmbuild
完成 运行s check-buildroot
时,构建失败并出现如下错误:
Binary file /a/b/c/BUILDROOT/my-rpm-1.0.0-1.el7.x86_64/x/y/lib64/python2.7/site-packages/tornado/speedups.so matches
如果 运行 strings tornado.so | grep BUILDROOT
.
%{buildroot}
路径
如何清理 .so
文件?或者更一般地说,我怎样才能让 check-buildroot
通过?
我想出了如何从 SO 文件中删除路径。
我确定路径是使用此命令嵌入的调试信息:
readelf --debug-dump=line speedups.so | less
strip
命令可以从 SO 文件中删除调试信息,因此我将其添加到我的 RPM 规范中:
BuildRequires: binutils
set +e
find "%{buildroot}{%_prefix}/lib64/python2.7/site-packages" -type f -name "*.so" | while read so_file
do
strip --strip-debug "$so_file"
done
set -e
注意:strip
某些 SO 文件存在段错误,原因尚不清楚。我使用 set +e
禁用了立即退出,以便构建忽略它们。