Linux 如何忽略 rpm 安装中的冲突

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17582768/
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-07 00:13:34  来源:igfitidea点击:

How to ignore conflicts in rpm installs

linuxunixrpmaix

提问by Cobra Kai Dojo

I have a bunch of rpm files in a folder. I am trying to install them using: rpm -ivh *.rpmso rpm can take care of the correct installation order.

我在一个文件夹中有一堆 rpm 文件。我正在尝试使用以下方法安装它们: rpm -ivh *.rpm因此 rpm 可以处理正确的安装顺序。

On some of these rpms I have a newer version installed in my system so I get for example:

在其中一些 rpm 上,我的系统中安装了较新版本,因此我得到例如:

package info-5.0-1 (which is newer than info-4.13a-2) is already installed

package info-5.0-1 (which is newer than info-4.13a-2) is already installed

/opt/freeware/man/man1/infokey.1 from install of info-4.13a-2 conflicts with file from package info-5.0-1

/opt/freeware/man/man1/infokey.1 from install of info-4.13a-2 conflicts with file from package info-5.0-1

Is there a way to ignore the old .rpm file and resolve the dependency with the new version that is already installed? I thought of the --force option. But how --force resolves the conflicts? Overwrites them with the older version or just ignores them leaving the new version?

有没有办法忽略旧的 .rpm 文件并解决与已经安装的新版本的依赖关系?我想到了 --force 选项。但是 --force 如何解决冲突?用旧版本覆盖它们还是忽略它们离开新版本?

Any thoughts are welcome.

欢迎任何想法。

回答by James

From the context, the conflict was caused by the version of the package.
Let's take a look the manual about rpm:

从上下文来看,冲突是由包的版本引起的。
让我们来看看手册rpm

--force
    Same as using --replacepkgs, --replacefiles, and --oldpackage.

--oldpackage
    Allow an upgrade to replace a newer package with an older one.

So, you can execute the command rpm -Uvh info-4.13a-2.rpm --forceto solve your issue.

因此,您可以执行命令rpm -Uvh info-4.13a-2.rpm --force来解决您的问题。

回答by Kalim Sayyed

Try Freshen command:

尝试 Freshen 命令:

rpm -Fvh *.rpm

回答by xoryves

The --forceoption will reinstall already installed packages or overwrite already installed files from other packages. You don't want this normally.

--force选项将重新安装已安装的软件包或覆盖其他软件包中已安装的文件。你通常不想要这个。

If you tell rpmto install all RPMs from some directory, then it does exactly this. rpmwill not ignore RPMs listed for installation. You must manually remove the unneeded RPMs from the list (or directory). It will always overwrite the files with the "latest RPM installed" whichever order you do it in.

如果您告诉rpm从某个目录安装所有 RPM,那么它就是这样做的。rpm不会忽略为安装列出的 RPM。您必须从列表(或目录)中手动删除不需要的 RPM。无论您按哪种顺序执行,它都会始终使用“安装的最新 RPM”覆盖文件。

You can remove the old RPM and rpmwill resolve the dependency with the newer version of the installed RPM. But this will only work, if none of the to be installed RPMs depends exactly on the old version.

您可以删除旧的 RPM,并rpm使用已安装 RPM 的较新版本解决依赖关系。但这只会起作用,如果要安装的 RPM 都不完全依赖于旧版本。

If you really need different versions of the same RPM, then the RPM must be relocatable. You can then tell rpmto install the specific RPM to a different directory. If the files are not conflicting, then you can just install different versions with rpm -i(zypper incan not install different versions of the same RPM). I am packaging for example ruby gems as relocatable RPMs at work. So I can have different versions of the same gem installed.

如果您确实需要相同 RPM 的不同版本,那么 RPM 必须是可重定位的。然后,您可以告诉rpm将特定 RPM 安装到不同的目录。如果文件没有冲突,那么你可以安装不同的版本rpm -izypper in不能安装相同RPM的不同版本)。例如,我将 ruby​​ gem 打包为工作中的可重定位 RPM。所以我可以安装同一个 gem 的不同版本。

I don't know on which files your RPMs are conflicting, but if all of them are "just" man pages, then you probably can simply overwrite the new ones with the old ones with rpm -i --replacefiles. The only problem with this would be, that it could confuse somebody who is reading the old man page and thinks it is for the actual version. Another problem would be the rpm --verifycommand. It will complain for the new package if the old one has overwritten some files.

我不知道您的 RPM 与哪些文件发生冲突,但是如果所有这些文件都“只是”手册页,那么您可能只需使用rpm -i --replacefiles. 唯一的问题是,它可能会使正在阅读旧手册页并认为它适用于实际版本的人感到困惑。另一个问题是rpm --verify命令。如果旧包覆盖了一些文件,它会抱怨新包。

Is this possibly a duplicate of https://serverfault.com/questions/522525/rpm-ignore-conflicts?

这可能是https://serverfault.com/questions/522525/rpm-ignore-conflicts的副本吗?