mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-07 07:19:22 +00:00
Fix: fall back to Ubuntu mirrors after the first apt failure
Co-Authored-By: Codex <267193182+codex@users.noreply.github.com>
This commit is contained in:
2 files changed
+16
-10
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
name: Install apt packages
|
name: Install apt packages
|
||||||
description: >
|
description: >
|
||||||
Installs apt packages using Ubuntu mirrors and bounded download retries. Caches downloaded packages as an optimization; apt resolves dependencies on every run.
|
Installs apt packages with bounded download retries and Ubuntu mirror fallback. Caches downloaded packages as an optimization; apt resolves dependencies on every run.
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
packages:
|
packages:
|
||||||
|
|||||||
@@ -19,16 +19,18 @@ read -r -a requested_packages <<< "$PACKAGES"
|
|||||||
mkdir -p "$CACHE_DIR"
|
mkdir -p "$CACHE_DIR"
|
||||||
touch "$CACHE_DIR/.keep"
|
touch "$CACHE_DIR/.keep"
|
||||||
|
|
||||||
# Hosted runners use a mirror list; job containers can point directly at Azure.
|
use_ubuntu_mirrors() {
|
||||||
# Handle both layouts, leaving other repositories and signature checks intact.
|
# Hosted runners use a mirror list; job containers can point directly at Azure.
|
||||||
if [ -f /etc/apt/apt-mirrors.txt ]; then
|
# Handle both layouts, leaving other repositories and signature checks intact.
|
||||||
"${SUDO[@]}" sed -i '\|azure\.archive\.ubuntu\.com|d' /etc/apt/apt-mirrors.txt
|
if [ -f /etc/apt/apt-mirrors.txt ]; then
|
||||||
fi
|
"${SUDO[@]}" sed -i '\|azure\.archive\.ubuntu\.com|d' /etc/apt/apt-mirrors.txt
|
||||||
for source in /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources; do
|
|
||||||
if [ -f "$source" ]; then
|
|
||||||
"${SUDO[@]}" sed -i 's|azure\.archive\.ubuntu\.com|archive.ubuntu.com|g' "$source"
|
|
||||||
fi
|
fi
|
||||||
done
|
for source in /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources; do
|
||||||
|
if [ -f "$source" ]; then
|
||||||
|
"${SUDO[@]}" sed -i 's|azure\.archive\.ubuntu\.com|archive.ubuntu.com|g' "$source"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
for attempt in $(seq 1 "$ATTEMPTS"); do
|
for attempt in $(seq 1 "$ATTEMPTS"); do
|
||||||
echo "::group::apt download attempt ${attempt}/${ATTEMPTS}"
|
echo "::group::apt download attempt ${attempt}/${ATTEMPTS}"
|
||||||
@@ -43,6 +45,10 @@ for attempt in $(seq 1 "$ATTEMPTS"); do
|
|||||||
fi
|
fi
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
echo "::warning::apt download attempt ${attempt}/${ATTEMPTS} failed or exceeded ${ATTEMPT_TIMEOUT}s"
|
echo "::warning::apt download attempt ${attempt}/${ATTEMPTS} failed or exceeded ${ATTEMPT_TIMEOUT}s"
|
||||||
|
if [ "$attempt" -eq 1 ] && [ "$ATTEMPTS" -gt 1 ]; then
|
||||||
|
echo "Switching from Azure to Ubuntu archive mirrors for remaining attempts"
|
||||||
|
use_ubuntu_mirrors
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "::error::apt download failed after ${ATTEMPTS} attempts"
|
echo "::error::apt download failed after ${ATTEMPTS} attempts"
|
||||||
|
|||||||
Reference in new issue
Block a user