mirror of
git://code.qt.io/qt/qt5.git
synced 2026-09-02 23:47:20 +08:00
Linux: add a distro version check to prevent unintentional updates
Add a helper script to check the reported distro version at /etc/os-release at the start of a provisioning and at the end of it, compare them, and throw an error if there is any difference even at the most minor patch level e.g. Ubuntu 24.04.0 -> 24.04.1. Task-number: QTQAINFRA-7810 Pick-to: 6.12 6.11 6.8 Change-Id: If4f1e997aef40037ee876bc3843ed09a5412615f Reviewed-by: Simo Fält <simo.falt@qt.io>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (C) 2026 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
set -e
|
||||
|
||||
OS_STATE_DIR="/var/lib/qtciid"
|
||||
OS_STATE_FILE="$OS_STATE_DIR/os-version"
|
||||
|
||||
get_os_id() {
|
||||
if [[ -r /etc/os-release ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /etc/os-release
|
||||
# os-release contains ID of the distro (e.g. 'ubuntu')
|
||||
# VERSION e.g. '24.04.1 LTS (Noble Numbat)'
|
||||
if [[ -n "${ID:-}" && -n "${VERSION:-}" ]]; then
|
||||
echo "${ID}:${VERSION}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "unknown:unknown"
|
||||
return 1
|
||||
}
|
||||
|
||||
record_os_version() {
|
||||
local os_id
|
||||
|
||||
os_id="$(get_os_id)"
|
||||
|
||||
if [[ "$os_id" == "unknown:unknown" ]]; then
|
||||
echo "ERROR: Unable to determine OS version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sudo mkdir -p "$OS_STATE_DIR"
|
||||
echo "$os_id" | sudo tee "$OS_STATE_FILE" > /dev/null
|
||||
|
||||
echo "OS version: $os_id"
|
||||
}
|
||||
|
||||
verify_os_version_unchanged() {
|
||||
if [[ ! -f "$OS_STATE_FILE" ]]; then
|
||||
echo "ERROR: OS version state file missing: $OS_STATE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local start_version current_version
|
||||
|
||||
start_version="$(cat "$OS_STATE_FILE")"
|
||||
current_version="$(get_os_id)"
|
||||
|
||||
if [[ "$current_version" == "unknown:unknown" ]]; then
|
||||
echo "ERROR: Unable to determine current OS version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$start_version" != "$current_version" ]]; then
|
||||
echo "ERROR: OS version changed during provisioning!"
|
||||
echo " Start version : $start_version"
|
||||
echo " End version : $current_version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "OS version unchanged ($current_version)"
|
||||
}
|
||||
@@ -7,6 +7,11 @@ set -ex
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/shared/network_test_server_ip.txt
|
||||
source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
echo "Set Network Test Server address to $network_test_server_ip in /etc/hosts"
|
||||
echo "$network_test_server_ip qt-test-server qt-test-server.qt-test-net" | sudo tee -a /etc/hosts
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
source "${BASH_SOURCE%/*}/../common/linux/verify-release-packages.sh"
|
||||
|
||||
|
||||
@@ -8,6 +8,11 @@ set -ex
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/shared/network_test_server_ip.txt
|
||||
source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
echo "Set Network Test Server address to $network_test_server_ip in /etc/hosts"
|
||||
echo "$network_test_server_ip qt-test-server qt-test-server.qt-test-net" | sudo tee -a /etc/hosts
|
||||
|
||||
@@ -9,6 +9,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
@@ -7,6 +7,11 @@ set -ex
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/shared/network_test_server_ip.txt
|
||||
source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
echo "Set Network Test Server address to $network_test_server_ip in /etc/hosts"
|
||||
echo "$network_test_server_ip qt-test-server qt-test-server.qt-test-net" | sudo tee -a /etc/hosts
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
@@ -7,6 +7,11 @@ set -ex
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/shared/network_test_server_ip.txt
|
||||
source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
echo "Set Network Test Server address to $network_test_server_ip in /etc/hosts"
|
||||
echo "$network_test_server_ip qt-test-server qt-test-server.qt-test-net" | sudo tee -a /etc/hosts
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
@@ -9,6 +9,11 @@ BASEDIR=$(dirname "$0")
|
||||
source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
# shellcheck source=../common/unix/check_and_set_proxy.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
echo "Set timezone to UTC."
|
||||
sudo timedatectl set-timezone Etc/UTC
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
@@ -11,6 +11,11 @@ source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/unix/SetEnvVar.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/SetEnvVar.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
echo "Set timezone to UTC."
|
||||
sudo timedatectl set-timezone Etc/UTC
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
@@ -9,6 +9,11 @@ set -ex
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/unix/check_and_set_proxy.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
NTS_IP=10.212.2.216
|
||||
|
||||
|
||||
@@ -2,5 +2,12 @@
|
||||
#Copyright (C) 2023 The Qt Company Ltd
|
||||
#SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
"$BASEDIR/../common/linux/ubuntu-version.sh"
|
||||
|
||||
@@ -9,6 +9,11 @@ set -ex
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/unix/check_and_set_proxy.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
NTS_IP=10.212.2.216
|
||||
|
||||
|
||||
@@ -2,5 +2,12 @@
|
||||
#Copyright (C) 2023 The Qt Company Ltd
|
||||
#SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
"$BASEDIR/../common/linux/ubuntu-version.sh"
|
||||
|
||||
@@ -9,6 +9,11 @@ set -ex
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/unix/check_and_set_proxy.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
NTS_IP=10.212.2.216
|
||||
|
||||
|
||||
@@ -2,5 +2,12 @@
|
||||
#Copyright (C) 2023 The Qt Company Ltd
|
||||
#SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
"$BASEDIR/../common/linux/ubuntu-version.sh"
|
||||
|
||||
@@ -8,6 +8,11 @@ BASEDIR=$(dirname "$0")
|
||||
source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
# shellcheck source=../common/unix/check_and_set_proxy.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
# https://bugzilla.opensuse.org/show_bug.cgi?id=1032027
|
||||
sudo btrfs quota disable /
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
|
||||
set -ex
|
||||
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
@@ -10,6 +10,11 @@ source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/unix/SetEnvVar.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/SetEnvVar.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
# https://bugzilla.opensuse.org/show_bug.cgi?id=1032027
|
||||
sudo btrfs quota disable /
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
@@ -10,6 +10,11 @@ source "$BASEDIR/../common/shared/network_test_server_ip.txt"
|
||||
source "${BASH_SOURCE%/*}/../common/unix/check_and_set_proxy.sh"
|
||||
# shellcheck source=../common/unix/SetEnvVar.sh
|
||||
source "${BASH_SOURCE%/*}/../common/unix/SetEnvVar.sh"
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Get distro version to later check if version has changed at the end of the provisioning
|
||||
record_os_version
|
||||
|
||||
# https://bugzilla.opensuse.org/show_bug.cgi?id=1032027
|
||||
sudo btrfs quota disable /
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
|
||||
set -ex
|
||||
|
||||
BASEDIR=$(dirname "$0")
|
||||
# shellcheck source=../common/linux/distro_version_check.sh
|
||||
source "$BASEDIR/../common/linux/distro_version_check.sh"
|
||||
|
||||
# Check distro version if it has changed
|
||||
verify_os_version_unchanged
|
||||
|
||||
# shellcheck disable=SC2129
|
||||
echo "*********************************************" >> ~/versions.txt
|
||||
echo "***** All installed RPM packages *****" >> ~/versions.txt
|
||||
|
||||
Reference in New Issue
Block a user