|
|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
# 在容器内配置 apt(amd64 主归档 + arm64 ubuntu-ports)、安装 Tauri 交叉打 deb 所需依赖、Node、Rust。
|
|
|
|
|
set -euxo pipefail
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
MAIN_MIRROR="${UBUNTU_MIRROR:-http://mirrors.aliyun.com/ubuntu}"
|
|
|
|
|
PORTS_MIRROR="${UBUNTU_PORTS_MIRROR:-http://mirrors.aliyun.com/ubuntu-ports}"
|
|
|
|
|
|
|
|
|
|
retry() {
|
|
|
|
|
local max_attempts="$1"
|
|
|
|
|
@ -24,33 +26,24 @@ retry() {
|
|
|
|
|
|
|
|
|
|
dpkg --add-architecture arm64
|
|
|
|
|
|
|
|
|
|
# 强制将默认源限制为 amd64,避免 apt 去 archive/security 拉 arm64 索引(会 404)。
|
|
|
|
|
if [[ -f /etc/apt/sources.list ]]; then
|
|
|
|
|
cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
|
|
|
|
sed -E -i \
|
|
|
|
|
-e 's|^deb[[:space:]]+http://|deb [arch=amd64] http://|g' \
|
|
|
|
|
-e 's|^deb[[:space:]]+https://|deb [arch=amd64] https://|g' \
|
|
|
|
|
/etc/apt/sources.list
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for list_file in /etc/apt/sources.list.d/*.list; do
|
|
|
|
|
[[ -e "$list_file" ]] || continue
|
|
|
|
|
sed -E -i \
|
|
|
|
|
-e 's|^deb[[:space:]]+http://|deb [arch=amd64] http://|g' \
|
|
|
|
|
-e 's|^deb[[:space:]]+https://|deb [arch=amd64] https://|g' \
|
|
|
|
|
"$list_file"
|
|
|
|
|
done
|
|
|
|
|
# 直接重写 amd64 主仓库源,避免网络策略导致 archive.ubuntu.com 不可达。
|
|
|
|
|
cat > /etc/apt/sources.list <<EOF
|
|
|
|
|
deb [arch=amd64] ${MAIN_MIRROR} focal main restricted universe multiverse
|
|
|
|
|
deb [arch=amd64] ${MAIN_MIRROR} focal-updates main restricted universe multiverse
|
|
|
|
|
deb [arch=amd64] ${MAIN_MIRROR} focal-backports main restricted universe multiverse
|
|
|
|
|
deb [arch=amd64] ${MAIN_MIRROR} focal-security main restricted universe multiverse
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# 清理并重建 arm64 ports 源,仅用于 arm64 索引与依赖解析。
|
|
|
|
|
rm -f /etc/apt/sources.list.d/arm64-ports.list
|
|
|
|
|
cat > /etc/apt/sources.list.d/arm64-ports.list <<'EOF'
|
|
|
|
|
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse
|
|
|
|
|
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse
|
|
|
|
|
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-backports main restricted universe multiverse
|
|
|
|
|
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports focal-security main restricted universe multiverse
|
|
|
|
|
cat > /etc/apt/sources.list.d/arm64-ports.list <<EOF
|
|
|
|
|
deb [arch=arm64] ${PORTS_MIRROR} focal main restricted universe multiverse
|
|
|
|
|
deb [arch=arm64] ${PORTS_MIRROR} focal-updates main restricted universe multiverse
|
|
|
|
|
deb [arch=arm64] ${PORTS_MIRROR} focal-backports main restricted universe multiverse
|
|
|
|
|
deb [arch=arm64] ${PORTS_MIRROR} focal-security main restricted universe multiverse
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
apt-get update
|
|
|
|
|
retry 5 apt-get update -o Acquire::Retries=3 -o Acquire::http::Timeout=30
|
|
|
|
|
apt-get install -y --no-install-recommends \
|
|
|
|
|
ca-certificates curl gnupg git ubuntu-keyring python3
|
|
|
|
|
|
|
|
|
|
|