Linux CentOS 5.5 - 在 RPM 规范文件中创建符号链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4823757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:39:49  来源:igfitidea点击:

CentOS 5.5 - symbolic link creation into RPM spec file

linuxcentosrpmcentos5rpm-spec

提问by Dima

I need to create the following symbolic links into RPM file

我需要在 RPM 文件中创建以下符号链接

/bin/ln -sf libcrypto.so.0.9.8e /lib/libcrypto.so.0.9.8
/bin/ln -sf libssl.so.0.9.8e /lib/libssl.so.0.9.8

In my RPM spec file:

在我的 RPM 规范文件中:

%files
%defattr(-,root,root)
/lib/libcrypto.so.0.9.8
/lib/libssl.so.0.9.8
<other files...>

%install
/bin/ln -sf libcrypto.so.0.9.8e /lib/libcrypto.so.0.9.8
/bin/ln -sf libssl.so.0.9.8e /lib/libssl.so.0.9.8

The /lib/libcrypto.so.0.9.8e and /lib/libssl.so.0.9.8e are exists on my PC, but when I'm trying to install my RPM, I got an error:

我的 PC 上存在 /lib/libcrypto.so.0.9.8e 和 /lib/libssl.so.0.9.8e,但是当我尝试安装 RPM 时,出现错误:

libcrypto.so.0.9.8 is needed by my-test-rpm-1.el5.i686
libssl.so.0.9.8 is needed by my-test-rpm-1.el5.i686

What wrong? What I need to do in order to create symbolic links as part of the RPM installation?

什么错?我需要做什么才能创建符号链接作为 RPM 安装的一部分?

Thanks

谢谢

采纳答案by Dima

As workaround I disabled automatic dependency processing by adding:

作为解决方法,我通过添加以下内容禁用了自动依赖处理:

AutoReqProv: no

to my spec file. I'm still looking for the real solution.

到我的规范文件。我仍在寻找真正的解决方案。

回答by ldav1s

You need to run ldconfig in the %post part of the spec file:

您需要在规范文件的 %post 部分运行 ldconfig:

%post
umask 007
/sbin/ldconfig > /dev/null 2>&1


%postun
umask 007
/sbin/ldconfig > /dev/null 2>&1

should do it.

应该这样做。

回答by reichhart

1) Just for symlinks you don't need to call ldconfig at post stage.

1)仅对于符号链接,您不需要在后期调用 ldconfig 。

2) As already mentioned by ldav1s: Be sure that your files are listed in %files section.

2) 正如 ldav1s 已经提到的:确保您的文件列在 %files 部分。

3) Once again: Be sure that your files are listed - especiallyif you use something like

3)再次:确保您的文件已列出 -特别是如果您使用类似

%define _unpackaged_files_terminate_build 0

RHEL rpmbuild terminates with an error if files are found in buildroot which are not listed in %files section. With this define you can switch the behaviour/error off but you should exactly know what you are actually doing. If you use this line you should remove it from your spec file.

如果在 buildroot 中找到未在 %files 部分中列出的文件,则 RHEL rpmbuild 会因错误而终止。使用此定义,您可以关闭行为/错误,但您应该确切地知道自己在做什么。如果你使用这一行,你应该从你的规范文件中删除它。

4) Don't build the rpm package as user root. If you forget to use rpm_build_root you won't destroy your live system. Your example looks like it was taken from a spec file of Red Hat 4.2 of 1997. Since Red Hat 5 (not RHEL 5!) in 1997 the rpm/rpmbuild command knows the RPM_BUILD_ROOT definition. I guess that this is your problem: You don't use the buildroot but install directly into the root FS and run rpmbuild as user root.

4)不要以root用户身份构建rpm包。如果您忘记使用 rpm_build_root,您将不会破坏您的实时系统。您的示例看起来像是取自 1997 年 Red Hat 4.2 的规范文件。自 1997 年的 Red Hat 5(不是 RHEL 5!)以来,rpm/rpmbuild 命令知道 RPM_BUILD_ROOT 定义。我猜这是您的问题:您不使用 buildroot,而是直接安装到 root FS 并以 root 用户身份运行 rpmbuild。

Given your example it should be changed to:

鉴于您的示例,它应该更改为:

%install
/bin/ln -sf libcrypto.so.0.9.8e $RPM_BUILD_ROOT/lib/libcrypto.so.0.9.8
/bin/ln -sf libssl.so.0.9.8e $RPM_BUILD_ROOT/lib/libssl.so.0.9.8

Using buildroot is described in RPM docs.

RPM 文档中描述了使用 buildroot 。

回答by jayhendren

The best way to do this is by preventing the symlinks you created from being scanned by the automatic depends & requires generators:

最好的方法是防止您创建的符号链接被自动依赖和需要生成器扫描:

%filter_provides_in libcrypto.so.0.9.8e
%filter_provides_in libssl.so.0.9.8e
%filter_requires_in libcrypto.so.0.9.8e
%filter_requires_in libssl.so.0.9.8e
%filter_setup

More information on depends/requires filtering here.

有关取决于/需要过滤的更多信息,请点击此处