fix(tools): install locales and fix re-run issues in Ubuntu setup scripts (#7603)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Peter Feerick
2026-08-11 08:26:35 +10:00
committed by GitHub
co-authored by Claude Opus 5
parent 73652d0a99
commit 81db17e5a7
2 changed files with 66 additions and 12 deletions
+33 -6
View File
@@ -18,13 +18,22 @@ do
fi
done
if ! command -v lsb_release >/dev/null 2>&1; then
echo "ERROR: lsb_release not found, so the Ubuntu version cannot be checked."
echo "Install it with: sudo apt-get install lsb-release"
echo "Terminating the script now."
exit 1
fi
if [[ $(lsb_release -rs) != "22.04" ]]; then
echo "ERROR: Not running on Ubuntu 22.04!"
echo "Terminating the script now."
exit 1
fi
echo "=== Step $((STEP++)): Setting up package repositories ==="
echo "=== Step $((STEP++)): Setting up package repositories. Please provide sudo credentials, when asked ==="
# Refresh in case package lists are stale
sudo apt-get -y update
sudo apt-get -y install --no-install-recommends software-properties-common gpg gpg-agent wget ca-certificates
sudo mkdir -p /etc/apt/keyrings
# Set up Kitware repository for newer cmake
@@ -46,7 +55,7 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
read
fi
echo "=== Step $((STEP++)): Updating Ubuntu package lists. Please provide sudo credentials, when asked ==="
echo "=== Step $((STEP++)): Updating Ubuntu package lists for the newly added repositories ==="
sudo apt-get -y update
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
@@ -63,6 +72,7 @@ sudo apt-get -y install --no-install-recommends \
unzip \
file \
gawk \
m4 \
libsdl2-dev \
python3-dev \
python3-pip \
@@ -76,6 +86,7 @@ sudo apt-get -y install --no-install-recommends \
python-is-python3 \
dfu-util \
nodejs \
locales \
stlink-tools \
openocd \
pv
@@ -91,6 +102,18 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
read
fi
echo "=== Step $((STEP++)): Generating locales used by the custom function sorter ==="
# cfn_sorter.sh sorts with std::locale, which aborts if a locale is missing
sudo locale-gen \
zh_CN.UTF-8 cs_CZ.UTF-8 da_DK.UTF-8 de_DE.UTF-8 es_ES.UTF-8 en_US.UTF-8 \
fi_FI.UTF-8 fr_FR.UTF-8 he_IL.UTF-8 it_IT.UTF-8 ja_JP.UTF-8 ko_KR.UTF-8 \
nl_NL.UTF-8 pl_PL.UTF-8 pt_PT.UTF-8 ru_RU.UTF-8 sv_SE.UTF-8 zh_TW.UTF-8 \
uk_UA.UTF-8
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
fi
echo "=== Step $((STEP++)): Installing Python packages ==="
sudo python3 -m pip install \
asciitree \
@@ -137,6 +160,8 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
fi
echo "=== Step $((STEP++)): Moving GNU Arm Embedded Toolchains to /opt ==="
# Remove first: mv into an existing directory nests instead of replacing
sudo rm -rf /opt/gcc-arm-none-eabi
sudo mv arm-gnu-toolchain-${GCC_ARM_VERSION}-x86_64-arm-none-eabi /opt/gcc-arm-none-eabi
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please press Enter to continue or Ctrl+C to stop."
@@ -144,10 +169,12 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
fi
echo "=== Step $((STEP++)): Adding GNU Arm Embedded Toolchain and Qt to PATH of current user ==="
cat >> ~/.bashrc << EOF
export PATH="/opt/gcc-arm-none-eabi/bin:\$PATH"
export PATH="/opt/qt/${QT_VERSION}/gcc_64/bin:\$PATH"
EOF
# Only append if missing, so re-runs do not duplicate
touch ~/.bashrc
GCC_PATH_LINE="export PATH=\"/opt/gcc-arm-none-eabi/bin:\$PATH\""
QT_PATH_LINE="export PATH=\"/opt/qt/${QT_VERSION}/gcc_64/bin:\$PATH\""
grep -qxF "${GCC_PATH_LINE}" ~/.bashrc || echo "${GCC_PATH_LINE}" >> ~/.bashrc
grep -qxF "${QT_PATH_LINE}" ~/.bashrc || echo "${QT_PATH_LINE}" >> ~/.bashrc
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please press Enter to continue or Ctrl+C to stop."
read
+33 -6
View File
@@ -18,13 +18,22 @@ do
fi
done
if ! command -v lsb_release >/dev/null 2>&1; then
echo "ERROR: lsb_release not found, so the Ubuntu version cannot be checked."
echo "Install it with: sudo apt-get install lsb-release"
echo "Terminating the script now."
exit 1
fi
if [[ $(lsb_release -rs) != "24.04" ]]; then
echo "ERROR: Not running on Ubuntu 24.04!"
echo "Terminating the script now."
exit 1
fi
echo "=== Step $((STEP++)): Setting up package repositories ==="
echo "=== Step $((STEP++)): Setting up package repositories. Please provide sudo credentials, when asked ==="
# Refresh in case package lists are stale
sudo apt-get -y update
sudo apt-get -y install --no-install-recommends software-properties-common gpg gpg-agent wget ca-certificates
sudo mkdir -p /etc/apt/keyrings
# Set up Kitware repository for newer cmake
@@ -42,7 +51,7 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
read
fi
echo "=== Step $((STEP++)): Updating Ubuntu package lists. Please provide sudo credentials, when asked ==="
echo "=== Step $((STEP++)): Updating Ubuntu package lists for the newly added repositories ==="
sudo apt-get -y update
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
@@ -59,6 +68,7 @@ sudo apt-get -y install --no-install-recommends \
unzip \
file \
gawk \
m4 \
libsdl2-dev \
python3-dev \
python3-pip \
@@ -72,6 +82,7 @@ sudo apt-get -y install --no-install-recommends \
python-is-python3 \
dfu-util \
nodejs \
locales \
stlink-tools \
openocd \
pv
@@ -87,6 +98,18 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
read
fi
echo "=== Step $((STEP++)): Generating locales used by the custom function sorter ==="
# cfn_sorter.sh sorts with std::locale, which aborts if a locale is missing
sudo locale-gen \
zh_CN.UTF-8 cs_CZ.UTF-8 da_DK.UTF-8 de_DE.UTF-8 es_ES.UTF-8 en_US.UTF-8 \
fi_FI.UTF-8 fr_FR.UTF-8 he_IL.UTF-8 it_IT.UTF-8 ja_JP.UTF-8 ko_KR.UTF-8 \
nl_NL.UTF-8 pl_PL.UTF-8 pt_PT.UTF-8 ru_RU.UTF-8 sv_SE.UTF-8 zh_TW.UTF-8 \
uk_UA.UTF-8
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please check the output above and press Enter to continue or Ctrl+C to stop."
read
fi
echo "=== Step $((STEP++)): Installing Python packages ==="
# Python 3.12+ enforces PEP 668 (managed environment); --break-system-packages allows pip installs outside a venv
sudo python3 -m pip install --break-system-packages --ignore-installed \
@@ -134,6 +157,8 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
fi
echo "=== Step $((STEP++)): Moving GNU Arm Embedded Toolchains to /opt ==="
# Remove first: mv into an existing directory nests instead of replacing
sudo rm -rf /opt/gcc-arm-none-eabi
sudo mv arm-gnu-toolchain-${GCC_ARM_VERSION}-x86_64-arm-none-eabi /opt/gcc-arm-none-eabi
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please press Enter to continue or Ctrl+C to stop."
@@ -141,10 +166,12 @@ if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
fi
echo "=== Step $((STEP++)): Adding GNU Arm Embedded Toolchain and Qt to PATH of current user ==="
cat >> ~/.bashrc << EOF
export PATH="/opt/gcc-arm-none-eabi/bin:\$PATH"
export PATH="/opt/qt/${QT_VERSION}/gcc_64/bin:\$PATH"
EOF
# Only append if missing, so re-runs do not duplicate
touch ~/.bashrc
GCC_PATH_LINE="export PATH=\"/opt/gcc-arm-none-eabi/bin:\$PATH\""
QT_PATH_LINE="export PATH=\"/opt/qt/${QT_VERSION}/gcc_64/bin:\$PATH\""
grep -qxF "${GCC_PATH_LINE}" ~/.bashrc || echo "${GCC_PATH_LINE}" >> ~/.bashrc
grep -qxF "${QT_PATH_LINE}" ~/.bashrc || echo "${QT_PATH_LINE}" >> ~/.bashrc
if [[ $PAUSEAFTEREACHLINE == "true" ]]; then
echo "Step finished. Please press Enter to continue or Ctrl+C to stop."
read