Skip to content

Conversation

@samrose
Copy link
Collaborator

@samrose samrose commented Dec 9, 2025

Summary: This commit adds mirror fallback support to apt-get install commands in the bootstrap script.

What was the problem?

The script already had apt_update_with_fallback for apt-get update, but apt-get install commands were still using direct calls without fallback. This meant if a package mirror
returned a 404, hash mismatch, or size mismatch error during installation, the build would fail even though another mirror might have the packages.

What changes were made?

  1. Refactored existing code into reusable functions:
    - get_current_mirror() - extracts current mirror from sources.list
    - switch_mirror() - changes the mirror in sources.list
    - get_mirror_list() - returns ordered list of mirrors to try (regional CDN first, then global fallback)
  2. Added apt_install_with_fallback() function:
    - Wraps apt-get install with automatic mirror retry logic
    - Detects 404, "Failed to fetch", hash mismatch, and size mismatch errors
    - Re-runs apt-get update when switching mirrors to refresh package lists
    - Cleans apt cache between retries to force re-download
    - Uses progressive backoff between attempts
    - Non-mirror errors (like dependency issues) fail immediately without retry
  3. Replaced all direct apt-get install calls with apt_install_with_fallback:
    - Boot packages (linux-aws, grub-pc, e2fsprogs)
    - Standard packages (sudo, wget, cloud-init, etc.)
    - Universe packages (openssh-server, git, ufw, etc.)
    - ARM64-specific packages
    - AppArmor packages
    - GRUB packages for ARM64
  4. Added explicit error handling with FATAL: messages and exit 1 on failures.

@samrose samrose requested review from a team as code owners December 9, 2025 19:33
@samrose samrose enabled auto-merge December 9, 2025 19:45
@samrose samrose added this pull request to the merge queue Dec 10, 2025
Merged via the queue into develop with commit 75b8362 Dec 10, 2025
18 checks passed
@samrose samrose deleted the mirror-on-install branch December 10, 2025 18:00
hunleyd added a commit that referenced this pull request Dec 10, 2025
* origin/develop:
  fix: apt install with mirrors (#1972)
  feat: allow etl admin to bypass rls (#1968)
  Feat: add track_functions to supautils allowed calls (#1950)
  feat: exclude nixos-test builds on x86_64-linux from GitHub matrix (#1970)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants