Linux 如何让rpm自动安装依赖
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13876875/
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
How to make rpm auto install dependencies
提问by HAL
I have built two RPM packages
我已经构建了两个 RPM 包
proj1-1.0-1.x86_64.rpm
libtest1-1.0-1.x86_64.rpm
proj1-1.0-1.x86_64.rpm
libtest1-1.0-1.x86_64.rpm
proj1
depends on the file libtest1.so
being present and it is reflected correctly in the RPM packages as seen here:
proj1
取决于libtest1.so
存在的文件,它在 RPM 包中正确反映,如下所示:
user@my-pc:~$ rpm -qp --requires proj1-1.0-1.x86_64.rpm
libtest1.so()(64bit)
user@my-pc:~$ rpm -qp --provides libtest1-1.0-1.x86_64.rpm
libtest1.so()(64bit)
The installation of proj1
fails due to a missing dependency.
proj1
由于缺少依赖项,安装失败。
user@my-pc:~$ rpm -ivh proj1-1.0-1.x86_64.rpm
error: Failed dependencies:
libtest1.so()(64bit) is needed by proj1-1.0-1.x86_64.rpm
How do I ensure that libtest1-1.0-1.x86_64.rpm
is installed automatically during
the installation of proj1-1.0-1.x86_64.rpm
?
如何确保libtest1-1.0-1.x86_64.rpm
在安装过程中自动安装proj1-1.0-1.x86_64.rpm
?
I did try the --aid
option with rpm -i
as described herebut it didn't work for me.
我确实按照此处所述尝试了该--aid
选项,但它对我不起作用。rpm -i
Is there any other way?
有没有其他办法?
Thanks for any help.
谢谢你的帮助。
采纳答案by gertvdijk
Create a (local) repository and use yum
to have it resolve the dependencies for you.
创建一个(本地)存储库并使用yum
它来为您解析依赖项。
The CentOS wiki has a nice page providing a how-to on this. CentOS wiki HowTos/CreateLocalRepos.
CentOS wiki 有一个很好的页面,提供了有关此的操作方法。CentOS wiki HowTos/CreateLocalRepos。
Summarized and further minimized (not ideal, but quickest):
总结并进一步最小化(不理想,但最快):
- Create a directory for you local repository, e.g.
/home/user/repo
. - Move the RPMs into that directory.
Fix some ownership and filesystem permissions:
# chown -R root.root /home/user/repo
Install the
createrepo
package if not installed yet, and run# createrepo /home/user/repo # chmod -R o-w+r /home/user/repo
Create a repository configuration file, e.g.
/etc/yum.repos.d/myrepo.repo
containing[local] name=My Awesome Repo baseurl=file:///home/user/repo enabled=1 gpgcheck=0
Install your package using
# yum install packagename
- 为您的本地存储库创建一个目录,例如
/home/user/repo
. - 将 RPM 移动到该目录中。
修复一些所有权和文件系统权限:
# chown -R root.root /home/user/repo
createrepo
如果尚未安装,请安装软件包,然后运行# createrepo /home/user/repo # chmod -R o-w+r /home/user/repo
创建一个存储库配置文件,例如
/etc/yum.repos.d/myrepo.repo
包含[local] name=My Awesome Repo baseurl=file:///home/user/repo enabled=1 gpgcheck=0
使用安装你的包
# yum install packagename
回答by Matthew
The link @gertvdijk provided shows a quick way to achieve the desired results without configuring a local repository:
@gertvdijk 提供的链接显示了一种无需配置本地存储库即可获得所需结果的快速方法:
$ yum --nogpgcheck localinstall packagename.arch.rpm
Just change packagename.arch.rpm
to the RPM filename you want to install.
只需更改packagename.arch.rpm
为您要安装的 RPM 文件名即可。
EditJust a clarification, this will automatically install all dependencies that are already available via system YUM repositories.
编辑只是澄清一下,这将自动安装通过系统 YUM 存储库已经可用的所有依赖项。
If you have dependencies satisfied by other RPMs that are not in the system's repositories, then this method will not work unless each RPM is also specified along with packagename.arch.rpm
on the command line.
如果您的依赖项由不在系统存储库中的其他 RPM 满足,则除非packagename.arch.rpm
在命令行中还指定了每个 RPM,否则此方法将不起作用。
回答by Rajaram
I found a simpler solution. If you have all the RPMs in the same directory, all you need to do is,
我找到了一个更简单的解决方案。如果您在同一目录中拥有所有 RPM,则您需要做的就是,
$ sudo rpm -i *.rpm
rpm
seems to figure out the correct order to install these and installs the RPMs.
rpm
似乎找出了安装这些并安装 RPM 的正确顺序。
回答by mimoralea
For dnf users just use dnf install *.rpm
, localinstall
is no longer needed.
对于 dnf 用户,只需使用dnf install *.rpm
,localinstall
不再需要。
回答by user5377363
For me worked just with
对我来说只是与
# yum install ffmpeg-2.6.4-1.fc22.x86_64.rpm
And automatically asked authorization to dowload the depedencies. Below the example, i am using fedora 22
并自动请求授权以下载依赖项。在示例下方,我使用的是 Fedora 22
[root@localhost lukas]# yum install ffmpeg-2.6.4-1.fc22.x86_64.rpm
Yum command has been deprecated, redirecting to '/usr/bin/dnf install ffmpeg-2.6.4-1.fc22.x86_64.rpm'.
See 'man dnf' and 'man yum2dnf' for more information.
To transfer transaction metadata from yum to DNF, run:
'dnf install python-dnf-plugins-extras-migrate && dnf-2 migrate'
Last metadata expiration check performed 0:28:24 ago on Fri Sep 25 12:43:44 2015.
Dependencies resolved.
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
SDL x86_64 1.2.15-17.fc22 fedora 214 k
ffmpeg x86_64 2.6.4-1.fc22 @commandline 1.5 M
ffmpeg-libs x86_64 2.6.4-1.fc22 rpmfusion-free-updates 5.0 M
fribidi x86_64 0.19.6-3.fc22 fedora 69 k
lame-libs x86_64 3.99.5-5.fc22 rpmfusion-free 345 k
libass x86_64 0.12.1-1.fc22 updates 85 k
libavdevice x86_64 2.6.4-1.fc22 rpmfusion-free-updates 75 k
libdc1394 x86_64 2.2.2-3.fc22 fedora 124 k
libva x86_64 1.5.1-1.fc22 fedora 79 k
openal-soft x86_64 1.16.0-5.fc22 fedora 292 k
opencv-core x86_64 2.4.11-5.fc22 updates 1.9 M
openjpeg-libs x86_64 1.5.1-14.fc22 fedora 89 k
schroedinger x86_64 1.0.11-7.fc22 fedora 315 k
soxr x86_64 0.1.2-1.fc22 updates 83 k
x264-libs x86_64 0.142-12.20141221git6a301b6.fc22 rpmfusion-free 587 k
x265-libs x86_64 1.6-1.fc22 rpmfusion-free 486 k
xvidcore x86_64 1.3.2-6.fc22 rpmfusion-free 264 k
Transaction Summary
====================================================================================================================
Install 17 Packages
Total size: 11 M
Total download size: 9.9 M
Installed size: 35 M
Is this ok [y/N]: y
回答by specialk1st
I ran into this and what worked for me was to run yum localinstall enterPkgNameHere.rpm
from inside the directory where the .rpm file is located.
我遇到了这个问题,对我yum localinstall enterPkgNameHere.rpm
有用的是从 .rpm 文件所在的目录中运行。
Note: replace the enterPkgNameHere.rpm
with the name of your .rpm file.
注意:将 替换为enterPkgNameHere.rpm
.rpm 文件的名称。
回答by user3248738
Process of generating RPM from source file: 1) download source file with.gz extention. 2) install rpm-build and rpmdevtools from yum install. (rpmbuild folder will be generated...SPECS,SOURCES,RPMS.. folders will should be generated inside the rpmbuild folder). 3) copy the source code.gz to SOURCES folder.(rpmbuild/SOURCES) 4)Untar the tar ball by using the following command. go to SOURCES folder :rpmbuild/SOURCES where tar file is present. command: e.g tar -xvzf httpd-2.22.tar.gz httpd-2.22 folder will be generated in the same path. Check if apr and apr-util and there in httpd-2.22/srclib folder. If apr and apr-util doesnt exist download latest version from apache site ,untar it and put it inside httpd-2.22/srclib folder. Also make sure you have pcre install in your system .
从源文件生成 RPM 的过程: 1) 下载扩展名为 .gz 的源文件。2) 从 yum install 安装 rpm-build 和 rpmdevtools。(将生成 rpmbuild 文件夹...SPECS,SOURCES,RPMS.. 文件夹将在 rpmbuild 文件夹内生成)。3) 将源代码.gz 复制到 SOURCES 文件夹。(rpmbuild/SOURCES) 4) 使用以下命令解压 tar 球。转到存在 tar 文件的 SOURCES 文件夹 :rpmbuild/SOURCES。命令:例如 tar -xvzf httpd-2.22.tar.gz httpd-2.22 文件夹将在同一路径中生成。检查 httpd-2.22/srclib 文件夹中是否有 apr 和 apr-util 。如果 apr 和 apr-util 不存在,请从 apache 站点下载最新版本,将其解压缩并将其放入 httpd-2.22/srclib 文件夹中。还要确保您的系统中安装了 pcre。
5)go to extracted folder and then type below command: ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-proxy --enable-proxy-balancer --with-mpm=worker --enable-mods-static=all 6)run below command once the configure is successful: make 7)after successfull execution od make command run: checkinstall in tha same folder. (if you dont have checkinstall software please download latest version from site) Also checkinstall software has bug which can be solved by following way::::: locate checkinstallrc and then replace TRANSLATE = 1 to TRANSLATE=0 using vim command. Also check for exclude package: EXCLUDE="/selinux" 8)checkinstall will ask for option (type R if you want tp build rpm for source file) 9)Done .rpm file will be built in RPMS folder inside rpmbuild/RPMS file... ALL the BEST ....
5)转到解压文件夹,然后输入以下命令:./configure --prefix=/usr/local/apache2 --with-included-apr --enable-proxy --enable-proxy-balancer --with-mpm= worker --enable-mods-static=all 6) 配置成功后运行以下命令:make 7) 成功执行 od make 命令后运行:checkinstall 在同一文件夹中。(如果您没有 checkinstall 软件,请从站点下载最新版本) checkinstall 软件也有错误,可以通过以下方式解决::::: 定位 checkinstallrc 然后使用 vim 命令将 TRANSLATE = 1 替换为 TRANSLATE = 0。还要检查排除包: EXCLUDE="/selinux" 8)checkinstall 将询问选项(如果您想要源文件的 tp build rpm,请键入 R) 9)完成 .rpm 文件将在 rpmbuild/RPMS 文件内的 RPMS 文件夹中构建。 .. 祝一切顺利 ....
Regards, Prerana
问候, 普雷拉纳
回答by Artur Opalinski
Matthew's answer awoke many emotions, because of the fact that it still lacks a minor detail. The general command would be:
马修的回答唤醒了很多情绪,因为它仍然缺乏一个小细节。一般命令是:
# yum --nogpgcheck localinstall <package1_file_name> ... <packageN_file_name>
The package_file_name
above can include local absolute or relative path, or be a URL (possibly even an URI).
在package_file_name
以上可包括本地绝对或相对路径,或者是一个URL(甚至可能的URI)。
Yum would search for dependencies among all package files given on the command line AND IF IT FAILS to find the dependencies there, it will also use any configured and enabled yum repositories.
Yum 将在命令行上给出的所有包文件中搜索依赖项,如果在那里找不到依赖项,它还将使用任何已配置和启用的 yum 存储库。
Neither the current working directory, nor the paths of any of package_file_name
will be searched, except when any of these directories has been previously configured as an enabled yum
repository.
当前工作目录或任何目录的路径都package_file_name
不会被搜索,除非这些目录中的任何一个先前已配置为启用的yum
存储库。
So in the OP's case the yum
command:
所以在 OP 的情况下,yum
命令:
# cd <path with pkg files>; yum --nogpgcheck localinstall ./proj1-1.0-1.x86_64.rpm ./libtest1-1.0-1.x86_64.rpm
would do, as would do the rpm
:
会做,也会做rpm
:
# cd <path with pkg files>; rpm -i proj1-1.0-1.x86_64.rpm libtest1-1.0-1.x86_64.rpm
The differencve between these yum
and rpm
invocations would only be visible if one of the packages listed to be installed had further dependencies on packages NOT listed on the command line.
只有当列出的要安装的软件包之一对命令行中未列出的软件包有进一步的依赖性时,这些yum
和rpm
调用之间的差异才会可见。
In such a case rpm
will just refuse to continue, while yum
would use any configured and enabled yum repositories to search for dependencies, and may possibly succeed.
在这种情况下rpm
只会拒绝继续,而yum
会使用任何已配置和启用的 yum 存储库来搜索依赖项,并且可能会成功。
The current working directory will NOT be searched in any case, except when it has been previously configured as an enabled yum
repository.
在任何情况下都不会搜索当前工作目录,除非它之前已配置为启用的yum
存储库。
回答by Subham Debnath
Simple just run the following command.
简单只需运行以下命令。
sudo dnf install *package.rpm
Enter your password and you are done.
输入您的密码,您就完成了。
回答by user3405291
In the case of openSUSE Leap 15, I'm receiving similar error:
在 openSUSE Leap 15 的情况下,我收到类似的错误:
> sudo rpm -i opera-stable_53.0.2907.68_amd64.rpm
[sudo] password for root:
warning: opera-stable_53.0.2907.68_amd64.rpm: Header V4 RSA/SHA512 Signature, key ID a5c7ff72: NOKEY
error: Failed dependencies:
at is needed by opera-stable-53.0.2907.68-0.x86_64
I run this command to figure out what are the dependencies:
我运行此命令以找出依赖项:
> sudo zypper install opera-stable_53.0.2907.68_amd64.rpm
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 4 NEW packages are going to be installed:
at libfl2 libHX28 opera-stable
4 new packages to install.
Overall download size: 50.3 MiB. Already cached: 0 B. After the operation, additional 176.9 MiB will be used.
Continue? [y/n/...? shows all options] (y): n
Then I run this command to install dependencies:
然后我运行这个命令来安装依赖项:
> sudo zypper in at
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 3 NEW packages are going to be installed:
at libfl2 libHX28
3 new packages to install.
Overall download size: 208.6 KiB. Already cached: 0 B. After the operation, additional 600.4 KiB will be used.
Continue? [y/n/...? shows all options] (y): y
Then I run this to install the rpm
file:
然后我运行它来安装rpm
文件:
> sudo rpm -i opera-stable_53.0.2907.68_amd64.rpm
I'm notsure if it is the best practice, however it solved my issue.
我不知道这是否是最好的做法,但它解决了我的问题。