You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/cross-compile.yml
+82-39Lines changed: 82 additions & 39 deletions
Original file line number
Diff line number
Diff line change
@@ -37,75 +37,118 @@ jobs:
37
37
echo "Runner Ubuntu Codename: ${CODENAME}"
38
38
HOST_ARCH=$(dpkg --print-architecture)
39
39
echo "Runner Host Architecture: ${HOST_ARCH}"
40
+
UBUNTU_SOURCES_FILE="/etc/apt/sources.list.d/ubuntu.sources" # Standard for Ubuntu 22.04+
40
41
41
42
# Replace Azure mirror with official Ubuntu repositories.
42
-
# This helps ensure consistency if the base image uses Azure mirrors.
43
43
echo "Replacing Azure mirrors with official Ubuntu mirrors..."
44
-
sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/g' /etc/apt/sources.list
44
+
if [ -f "${UBUNTU_SOURCES_FILE}" ]; then
45
+
sudo sed -i 's|azure.archive.ubuntu.com|archive.ubuntu.com|g' "${UBUNTU_SOURCES_FILE}"
46
+
sudo sed -i 's|azure.ports.ubuntu.com|ports.ubuntu.com|g' "${UBUNTU_SOURCES_FILE}" # if applicable for .sources
47
+
fi
48
+
if [ -f "/etc/apt/sources.list" ]; then
49
+
sudo sed -i 's|azure.archive.ubuntu.com|archive.ubuntu.com|g' /etc/apt/sources.list
50
+
sudo sed -i 's|azure.ports.ubuntu.com|ports.ubuntu.com|g' /etc/apt/sources.list # if applicable for .list
51
+
fi
45
52
# Also attempt to replace in any existing sources.list.d files.
46
-
sudo find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sudo sed -i 's/azure.archive.ubuntu.com/archive.ubuntu.com/g' {} \; || echo "Sed on sources.list.d files for Azure mirror replacement had issues or no files found, continuing."
47
-
48
-
# Restrict existing Ubuntu sources to host architecture to prevent issues when adding foreign architectures.
49
-
# This ensures that 'apt-get update' after 'dpkg --add-architecture arm64' doesn't try to find arm64 packages
50
-
# from amd64-focused repositories which might lead to 404 errors.
51
-
echo "Restricting existing Ubuntu sources in /etc/apt/sources.list to [arch=${HOST_ARCH}]..."
sudo find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sudo sed -i 's|azure.archive.ubuntu.com|archive.ubuntu.com|g' {} \; || echo "Sed on sources.list.d/*.list for Azure mirror replacement had issues or no files found, continuing."
54
+
sudo find /etc/apt/sources.list.d/ -type f -name "*.list" -exec sudo sed -i 's|azure.ports.ubuntu.com|ports.ubuntu.com|g' {} \; || echo "Sed on sources.list.d/*.list for Azure ports mirror replacement had issues or no files found, continuing."
55
+
56
+
57
+
echo "Configuring APT sources for host architecture (${HOST_ARCH})..."
58
+
if [ -f "${UBUNTU_SOURCES_FILE}" ]; then
59
+
echo "Modifying ${UBUNTU_SOURCES_FILE} to restrict to [arch=${HOST_ARCH}] for main Ubuntu repos..."
echo "--- Main Ubuntu sources file (${UBUNTU_SOURCES_FILE:-/etc/apt/sources.list}) after host arch restriction ---"
107
+
if [ -f "${UBUNTU_SOURCES_FILE}" ]; then sudo cat "${UBUNTU_SOURCES_FILE}"; elif [ -f "/etc/apt/sources.list" ]; then sudo head -n 20 /etc/apt/sources.list; fi
70
108
echo "--- Relevant files in /etc/apt/sources.list.d/ after host arch restriction ---"
71
-
for f_path in $(sudo find /etc/apt/sources.list.d/ -type f -name "*.list" 2>/dev/null || true); do
72
-
if [ -f "$f_path" ]; then
109
+
# List all .sources and .list files for thorough debugging
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME} main restricted universe multiverse" | sudo tee "${ARM64_SOURCES_FILE}"
99
-
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-updates main restricted universe multiverse" | sudo tee -a "${ARM64_SOURCES_FILE}"
100
-
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-security main restricted universe multiverse" | sudo tee -a "${ARM64_SOURCES_FILE}"
101
-
# Optionally, include backports if needed:
102
-
# echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-backports main restricted universe multiverse" | sudo tee -a "${ARM64_SOURCES_FILE}"
103
-
104
-
# Update package lists again to include arm64 sources
131
+
echo "Configuring APT sources for arm64 architecture in ${ARM64_SOURCES_FILE}..."
132
+
sudo rm -f "${ARM64_SOURCES_FILE}" # Remove if exists to ensure clean state
133
+
# Using echo commands to construct the arm64 sources file
134
+
{
135
+
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME} main restricted universe multiverse"
136
+
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-updates main restricted universe multiverse"
137
+
echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-security main restricted universe multiverse"
138
+
# echo "deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports ${CODENAME}-backports main restricted universe multiverse"
139
+
} | sudo tee "${ARM64_SOURCES_FILE}" > /dev/null
140
+
echo "APT sources for arm64 configured."
141
+
echo "--- Content of ${ARM64_SOURCES_FILE} ---"
142
+
sudo cat "${ARM64_SOURCES_FILE}"
143
+
echo "--------------------------------------"
144
+
145
+
echo "Updating package lists to include arm64 sources..."
146
+
# It's important that previous apt update for host_arch succeeded and sources are clean
105
147
sudo apt-get update -y
106
148
107
-
# Install cross-compiler toolchain and arm64 version of libraries
149
+
echo "Installing arm64 cross-compiler and libraries (gcc-aarch64-linux-gnu, g++-aarch64-linux-gnu, libxcb1-dev:arm64)..."
0 commit comments