我正在尝试安装我构建的需要gnuplot的软件包。
我目前在我的CentOS机器上安装了gnuplot:
$ which gnuplot
/usr/bin/gnuplot
$ gnuplot --version
gnuplot 4.6 patchlevel 2
但是当我尝试安装软件包时,出现以下错误:
$ sudo yum install my_package.rpm
Loaded plugins: fastestmirror
Examining my_package.rpm: my_package.x86_64
Marking my_package.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package my_package will be installed
--> Processing Dependency: /usr/bin/gnuplot for package: my_package.x86_64
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 30 kB 00:00:00
[...]
--> Processing Dependency: /usr/bin/gnuplot for package: my_package.x86_64
--> Processing Dependency: /usr/bin/gnuplot for package: my_package.x86_64
--> Finished Dependency Resolution
Error: Package: my_package.x86_64 (/my_package)
Requires: /usr/bin/gnuplot
Error: Package: my_package.x86_64 (installed)
Requires: /usr/bin/gnuplot
You could try using --skip-broken to work around the problem
** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows:
my_package.x86_64 has missing requires of /usr/bin/gnuplot
如果我使用rpm,我有同样的问题:
$ sudo rpm -ivh my_package.rpm
error: Failed dependencies:
/usr/bin/gnuplot is needed by my_package.x86_64
由于安装了gnuplot,我不明白为什么百胜抱怨...
好的我通过修改脚本的shebang修复了它:
#!/bin/bash
[...]
gnuplot -persist <<-EOFMarker
[...]
EOFMarker
这显然是一个黑客,但它正在工作,因为在安装rpm时,不再抱怨未安装的/ usr / bin / gnuplot。
你在评论中想出了问题 - RPM并不关心你系统上的内容;它只关心其数据库中的内容。如果你没有通过RPM安装gnuplot
,它就不知道它在那里。
对此唯一“正确”的答案是使用RPM(这是幕后的yum
或dnf
)在您的机器上安装工具。这些工具已经存在了很长时间,这是有充分理由的 - 您可以轻松确保您的软件无需假设即可在目标盒上运行。
也就是说,如果你想制作一个格式错误的RPM,只是假设gnuplot
在那里,你可以添加到RPM规范文件AutoReqProv: no
(参见this reference)。如果你这样做,你可能想要添加许多手动Requires
线覆盖其他一切。您还应该调整使用gnuplot
的脚本,不再认为它存在并明确检查它是否首先向用户返回有用的消息(如果不是,例如“您需要安装gnuplot”)。