From 6119bb983725b6ac15574423c2411576569072a4 Mon Sep 17 00:00:00 2001 From: ASHMIT <52139594+ashmitvoid@users.noreply.github.com> Date: Tue, 15 Sep 2026 04:22:41 +0000 Subject: [PATCH] [installation] cachyos: select repositories by CPU ISA Use glibc hwcaps to keep v3 rebuilds on capable CPUs and fall back to the generic CachyOS repository on baseline x86-64. Note: Fixed: CachyOS installs now keep non-v3 CPUs on compatible repositories --- installation/backend/lib/CHANGELOG.md | 3 ++ installation/backend/lib/cachyos.sh | 41 ++++++++++++++++++--------- tests/install-offline.sh | 28 ++++++++++++++++++ 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/installation/backend/lib/CHANGELOG.md b/installation/backend/lib/CHANGELOG.md index f90f53ed9d..1d1cfc6e14 100644 --- a/installation/backend/lib/CHANGELOG.md +++ b/installation/backend/lib/CHANGELOG.md @@ -29,6 +29,9 @@ normal install. ### Fixed +- `cachyos`: **non-v3 CPUs keep compatible repositories after install.** + The target now enables the v3 core/extra rebuilds only when glibc reports + x86-64-v3 support; baseline x86-64 uses the generic `[cachyos]` repository. - `bootloader`: **a CachyOS install autoboots the CachyOS kernel.** `ryoku_limine_autoboot` pointed default_entry at the first kernel the menu listed (stock `linux`), so a fresh CachyOS box booted the Arch kernel; it now prefers the diff --git a/installation/backend/lib/cachyos.sh b/installation/backend/lib/cachyos.sh index 633851aa51..d3e7771441 100755 --- a/installation/backend/lib/cachyos.sh +++ b/installation/backend/lib/cachyos.sh @@ -1,26 +1,29 @@ #!/usr/bin/env bash # shellcheck shell=bash -# Make the installed target a CachyOS system for future updates: add the CachyOS -# x86-64-v3 repositories above [core], allow x86_64_v3 packages, enable [multilib] -# for the 32-bit gaming/driver set (proton-cachyos, lib32-*), and trust the -# CachyOS key from the installed cachyos-keyring (offline, no keyserver). Mirrors -# system/extras/ryoku-pkg-cachyos, run once in the target chroot at install time. +# Make the installed target a CachyOS system for future updates: add CPU-compatible +# CachyOS repositories above [core], enable [multilib] for the 32-bit gaming/driver +# set (proton-cachyos, lib32-*), and trust the CachyOS key from the installed +# cachyos-keyring (offline, no keyserver). # # The install ITSELF pulls every package (including the CachyOS kernel + proton) # from the baked [offline] repo (lib/offline.sh); this step only wires future # `pacman -Syu` to CachyOS so the box stays a CachyOS box. ryoku_cachyos_repo() { - local conf=/mnt/etc/pacman.conf + local conf=/mnt/etc/pacman.conf v3=0 if [[ -n ${RYOKU_DRYRUN:-} ]]; then - log "DRYRUN: allow x86_64_v3, enable [multilib], add [cachyos-v3]/[cachyos-core-v3]/[cachyos-extra-v3]/[cachyos] above [core], populate the cachyos keyring in the target" + log "DRYRUN: select CPU-compatible CachyOS repos, enable [multilib], populate the cachyos keyring in the target" return 0 fi [[ -f $conf ]] || { log 'cachyos: no %s in the target yet; skipping repo config' "$conf"; return 0; } log "cachyos: configuring the CachyOS repositories in the target" - ryoku_cachyos_arch "$conf" + if LC_ALL=C /lib/ld-linux-x86-64.so.2 --help 2>/dev/null | + grep -qF 'x86-64-v3 (supported'; then + v3=1 + ryoku_cachyos_arch "$conf" + fi ryoku_cachyos_multilib "$conf" - ryoku_cachyos_repos "$conf" + ryoku_cachyos_repos "$conf" "$v3" ryoku_cachyos_keyring } @@ -54,12 +57,24 @@ EOF grep -qE '^\[multilib\]' "$conf" || log "cachyos: warning, could not enable [multilib] (lib32 updates will be unavailable)" } -# add the CachyOS v3 repos above [core]: the -v3 rebuilds give the ISA-optimized -# userland, the generic [cachyos] carries the kernels/settings/proton. Include -# the installed cachyos mirrorlists. left out on a conf with no [core] anchor. +# add CPU-compatible CachyOS repos above [core]. Baseline x86-64 gets only +# [cachyos]; v3-capable CPUs keep the optimized core/extra rebuilds. ryoku_cachyos_repos() { - local conf=$1 + local conf=$1 v3=${2:-1} grep -qE '^\[cachyos' "$conf" && { log "cachyos: repositories already present"; return 0; } + if [[ $v3 != 1 ]]; then + if grep -qE '^\[core\]' "$conf"; then + run sed -i "0,/^\[core\]/ s|^\[core\]|[cachyos]\nInclude = /etc/pacman.d/cachyos-mirrorlist\n\n[core]|" "$conf" + else + append_file "$conf" <<'EOF' + +[cachyos] +Include = /etc/pacman.d/cachyos-mirrorlist +EOF + fi + grep -qE '^\[cachyos\]' "$conf" || log 'cachyos: warning, could not add the CachyOS repo to %s' "$conf" + return 0 + fi grep -qE '^\[core\]' "$conf" || { log 'cachyos: no [core] anchor in %s; appending the CachyOS repos' "$conf"; ryoku_cachyos_repos_append "$conf"; return 0; } run sed -i "0,/^\[core\]/ s|^\[core\]|[cachyos-v3]\nInclude = /etc/pacman.d/cachyos-v3-mirrorlist\n\n[cachyos-core-v3]\nInclude = /etc/pacman.d/cachyos-v3-mirrorlist\n\n[cachyos-extra-v3]\nInclude = /etc/pacman.d/cachyos-v3-mirrorlist\n\n[cachyos]\nInclude = /etc/pacman.d/cachyos-mirrorlist\n\n[core]|" "$conf" grep -qE '^\[cachyos-v3\]' "$conf" || log 'cachyos: warning, could not add the CachyOS repos to %s' "$conf" diff --git a/tests/install-offline.sh b/tests/install-offline.sh index d75300ddfc..2d95b28fe8 100755 --- a/tests/install-offline.sh +++ b/tests/install-offline.sh @@ -173,4 +173,32 @@ while IFS=: read -r file lineno _; do fail "unguarded in-chroot call to $helper (a target whose baked desktop set predates it dies here): $file:$lineno" done < <(grep -rnE '^[^#]*run arch-chroot /mnt ryoku-[a-z-]+' "$root/installation/backend/lib/" || true) +# ---- 7. CachyOS update repositories match the CPU ISA ------------------------ +( + run() { "$@"; } + append_file() { cat >>"$1"; } + log() { :; } + # shellcheck source=/dev/null + source "$root/installation/backend/lib/cachyos.sh" + + baseline="$tmp/cachyos-baseline.conf" + printf '[options]\nArchitecture = auto\n\n[core]\nInclude = /etc/pacman.d/mirrorlist\n' >"$baseline" + ryoku_cachyos_repos "$baseline" 0 + headers=$(grep -oE '^\[[a-z0-9_-]+\]' "$baseline" | grep -v '^\[options\]$') + [[ $headers == $'[cachyos]\n[core]' ]] \ + || fail "baseline CachyOS repo order is '$headers'" + ! grep -qF 'x86_64_v3' "$baseline" \ + || fail "baseline CachyOS config enabled x86_64_v3 packages" + + v3="$tmp/cachyos-v3.conf" + printf '[options]\nArchitecture = auto\n\n[core]\nInclude = /etc/pacman.d/mirrorlist\n' >"$v3" + ryoku_cachyos_arch "$v3" + ryoku_cachyos_repos "$v3" 1 + headers=$(grep -oE '^\[[a-z0-9_-]+\]' "$v3" | grep -v '^\[options\]$') + [[ $headers == $'[cachyos-v3]\n[cachyos-core-v3]\n[cachyos-extra-v3]\n[cachyos]\n[core]' ]] \ + || fail "v3 CachyOS repo order is '$headers'" + grep -qE '^Architecture[[:space:]]*=.*x86_64_v3' "$v3" \ + || fail "v3 CachyOS config did not enable x86_64_v3 packages" +) + echo "install-offline: OK"