mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2026-10-06 06:59:08 +08:00
install.sh grew a retry loop, per-command timeouts and a deliberately non-gating apt-get update after this runner pool cost several whole runs: a mirror going silent for two hours, and a Hash Sum mismatch from a third-party repository the project does not even use turning builds red. Those lessons were local to that one file. install_riscv.sh had none of them, and #717 puts it on every pull request's critical path. Under set -e its bare apt-get update was a single point of failure for the whole suite -- the precise case install.sh downgrades to a warning on purpose -- and its two wget calls, each fetching about 500 MB, had no retry and no timeout. Rather than copy the helpers and let them drift again, they move to tx_ci_common.sh and both scripts source it, following the arrangement scripts/tx_windows_common.ps1 already uses on the Windows side. install.sh keeps its behaviour exactly: same APT_OPTIONS, same 120-second TIMEOUT, same three-attempt retry, and the comments explaining each of them travel with the code they explain. Two things are new: - TIMEOUT_LONG, 180 seconds, for a single large download. Sized against the 39 seconds each tarball took on 10 Sep 2026 and deliberately not larger: the install step is capped at ten minutes, and a per-attempt timeout able to swallow that cap would leave the retry loop no turn to take, which is the failure mode the apt comment already records. - fetch(), which verifies a SHA-256 before anything is unpacked. Both digests were taken from the releases API and then checked against the bytes the CDN actually serves. This is not an independent trust root -- expected value and file come from the same host -- but it pins the bytes, so a deleted and re-pushed tag or a replaced asset stops the build instead of being picked up silently. Also verifies qemu-system-riscv32 alongside riscv64. run.sh selects one per architecture, so both are worth failing on here rather than at the first test. Verified locally: retry returns 0 on success and 1 after three attempts; fetch accepts a correct digest and, on a wrong one, fails and removes the partial file; the source line resolves from the repository root, from an absolute path and through a symlink; and both recorded digests match the bytes served for the pinned tag. Assisted-by: Claude Code (Opus 5) <noreply@anthropic.com>
86 lines
4.0 KiB
Bash
Executable File
86 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
##############################################################################
|
|
# Copyright (c) 2024 Microsoft Corporation
|
|
# Copyright (c) 2026 Eclipse ThreadX contributors
|
|
#
|
|
# This program and the accompanying materials are made available under the
|
|
# terms of the MIT License which is available at
|
|
# https://opensource.org/licenses/MIT.
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
##############################################################################
|
|
|
|
#
|
|
# Install necessary softwares for Ubuntu.
|
|
|
|
# Remove large folder to save space
|
|
rm -rf /opt/hostedtoolcache
|
|
|
|
# The network helpers -- retry, TIMEOUT, TIMEOUT_LONG and APT_OPTIONS -- live in
|
|
# tx_ci_common.sh, alongside the comments recording why each of them is shaped
|
|
# the way it is. They were defined here until the RISC-V suite was enabled in
|
|
# CI, which put a second install script on every pull request's critical path
|
|
# with none of them.
|
|
. "$(dirname "$(realpath "$0")")/tx_ci_common.sh"
|
|
|
|
# THE UPDATE IS NOT THE GATE, AND IT MUST NOT BE. apt-get update fails if ANY
|
|
# configured repository serves a bad index, including ones this project does
|
|
# not use. On a GitHub runner the image carries Google's and Microsoft's
|
|
# repositories, and a Hash Sum mismatch from Google's -- their CDN caught
|
|
# mid-publish, index and Release file eight hours apart -- failed this script
|
|
# three attempts running and turned a build red over a browser nobody was
|
|
# installing.
|
|
#
|
|
# The alternative of disabling third-party sources before updating is wrong
|
|
# here: this script also runs on a contributor's own machine, where silently
|
|
# rewriting their apt configuration would be a far worse thing to do than
|
|
# tolerating a stale index.
|
|
#
|
|
# So a failed update WARNS and the install below is the gate. Nothing is
|
|
# weakened by that: apt-get install still fails hard on a package it cannot
|
|
# find, so an archive that is genuinely unreachable still stops the script --
|
|
# one step later, and saying which package it could not get.
|
|
if ! retry sudo "${TIMEOUT[@]}" apt-get "${APT_OPTIONS[@]}" update; then
|
|
echo ""
|
|
echo "install.sh: apt-get update did not fully succeed."
|
|
echo "install.sh: continuing, because a repository this project does not"
|
|
echo "install.sh: use can fail an update. The install below is the real"
|
|
echo "install.sh: gate and fails if any package needed is unavailable."
|
|
echo ""
|
|
fi
|
|
retry sudo "${TIMEOUT[@]}" apt-get "${APT_OPTIONS[@]}" install -y \
|
|
gcc-multilib \
|
|
git \
|
|
g++ \
|
|
python3-pip \
|
|
ninja-build \
|
|
unifdef \
|
|
p7zip-full \
|
|
tofrodos \
|
|
gawk \
|
|
cmake \
|
|
software-properties-common || exit 1
|
|
|
|
retry "${TIMEOUT[@]}" python3 -m pip install --retries 3 --timeout 30 --upgrade pip || exit 1
|
|
# gcovr was pinned to 4.1, released in 2018. That version cannot do what merging
|
|
# the coverage of several build configurations needs: it has no --json and no
|
|
# --add-tracefile, both of which arrived later. The pin is exact rather than
|
|
# floating so the coverage percentage stays comparable between runs -- the
|
|
# denominator is a property of the tool as much as of the tree -- and it is moved
|
|
# by hand, because it lives in a shell script that Dependabot cannot parse.
|
|
#
|
|
# Measured before bumping, on the default_build_coverage tree of test/tx, over
|
|
# the same gcda with the same gcov, varying only the gcovr version: 4.1, 7.0,
|
|
# 8.3 and 8.6 all report lines-valid 3827 across 177 files and branches-valid
|
|
# 1994. The denominator does not move with the tool, so this bump moves no
|
|
# number and any movement in a later run belongs to a later change.
|
|
#
|
|
# The numerator does move, but not because of gcovr: tx_thread_system_resume.c
|
|
# line 529 is executed on some runs of the suite and not others, so the same
|
|
# tree reports 3826 or 3827 covered lines with every test passing either way.
|
|
# That is a property of the suite, not of this pin.
|
|
retry "${TIMEOUT[@]}" pip3 install --retries 3 --timeout 30 gcovr==8.6 || exit 1
|
|
|
|
# Upgrade cmake to the latest version.
|
|
retry "${TIMEOUT[@]}" pip install --retries 3 --timeout 30 --upgrade cmake || exit 1
|