From f454850c6cf01ac238a6bb3f124982002265b3b5 Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Thu, 19 Sep 2024 13:12:32 +0800 Subject: [PATCH] llvm-apt: fetch codenames from upstream, add focal back (fix tuna/issues#2026) Signed-off-by: Harry Chen --- llvm-apt.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/llvm-apt.sh b/llvm-apt.sh index b0530f4..8d30e75 100755 --- a/llvm-apt.sh +++ b/llvm-apt.sh @@ -10,9 +10,22 @@ BASE_URL=${TUNASYNC_UPSTREAM_URL:-"https://apt.llvm.org"} export REPO_SIZE_FILE=/tmp/reposize.$RANDOM -for os in "jammy" "noble" "bullseye" "bookworm"; do - prefix=llvm-toolchain-$os - "$apt_sync" --delete "$BASE_URL/$os" $prefix,$prefix-9,$prefix-10,$prefix-11,$prefix-12,$prefix-13,$prefix-14,$prefix-15,$prefix-16,$prefix-17,$prefix-18,$prefix-19 main amd64,arm64 "$BASE_PATH/$os" +function get_codenames() { + local os=$1 + local dist_meta_url="${BASE_URL}/${os}/conf/distributions" + local codenames=$(curl -s $dist_meta_url 2>/dev/null | grep -oP '^Codename: \K.*' | tr '\n' ',' | sed 's/,$//') + if [ -z "$codenames" ]; then + echo "Unable to fetch codename from $dist_meta_url, using default" >&2 + prefix=llvm-toolchain-$os + codenames="$prefix,$prefix-18,$prefix-19" + fi + echo "Codenames for $os: $codenames" >&2 + echo $codenames +} + +for os in "focal" "jammy" "noble" "bullseye" "bookworm"; do + codenames=$(get_codenames $os) + "$apt_sync" --delete "$BASE_URL/$os" "$codenames" "$BASE_PATH/$os" done echo "APT finished"