core: alpine 添加 community repo 时,用原有的源镜像

This commit is contained in:
bin456789 2023-10-27 11:50:06 +08:00
parent 20636f33df
commit ae46a1386f
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
2 changed files with 8 additions and 8 deletions

View File

@ -205,15 +205,15 @@ test_url_real() {
add_community_repo_for_alpine() { add_community_repo_for_alpine() {
# 先检查原来的repo是不是egde # 先检查原来的repo是不是egde
if grep -x 'http.*/edge/main' /etc/apk/repositories; then if grep -q '^http.*/edge/main$' /etc/apk/repositories; then
alpine_ver=edge alpine_ver=edge
else else
alpine_ver=v$(cut -d. -f1,2 </etc/alpine-release) alpine_ver=v$(cut -d. -f1,2 </etc/alpine-release)
fi fi
if ! grep -x "http.*/$alpine_ver/community" /etc/apk/repositories; then if ! grep -q "^http.*/$alpine_ver/community$" /etc/apk/repositories; then
is_in_china && mirror=mirrors.tuna.tsinghua.edu.cn || mirror=dl-cdn.alpinelinux.org mirror=$(grep '^http.*/main$' /etc/apk/repositories | sed 's,/[^/]*/main$,,' | head -1)
echo https://$mirror/alpine/$alpine_ver/community >>/etc/apk/repositories echo $mirror/$alpine_ver/community >>/etc/apk/repositories
fi fi
} }

View File

@ -41,15 +41,15 @@ error_and_exit() {
add_community_repo() { add_community_repo() {
# 先检查原来的repo是不是egde # 先检查原来的repo是不是egde
if grep -x 'http.*/edge/main' /etc/apk/repositories; then if grep -q '^http.*/edge/main$' /etc/apk/repositories; then
alpine_ver=edge alpine_ver=edge
else else
alpine_ver=v$(cut -d. -f1,2 </etc/alpine-release) alpine_ver=v$(cut -d. -f1,2 </etc/alpine-release)
fi fi
if ! grep -x "http.*/$alpine_ver/community" /etc/apk/repositories; then if ! grep -q "^http.*/$alpine_ver/community$" /etc/apk/repositories; then
is_in_china && mirror=mirrors.tuna.tsinghua.edu.cn || mirror=dl-cdn.alpinelinux.org mirror=$(grep '^http.*/main$' /etc/apk/repositories | sed 's,/[^/]*/main$,,' | head -1)
echo https://$mirror/alpine/$alpine_ver/community >>/etc/apk/repositories echo $mirror/$alpine_ver/community >>/etc/apk/repositories
fi fi
} }