From ae40929383265c3790629ab5ffec1bd52f7ae7d2 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 25 Apr 2026 23:16:52 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E6=A3=80=E6=9F=A5=E5=8E=9F=20alpine=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=98=AF=E5=90=A6=E7=94=A8=20latest-stable?= =?UTF-8?q?=20=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 17 ++++++++++------- trans.sh | 19 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/reinstall.sh b/reinstall.sh index d0ba39b..f4c7983 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -531,19 +531,22 @@ file_enhanced() { echo "$full_type" | sed 's/\.$//' } +# trans.sh 有相同方法 add_community_repo_for_alpine() { - local alpine_ver + local ver mirror - # 先检查原来的repo是不是egde - if grep -q '^http.*/edge/main$' /etc/apk/repositories; then - alpine_ver=edge + # 先检查原来的 repo 是不是 edge 或者 latest-stable + if grep -q "^http.*/edge/main$" /etc/apk/repositories; then + ver=edge + elif grep -q "^http.*/latest-stable/main$" /etc/apk/repositories; then + ver=latest-stable else - alpine_ver=v$(cut -d. -f1,2 >/etc/apk/repositories + echo $mirror/$ver/community >>/etc/apk/repositories fi } diff --git a/trans.sh b/trans.sh index b58d91a..b256caa 100644 --- a/trans.sh +++ b/trans.sh @@ -67,17 +67,22 @@ is_run_from_locald() { [[ "$0" = "/etc/local.d/*" ]] } +# reinstall.sh 有相同方法 add_community_repo_for_alpine add_community_repo() { - # 先检查原来的repo是不是egde - if grep -q '^http.*/edge/main$' /etc/apk/repositories; then - alpine_ver=edge + local ver mirror + + # 先检查原来的 repo 是不是 edge 或者 latest-stable + if grep -q "^http.*/edge/main$" /etc/apk/repositories; then + ver=edge + elif grep -q "^http.*/latest-stable/main$" /etc/apk/repositories; then + ver=latest-stable else - alpine_ver=v$(cut -d. -f1,2 >/etc/apk/repositories + if ! grep -q "^http.*/$ver/community$" /etc/apk/repositories; then + mirror=$(grep '^http.*/main$' /etc/apk/repositories | sed 's,/[^/]*/main$,,' | head -1) + echo $mirror/$ver/community >>/etc/apk/repositories fi }