Files
PX4-Autopilot/Tools/ci/use_aws_apt_mirror.sh
Jukka Laitinen 839b7a470f fix(CI): Prerequisites for nuttx update (#27509)
* src/drivers/cdcacm_autostart: Include posix.h for px4_close

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* platforms/nuttx/CMakeLists.txt: Fix linking of nuttx libaries for memalign

This fixes memalign not found in linking step for some boards

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* Add "flock" to macos.sh setup script

"flock" is not standard on macOS, and a dependency was missing from the
macOS setup path.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* Fix clang-tidy errors in Bitset.hpp and in src/lib/matrix

Fix the "bugprone-dynamic-static-initializers" linter errors.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* systemlib/hardfault_log: Fix clang-diagnostics error

Fix for
"[error] clang-diagnostic-error [error]
 use of undeclared identifier XCPTCONTEXT_REGS".

XCPTCONTEXT_REGS is defined in nuttx irq.h, so include that.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* uORB: Fix clang-tidy error "bugprone-dynamic-static-initializers"

Fix the clang-tidy error appearing on uORBManager _Instance variable by
adding a getter for the reference to the _Instance and using that instead.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

* CI: Add default ubuntu mirrors as fallback

In case of specified aws mirror doesn't have the package idicated by the
metadata, a the default ubuntu mirror as a backup.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>

---------

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-06-02 11:27:50 -06:00

76 lines
3.0 KiB
Bash
Executable File

#!/bin/sh
# Rewrite the container's apt sources to point at the AWS regional Ubuntu
# mirror that is local to the runs-on instance.
#
# The default archive.ubuntu.com round-robin sometimes serves out-of-sync
# index files mid-sync, breaking apt-get update with errors like:
# File has unexpected size (25378 != 25381). Mirror sync in progress?
# The Canonical-operated EC2 mirrors are region-local and sync aggressively,
# eliminating that failure mode.
#
# This script is a no-op outside runs-on, so it is safe to call from any CI
# job (forks, self-hosted runners, local docker runs, etc.) without changing
# behavior there.
#
# Usage (from a workflow step running inside the container):
# ./Tools/ci/use_aws_apt_mirror.sh
set -e
if [ -z "$RUNS_ON_AWS_REGION" ]; then
echo "use_aws_apt_mirror: not running on runs-on (RUNS_ON_AWS_REGION unset), skipping"
exit 0
fi
MIRROR="http://${RUNS_ON_AWS_REGION}.ec2.archive.ubuntu.com/ubuntu"
echo "use_aws_apt_mirror: rewriting apt sources to ${MIRROR}"
# Noble (24.04+) uses the deb822 format at /etc/apt/sources.list.d/ubuntu.sources
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
sed -i \
-e "s|http://archive.ubuntu.com/ubuntu|${MIRROR}|g" \
-e "s|http://security.ubuntu.com/ubuntu|${MIRROR}|g" \
/etc/apt/sources.list.d/ubuntu.sources
fi
# Jammy (22.04) and earlier use the legacy /etc/apt/sources.list
if [ -f /etc/apt/sources.list ]; then
sed -i \
-e "s|http://archive.ubuntu.com/ubuntu|${MIRROR}|g" \
-e "s|http://security.ubuntu.com/ubuntu|${MIRROR}|g" \
/etc/apt/sources.list
fi
# Add standard Ubuntu mirrors as fallback entries so apt can still resolve
# packages if regional mirror metadata lags briefly for specific revisions.
if [ -r /etc/os-release ]; then
# shellcheck disable=SC1091
. /etc/os-release
fi
CODENAME="${VERSION_CODENAME:-}"
if [ -z "${CODENAME}" ]; then
echo "use_aws_apt_mirror: unable to determine distro codename, skipping fallback source generation"
else
# Prefer the same mirror family the image already uses.
# This avoids keeping a hardcoded architecture map here.
if grep -Rqs "ubuntu-ports" /etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null; then
FALLBACK_MAIN="http://ports.ubuntu.com/ubuntu-ports"
FALLBACK_SECURITY="http://ports.ubuntu.com/ubuntu-ports"
else
FALLBACK_MAIN="http://archive.ubuntu.com/ubuntu"
FALLBACK_SECURITY="http://security.ubuntu.com/ubuntu"
fi
FALLBACK_FILE="/etc/apt/sources.list.d/px4-ubuntu-fallback.list"
cat <<EOF > "${FALLBACK_FILE}"
# Generated by Tools/ci/use_aws_apt_mirror.sh
deb ${FALLBACK_MAIN} ${CODENAME} main restricted universe multiverse
deb ${FALLBACK_MAIN} ${CODENAME}-updates main restricted universe multiverse
deb ${FALLBACK_MAIN} ${CODENAME}-backports main restricted universe multiverse
deb ${FALLBACK_SECURITY} ${CODENAME}-security main restricted universe multiverse
EOF
echo "use_aws_apt_mirror: wrote fallback sources to ${FALLBACK_FILE}"
fi