core: 修复 el7 无法安装 epel 里面的软件包

This commit is contained in:
bin456789 2024-07-21 23:57:59 +08:00
parent e6760deed3
commit 6024a8434a
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
3 changed files with 13 additions and 8 deletions

View File

@ -228,7 +228,6 @@ bash reinstall.sh windows \
- Massgrave
- <https://massgrave.dev/genuine-installation-media.html> (Recommended, iso sourced from official channels, updated monthly, includes the latest patches)
- Microsoft
- <https://www.microsoft.com/software-download/windows8>
- <https://www.microsoft.com/software-download/windows10> (Need to open it with a mobile User-Agent)
- <https://www.microsoft.com/software-download/windows11>
- <https://www.microsoft.com/software-download/windowsinsiderpreviewiso> (Preview)

View File

@ -228,7 +228,6 @@ bash reinstall.sh windows \
- Massgrave
- <https://massgrave.dev/genuine-installation-media.html> (推荐iso 来自官方,每月更新,包含最新补丁)
- 微软
- <https://www.microsoft.com/software-download/windows8>
- <https://www.microsoft.com/software-download/windows10> (需用手机 User-Agent 打开)
- <https://www.microsoft.com/software-download/windows11>
- <https://www.microsoft.com/software-download/windowsinsiderpreviewiso> (预览版)

View File

@ -1385,17 +1385,24 @@ install_pkg() {
esac
}
try_find_epel_name() {
epel=$($pkg_mgr repolist --all | awk '{print $1}' | grep -Ei '(epel|epol)$')
get_epel_repo_name() {
# el7 不支持 yum repolist --all要使用 yum repolist all
# el7 yum repolist 第一栏有 /x86_64 后缀,因此要去掉。而 el9 没有
$pkg_mgr repolist all | awk '{print $1}' | awk -F/ '{print $1}' | grep -Ei '(epel|epol)$'
}
get_epel_pkg_name() {
$pkg_mgr list | grep -E '(epel|epol)-release' | awk '{print $1}' | cut -d. -f1 | head -1
}
if is_need_epel; then
if ! try_find_epel_name; then
epel_release="$($pkg_mgr list | grep -E '(epel|epol)-release' | awk '{print $1}' | cut -d. -f1 | head -1)"
$pkg_mgr install -y $epel_release
try_find_epel_name
if ! epel=$(get_epel_repo_name); then
$pkg_mgr install -y "$(get_epel_pkg_name)"
epel=$(get_epel_repo_name)
fi
enable_epel="--enablerepo=$epel"
else
enable_epel=
fi
}