Ubuntu20 android编译环境踩坑日记 --openssl

ubuntu20 LTS编译 android 踩坑系列 – openssl

ubuntu20 最新的 openssl 版本号是

~$ openssl  version -a
OpenSSL 1.1.1f  31 Mar 2020
built on: Mon Apr 20 11:53:50 2020 UTC
platform: debian-amd64

对于高通平台android Q代码来说太高了,在编译 nonhlos 的时候,签名工具报错.

Traceback (most recent call last):
File “/local/sourceCode/austin_bsp/amss_4250_spf1.0/BOOT.XF.4.1/boot_images/QcomPkg/Tools/sectools/sectools_builder.py”, line 463, in
build(False, os.environ)
File “/local/sourceCode/austin_bsp/amss_4250_spf1.0/BOOT.XF.4.1/boot_images/QcomPkg/Tools/sectools/sectools_builder.py”, line 271, in build
return SectoolsBuilderCore(args).build()
File “/local/sourceCode/austin_bsp/amss_4250_spf1.0/BOOT.XF.4.1/boot_images/QcomPkg/Tools/sectools/sectools/features/isc/builder/sectools_builder_core.py”, line 157, in build
self._execute_sign()
File “/local/sourceCode/austin_bsp/amss_4250_spf1.0/BOOT.XF.4.1/boot_images/QcomPkg/Tools/sectools/sectools/features/isc/builder/sectools_builder_core.py”, line 254, in _execute_sign
raise RuntimeError(“Sectools failed”)
RuntimeError: Sectools failed

把log打印出来显示 openssl 错误:

ERROR: /usr/bin/openssl retcode: 2
Output: C = US, ST = California, CN = SecTools Test User, O = SecTools, L = San Diego
error 20 at 0 depth lookup: unable to get local issuer certificate

我们猜测是 openssl 版本太高导致,以为同样的代码在 ubuntu14.04 下没有问题.ubuntu 14.04 的版本号是:

~$ openssl version -a
OpenSSL 1.0.1f 6 Jan 2014
built on: Mon Apr  7 21:22:23 UTC 2014
platform: debian-amd64

所以我们需要降级 openssl.

#安装 aptitude
sudo apt-get install aptitude
#利用aptitude强大的工具来降级 openssl
sudo aptitude remove openssl
#这里会提示有其他包依赖于 openssl,会给出一些建议来执行你这个操作,选择n,直到看到将openssl降级到1.0.2g版本,选择y
#aptitude 就会自动完成降级

接着往下编译android的kernel时,提示错误

ld.lld: error: undefined symbol: OPENSSL_add_all_algorithms_noconf
'>>> referenced by sign-file.c
'>>> /local/sourceCode/delhi-bsp/out/soong/.temp/sign-file-21876f.o:(main)
ld.lld: error: undefined symbol: ERR_load_crypto_strings
'>>> referenced by sign-file.c
'>>> /local/sourceCode/delhi-bsp/out/soong/.temp/sign-file-21876f.o:(main)
'>>> did you mean: ERR_load_CRYPTO_strings
'>>> defined in: /usr/lib/x86_64-linux-gnu/libcrypto.so
ld.lld: error: undefined symbol: OpenSSL_add_all_digests
'>>> referenced by sign-file.c
'>>> /local/sourceCode/delhi-bsp/out/soong/.temp/sign-file-21876f.o:(main)
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [scripts/Makefile.host:90:scripts/sign-file] 错误 1
make[3]: *** 正在等待未完成的任务…
ld.lld: error: undefined symbol: OPENSSL_add_all_algorithms_noconf
'>>> referenced by extract-cert.c
'>>> /local/sourceCode/delhi-bsp/out/soong/.temp/extract-cert-6eebd7.o:(main)
ld.lld: error: undefined symbol: ERR_load_crypto_strings
'>>> referenced by extract-cert.c
'>>> /local/sourceCode/delhi-bsp/out/soong/.temp/extract-cert-6eebd7.o:(main)
'>>> did you mean: ERR_load_CRYPTO_strings
'>>> defined in: /usr/lib/x86_64-linux-gnu/libcrypto.so
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [scripts/Makefile.host:90:scripts/extract-cert] 错误 1
HOSTLD scripts/genksyms/genksyms
HOSTLD scripts/mod/modpost
CALL /local/sourceCode/delhi-bsp/kernel/msm-4.19/scripts/checksyscalls.sh
make[2]: *** [/local/sourceCode/delhi-bsp/kernel/msm-4.19/Makefile:1189:scripts] 错误 2
make[2]: *** 正在等待未完成的任务…
make[1]: *** [Makefile:146:sub-make] 错误 2
make: *** [Makefile:24:__sub-make] 错误 2

这是因为 /usr/include/openssl 下面的头文件还是 1.1.1 版本的,也需要降级到 1.0.1.

sudo aptitude remove libssl-dev
#指定版本号
sudo aptitude install libssl-dev=1.0.2g-1ubuntu4

如此操作后,就完成了 openssl 的降级.是否对其他模块有影响暂时还未知.反正我们这个系统主要就是为了编译 android 系统.

为了防止后续系统自动升级 openssl,需要禁止它升级

sudo echo "openssl hold" | sudo dpkg --set-selections
sudo echo "libssl-dev hold" | sudo dpkg --set-selections
#查询结果
sudo dpkg --get-selections | grep hold
libssl-dev:amd64				hold
openssl						    hold

猜你喜欢

转载自blog.csdn.net/qq_40211991/article/details/108093111
今日推荐