Linux上 如何查找yum安装包所缺缺少的依赖包及报错处理

Linux上 如何查找yum安装包所缺缺少的依赖包及报错处理

?前言

大家在不能上外网的Linux上yum安装一包时,如果报错是不是感觉天塌了下来,接下来我们来讲讲遇到这个情况咋处理。

?准备工作

首先,你需要一台能上网的电脑,可以与你安装的不在一个内网中,毕竟要来下载依赖包。

环境:

Linux web-api 3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

??????????????????????????????????

?遇到的问题

现在以为某一次遇到问题来分析,问题如下:

[root@fxyjgxsql postgis32]# yum localinstall *.rpm -y
Loaded plugins: fastestmirror
Examining armadillo-8.600.1-2.el7.x86_64.rpm: armadillo-8.600.1-2.el7.x86_6
...........

---> Package xerces-c.x86_64 0:3.1.1-10.el7_7 will be an update
--> Finished Dependency Resolution
Error: Package: libtiff-devel-4.0.3-35.el7.x86_64 (/libtiff-devel-4.0.3-35.el7.x86_64)
           Requires: libtiff(x86-64) = 4.0.3-35.el7
           Installed: libtiff-4.0.3-27.el7_3.x86_64 (@anaconda)
               libtiff(x86-64) = 4.0.3-27.el7_3
Error: Package: libquadmath-devel-4.8.5-16.el7.x86_64 (@anaconda)
           Requires: libquadmath = 4.8.5-16.el7
           Removing: libquadmath-4.8.5-16.el7.x86_64 (@anaconda)
               libquadmath = 4.8.2-16.el7
               libquadmath = 4.8.5-16.el7
           Updated By: libquadmath-4.8.5-44.el7.x86_64 (/libquadmath-4.8.5-44.el7.x86_64)
               libquadmath = 4.8.2-16.el7
               libquadmath = 4.8.5-44.el7
           Available: libquadmath-4.8.5-36.el7_6.2.x86_64 (hrmw)
               libquadmath = 4.8.5-36.el7_6.2
               libquadmath = 4.8.2-16.el7_6
Error: Package: gpsbabel-1.5.0-2.el7.x86_64 (/gpsbabel-1.5.0-2.el7.x86_64)
           Requires: libQtCore.so.4()(64bit)
Error: Package: boost-chrono-1.53.0-27.el7.x86_64 (@hrmw)
           Requires: boost-system(x86-64) = 1.53.0-27.el7
           Removing: boost-system-1.53.0-27.el7.x86_64 (@anaconda)
               boost-system(x86-64) = 1.53.0-27.el7
           Updated By: boost-system-1.53.0-28.el7.x86_64 (/boost-system-1.53.0-28.el7.x86_64)
               boost-system(x86-64) = 1.53.0-28.el7
Error: Package: boost-filesystem-1.53.0-27.el7.x86_64 (@hrmw)
           Requires: boost-system(x86-64) = 1.53.0-27.el7
           Removing: boost-system-1.53.0-27.el7.x86_64 (@anaconda)
               boost-system(x86-64) = 1.53.0-27.el7
           Updated By: boost-system-1.53.0-28.el7.x86_64 (/boost-system-1.53.0-28.el7.x86_64)
               boost-system(x86-64) = 1.53.0-28.el7
Error: Package: gcc-gfortran-4.8.5-16.el7.x86_64 (@anaconda)
           Requires: libquadmath = 4.8.5-16.el7
           Removing: libquadmath-4.8.5-16.el7.x86_64 (@anaconda)
               libquadmath = 4.8.2-16.el7
               libquadmath = 4.8.5-16.el7
           Updated By: libquadmath-4.8.5-44.el7.x86_64 (/libquadmath-4.8.5-44.el7.x86_64)
               libquadmath = 4.8.2-16.el7
               libquadmath = 4.8.5-44.el7
           Available: libquadmath-4.8.5-36.el7_6.2.x86_64 (hrmw)
               libquadmath = 4.8.5-36.el7_6.2
               libquadmath = 4.8.2-16.el7_6
Error: Package: gcc-gfortran-4.8.5-16.el7.x86_64 (@anaconda)
           Requires: libgfortran = 4.8.5-16.el7
           Removing: libgfortran-4.8.5-16.el7.x86_64 (@anaconda)
               libgfortran = 4.8.2-16.el7
               libgfortran = 4.8.5-16.el7
           Updated By: libgfortran-4.8.5-44.el7.x86_64 (/libgfortran-4.8.5-44.el7.x86_64)
               libgfortran = 4.8.2-16.el7
               libgfortran = 4.8.5-44.el7
           Available: libgfortran-4.8.5-36.el7_6.2.x86_64 (hrmw)
               libgfortran = 4.8.5-36.el7_6.2
               libgfortran = 4.8.2-16.el7_6
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

???????????????????????????????????????

?问题分析与解决

?一. 缺少依赖包报错:

Error: Package: gpsbabel-1.5.0-2.el7.x86_64 (/gpsbabel-1.5.0-2.el7.x86_64)
           Requires: libQtCore.so.4()(64bit)

这个报错就是典型的缺少依赖包,那如何查找依赖包呢?

?1.找到依赖所在的包

运用 yum来找到依赖所在的包

yum provides 
yum provides libQtCore.so.4
yum provides libQtCore.so.4
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.nju.edu.cn
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.nju.edu.cn
1:qt-4.8.7-8.el7.i686 : Qt toolkit
源    :base
匹配来源:
提供    :libQtCore.so.4



1:qt-4.8.7-9.el7_9.i686 : Qt toolkit
源    :updates
匹配来源:
提供    :libQtCore.so.4



1:qt-4.8.7-9.el7_9.i686 : Qt toolkit
源    :@updates
匹配来源:
提供    :libQtCore.so.4

现在我们找到libQtCore.so.4的包在 1:qt-4.8.7-9.el7_9.i686 下面
我们现在又可以运用命令来下载这个包。

?2.下载所需的依赖包

我运用yumdownloader --resolve --destdir 来下载

yumdownloader --resolve --destdir=地址 依赖包名
yumdownloader --resolve --destdir=/root/pgis 1:qt-4.8.7-9.el7_9.i686
[root@hrmw-web-api ~]# yumdownloader --resolve --destdir=/root/pgis 1:qt-4.8.7-9.el7_9.i686
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nju.edu.cn
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.nju.edu.cn
base                                                                              | 3.6 kB  00:00:00     
extras                                                                            | 2.9 kB  00:00:00     
hrmw                                                                              | 2.9 kB  00:00:00     
pgdg-common/7/x86_64/signature                                                    |  198 B  00:00:00     
pgdg-common/7/x86_64/signature                                                    | 2.9 kB  00:00:00 !!! 
pgdg10/7/x86_64/signature                                                         |  198 B  00:00:00     
pgdg10/7/x86_64/signature                                                         | 3.6 kB  00:00:00 !!! 
pgdg11/7/x86_64/signature                                                         |  198 B  00:00:00     
pgdg11/7/x86_64/signature                                                         | 3.6 kB  00:00:00 !!! 
pgdg12/7/x86_64/signature                                                         |  198 B  00:00:00     
pgdg12/7/x86_64/signature                                                         | 3.6 kB  00:00:00 !!! 
pgdg13/7/x86_64/signature                                                         |  198 B  00:00:00     
pgdg13/7/x86_64/signature                                                         | 3.6 kB  00:00:00 !!! 
pgdg14/7/x86_64/signature                                                         |  198 B  00:00:00     
pgdg14/7/x86_64/signature                                                         | 3.6 kB  00:00:00 !!! 
pgdg96/7/x86_64/signature                                                         |  198 B  00:00:00     
pgdg96/7/x86_64/signature                                                         | 3.6 kB  00:00:00 !!! 
updates                                                                           | 2.9 kB  00:00:00     
(1/2): updates/7/x86_64/primary_db                                                |  14 MB  00:00:01     
(2/2): pgdg-common/7/x86_64/primary_db                                            | 161 kB  00:00:02     
--> 正在检查事务
---> 软件包 qt.i686.1.4.8.7-9.el7_9 将被 已重新安装
--> 解决依赖关系完成
qt-4.8.7-9.el7_9.i686.rpm                                                         | 4.7 MB  00:00:12

然后把他考上去就行了,再看看少啥包?
????????????????????????

?我又遇到问题

但是这里问题,我需要装机的Linux是x86的,但是我下载的是i686版本的,这是以为我下载依赖包的机器是i686的,所以我们这需要改一下,把包名改一下,重新执行一下。

yumdownloader --resolve --destdir=/root/pgis 1:qt-4.8.7-9.el7_9.x86_64
root@hrmw-web-api ~]# yumdownloader --resolve --destdir=/root/pgis 1:qt-4.8.7-9.el7_9.x86_64
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.nju.edu.cn
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.nju.edu.cn
--> 正在检查事务
---> 软件包 qt.x86_64.1.4.8.7-9.el7_9 将被 已重新安装
--> 解决依赖关系完成
qt-4.8.7-9.el7_9.x86_64.rpm                                                       | 4.6 MB  00:00:01     

那这个问题就解决了,我们来看下一个问题:
???????????????????????????

?二 版本太低导致的

上面解决缺少依赖包的已经解决了,再看看下面这个问题:

Error: Package: boost-filesystem-1.53.0-27.el7.x86_64 (@hrmw)
           Requires: boost-system(x86-64) = 1.53.0-27.el7
           Removing: boost-system-1.53.0-27.el7.x86_64 (@anaconda)
               boost-system(x86-64) = 1.53.0-27.el7
           Updated By: boost-system-1.53.0-28.el7.x86_64 (/boost-system-1.53.0-28.el7.x86_64)
               boost-system(x86-64) = 1.53.0-28.el7
Error: Package: gcc-gfortran-4.8.5-16.el7.x86_64 (@anaconda)
           Requires: libquadmath = 4.8.5-16.el7
           Removing: libquadmath-4.8.5-16.el7.x86_64 (@anaconda)
               libquadmath = 4.8.2-16.el7
               libquadmath = 4.8.5-16.el7
           Updated By: libquadmath-4.8.5-44.el7.x86_64 (/libquadmath-4.8.5-44.el7.x86_64)
               libquadmath = 4.8.2-16.el7
               libquadmath = 4.8.5-44.el7
           Available: libquadmath-4.8.5-36.el7_6.2.x86_64 (hrmw)
               libquadmath = 4.8.5-36.el7_6.2
               libquadmath = 4.8.2-16.el7_6

这个问题,大家看出来问题了吗?

这个毛病是因为系统上已经有低版本的依赖,但是又无法更新导致的,那这种问题又如何去解决呢?

?1.检查系统上的版本

在root的用户下 执行
rpm -qa |grep libquadmath

[root@fxyjgxsql postgis32]# rpm -qa |grep libquadmath
libquadmath-4.8.5-16.el7.x86_64
libquadmath-devel-4.8.5-16.el7.x86_64

从这里可以看出系统自带的是4.8.5-16.el7版本的,但是我们这边需要的是4.8.5-44.el7版本的。

?2. 删除系统上的版本

利用 rpm -e来卸载程序。

rpm -e libquadmath-4.8.5-16.el7.x86_64

在这里可能会出现删不掉的情况,这里要加上–nodeps参数。

[root@fxyjgxsql postgis32]# rpm -e libquadmath-4.8.5-16.el7.x86_64 --nodeps
[root@fxyjgxsql postgis32]# rpm -qa |grep libquadmath
libquadmath-devel-4.8.5-16.el7.x86_64

到这里这个问题也解决了。

?三 安装包的版本不对

这个问题的报错,由于我忘记保存了,就暂时不上传了,记得注意一下包的结尾就行了,一定是跟你Linux上一致的,要吗都是x86,要吗都是i686,这里的解决方法参考上面2个。

????????????????????????????????

目前我所遇到的问题就是就是以上这些,大家有啥问题可以提出来。
????????????????????????????????

?yum 命令

[root@hrmw-web-api ~]# yum --help
已加载插件:fastestmirror
Usage: yum [options] COMMAND

List of Commands:

check          检查 RPM 数据库问题
check-update   检查是否有可用的软件包更新
clean          删除缓存数据
deplist        列出软件包的依赖关系
distribution-synchronization 已同步软件包到最新可用版本
downgrade      降级软件包
erase          从系统中移除一个或多个软件包
fs             Acts on the filesystem data of the host, mainly for removing docs/lanuages for minimal hosts.
fssnapshot     Creates filesystem snapshots, or lists/deletes current snapshots.
groups         显示或使用、组信息
help           显示用法提示
history        显示或使用事务历史
info           显示关于软件包或组的详细信息
install        向系统中安装一个或多个软件包
list           列出一个或一组软件包
load-transaction 从文件名中加载一个已存事务
makecache      创建元数据缓存
provides       查找提供指定内容的软件包
reinstall      覆盖安装软件包
repo-pkgs      将一个源当作一个软件包组,这样我们就可以一次性安装/移除全部软件包。
repolist       显示已配置的源
search         在软件包详细信息中搜索指定字符串
shell          运行交互式的 yum shell
swap           Simple way to swap packages, instead of using shell
update         更新系统中的一个或多个软件包
update-minimal Works like upgrade, but goes to the 'newest' package match which fixes a problem that affects your system
updateinfo     Acts on repository update information
upgrade        更新软件包同时考虑软件包取代关系
version        显示机器和/或可用的源版本。


Options:
  -h, --help            显示此帮助消息并退出
  -t, --tolerant        忽略错误
  -C, --cacheonly       完全从系统缓存运行,不升级缓存
  -c [config file], --config=[config file]
                        配置文件路径
  -R [minutes], --randomwait=[minutes]
                        命令最长等待时间
  -d [debug level], --debuglevel=[debug level]
                        调试输出级别
  --showduplicates      在 list/search 命令下,显示源里重复的条目
  -e [error level], --errorlevel=[error level]
                        错误输出级别
  --rpmverbosity=[debug level name]
                        RPM 调试输出级别
  -q, --quiet           静默执行
  -v, --verbose         详尽的操作过程
  -y, --assumeyes       回答全部问题为是
  --assumeno            回答全部问题为否
  --version             显示 Yum 版本然后退出
  --installroot=[path]  设置安装根目录
  --enablerepo=[repo]   启用一个或多个软件源(支持通配符)
  --disablerepo=[repo]  禁用一个或多个软件源(支持通配符)
  -x [package], --exclude=[package]
                        采用全名或通配符排除软件包
  --disableexcludes=[repo]
                        禁止从主配置,从源或者从任何位置排除
  --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
  --obsoletes           更新时处理软件包取代关系
  --noplugins           禁用 Yum 插件
  --nogpgcheck          禁用 GPG 签名检查
  --disableplugin=[plugin]
                        禁用指定名称的插件
  --enableplugin=[plugin]
                        启用指定名称的插件
  --skip-broken         忽略存在依赖关系问题的软件包
  --color=COLOR         配置是否使用颜色
  --releasever=RELEASEVER
                        在 yum 配置和 repo 文件里设置 $releasever 的值
  --downloadonly        仅下载而不更新
  --downloaddir=DLDIR   指定一个其他文件夹用于保存软件包
  --setopt=SETOPTS      设置任意配置和源选项
  --bugfix              Include bugfix relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
  --bzs=BZS             Include packages needed to fix the given BZ, in
                        updates
  --cves=CVES           Include packages needed to fix the given CVE, in
                        updates
  --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

  插件选项:

????????????????????????????

?后记

如果本文章有何错误,请您评论中指出,或联系我,我会改正,如果您觉得这篇文章有用,请帮忙一键三连,让更多的人看见,谢谢
作者 yang_z_1 csdn博客地址: https://blog.csdn.net/yang_z_1?type=blog


版权声明:本文为yang_z_1原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。