core: alpine 添加 community repo 时,用原有的源镜像
This commit is contained in:
parent
20636f33df
commit
ae46a1386f
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
trans.sh
8
trans.sh
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user