Skip to main content

mirror_update_command

Function mirror_update_command 

Source
pub fn mirror_update_command(
    countries: &str,
    count: u16,
) -> Result<String, String>
Expand description

What: Build a shell snippet to refresh pacman mirrors depending on the detected distro.

Inputs:

  • countries: Either “Worldwide” to auto-rank mirrors, or a comma-separated list used by the underlying tool
  • count: Mirror count used by Manjaro fasttrack when countries is “Worldwide”, or top mirrors number for Artix rate-mirrors

Output:

  • Shell command string suitable to run in a terminal

Details:

  • On Manjaro (detected via /etc/os-release), ensures pacman-mirrors exists, then:
    • Worldwide: pacman-mirrors --fasttrack {count}
    • Countries: pacman-mirrors --method rank --country {countries_q}
  • On Artix (detected via /etc/os-release), checks for rate-mirrors and AUR helper (yay/paru), prompts for installation if needed, creates backup of mirrorlist, then runs rate-mirrors with country filtering using –entry-country option (only one country allowed, global option must come before the artix command).
  • On EndeavourOS, ensures eos-rankmirrors is installed, runs it, then runs reflector.
  • On CachyOS, ensures cachyos-rate-mirrors is installed, runs it, then runs reflector.
  • Otherwise, attempts to use reflector to write /etc/pacman.d/mirrorlist; if not found, prints a notice.

§Errors

Returns Err when the configured privilege tool cannot be resolved (see crate::logic::privilege::active_tool).