cppunit-devel 依赖缺失解决方案
# 背景说明
在 Rocky Linux 8.10
上用 Bigtop 编译 Zookeeper rpm 包时,经常因为系统找不到 cppunit-devel,导致
rpmbuild 阶段直接中断。
# 0. 全部日志
Provides: bigtop-select = 3.2.0-1.el8
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: /usr/bin/ambari-python-wrap /usr/bin/python2
Checking for unpackaged file(s): /usr/lib/rpm/check-files /opt/modules/bigtop/build/bigtop-select/rpm/BUILDROOT/bigtop-select-3.2.0-1.el8.x86_64
Wrote: /opt/modules/bigtop/build/bigtop-select/rpm/RPMS/noarch/bigtop-select-3.2.0-1.el8.noarch.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.lE4Uio
+ umask 022
+ cd /opt/modules/bigtop/build/bigtop-select/rpm//BUILD
+ cd bigtop-select-3.2.0
+ rm -rf /opt/modules/bigtop/build/bigtop-select/rpm/BUILDROOT/bigtop-select-3.2.0-1.el8.x86_64
+ exit 0
Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.HdTvOr
+ umask 022
+ cd /opt/modules/bigtop/build/bigtop-select/rpm//BUILD
+ rm -rf bigtop-select-3.2.0
+ exit 0
Download https://mirrors.huaweicloud.com/apache//zookeeper/zookeeper-3.5.9/apache-zookeeper-3.5.9.tar.gz
> Task :zookeeper-tar
Copy /opt/modules/bigtop/dl/apache-zookeeper-3.5.9.tar.gz to /opt/modules/bigtop/build/zookeeper/tar/apache-zookeeper-3.5.9.tar.gz
> Task :zookeeper-srpm
Copying common RPM SOURCES from: /opt/modules/bigtop/bigtop-packages/src/common/zookeeper (excluding 3.5.9) to /opt/modules/bigtop/build/zookeeper/rpm/SOURCES
No version-specific directory found at: /opt/modules/bigtop/bigtop-packages/src/common/zookeeper/3.5.9
Wrote: /opt/modules/bigtop/build/zookeeper/rpm/SRPMS/zookeeper_3_2_0-3.5.9-2.el8.src.rpm
> Task :zookeeper-rpm FAILED
error: Failed build dependencies:
cppunit-devel is needed by zookeeper_3_2_0-3.5.9-2.el8.x86_64
Installing /opt/modules/bigtop/output/zookeeper/zookeeper_3_2_0-3.5.9-2.el8.src.rpm
FAILURE: Build failed with an exception.
* Where:
Script '/opt/modules/bigtop/packages.gradle' line: 545
* What went wrong:
Execution failed for task ':zookeeper-rpm'.
> Process 'command 'rpmbuild'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
25 actionable tasks: 25 executed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 1. 报错及常见卡点
编译时报如下错误:
> Task :zookeeper-rpm FAILED
error: Failed build dependencies:
cppunit-devel is needed by zookeeper_3_2_0-3.5.9-2.el8.x86_64
1
2
3
2
3
警告
大部分云服务器默认的 Rocky/CentOS 官方仓库 没有 cppunit-devel 包,dnf/yum 直接安装会提示“没有可用软件包”!
# 2. 关键解决方案——引入阿里云 epel 镜像重点操作
如图所示,通过引入阿里云 EPEL 镜像源,系统才能正常获取并安装 cppunit-devel:
# 2.1 一键配置阿里云 EPEL 源
当你发现 cppunit-devel
装不上,优先考虑更换国内 EPEL 镜像。最常用的是阿里云,操作如下:
# 先安装 epel-release(如果没装过)
dnf install -y epel-release
# 替换为阿里云 EPEL 镜像
sed -i 's|^metalink=|#metalink=|g' /etc/yum.repos.d/epel.repo
sed -i 's|^#baseurl=.*|baseurl=https://mirrors.aliyun.com/epel/$releasever/Everything/$basearch/|' /etc/yum.repos.d/epel.repo
# 更新缓存
dnf makecache
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
提示
以上脚本适用于 Rocky/CentOS 8.x,极大提升 epel 依赖包(如 cppunit-devel)的获取速度和稳定性。
配置 epel 源后,即可直接安装:
dnf install -y cppunit-devel
1
依赖安装成功效果如下:
# 3. 重新编译验证
镜像引入并安装成功后,重新运行:
gradle zookeeper-rpm \
-PparentDir=/usr/bigtop -Dbuildwithdeps=true -PpkgSuffix
1
2
2
编译即可顺利通过,见下图: