mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2026-10-25 22:30:05 -05:00
- management_ip() returned non-zero when no lease was active, which made wait_for_management_ip exit before its retry loop. It now always returns 0, filters on the ipv4 protocol column, and parses lease rows with bash instead of per-line awk subprocesses. - wait_for_cloud_init() treated exit 2 as 'disabled'; cloud-init returns 2 for recoverable errors and 0 when disabled, so a failed package install was silently accepted. Only 0 is accepted now, and the long status is printed on failure. - check-package now waits for cloud-init through the shared wait_for_guest_ready helper, asserts the guest OS, and reports the missing-package error instead of exiting silently under pipefail. - Resolve the guest OS and the expected os-release string once in lib/common.sh; configure.sh and check-package share the assertion. - Delete the unused package-list helper and warn when bpftool is missing after the best-effort extras install. - build_rust.sh stops when prerequisite installation fails, matching build_pkg_debian.sh. - Add a sync pointer above the harness UISP config block.
106 lines
3.8 KiB
Bash
Executable File
106 lines
3.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Shared build-prerequisite handling for the LibreQoS build scripts.
|
|
#
|
|
# build_rust.sh and build_dpkg.sh are the source of truth for the build and
|
|
# package flows. This helper centralizes the per-distribution package list so
|
|
# the Ubuntu and Debian paths cannot drift apart.
|
|
|
|
# Build packages shared by every supported distribution.
|
|
LQOS_COMMON_BUILD_PACKAGES=(
|
|
python3-pip python3-venv clang gcc gcc-multilib llvm libelf-dev git nano
|
|
curl screen pkg-config make libbpf-dev libssl-dev
|
|
)
|
|
|
|
# Prints the distribution id used to select build packages.
|
|
# LQOS_DISTRO overrides /etc/os-release, and ID_LIKE covers derivatives such as
|
|
# Linux Mint and Pop!_OS.
|
|
lqos_detect_distro() {
|
|
local id id_like
|
|
if [ -n "${LQOS_DISTRO:-}" ]; then
|
|
printf '%s\n' "${LQOS_DISTRO,,}"
|
|
return 0
|
|
fi
|
|
if [ -r /etc/os-release ]; then
|
|
id=$(awk -F= '$1 == "ID" { gsub(/"/, "", $2); print $2 }' /etc/os-release)
|
|
case "$id" in
|
|
ubuntu|debian)
|
|
printf '%s\n' "$id"
|
|
return 0
|
|
;;
|
|
esac
|
|
id_like=$(awk -F= '$1 == "ID_LIKE" { gsub(/"/, "", $2); print $2 }' /etc/os-release)
|
|
case " $id_like " in
|
|
*" ubuntu "*)
|
|
printf 'ubuntu\n'
|
|
return 0
|
|
;;
|
|
*" debian "*)
|
|
printf 'debian\n'
|
|
return 0
|
|
;;
|
|
esac
|
|
if [ -n "$id" ]; then
|
|
printf '%s\n' "${id,,}"
|
|
return 0
|
|
fi
|
|
fi
|
|
printf 'unknown\n'
|
|
}
|
|
|
|
# Prints the distribution-specific build packages.
|
|
# Returns non-zero for distributions without a known package set.
|
|
lqos_distro_build_extras() {
|
|
case "$1" in
|
|
ubuntu)
|
|
# linux-tools-common and linux-tools-<kernel> provide bpftool and
|
|
# perf on Ubuntu.
|
|
printf '%s\n' linux-tools-common "linux-tools-$(uname -r)"
|
|
;;
|
|
debian)
|
|
# Debian ships bpftool and perf as standalone packages instead of
|
|
# the Ubuntu linux-tools-* names.
|
|
printf '%s\n' bpftool linux-perf
|
|
;;
|
|
*)
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
# Installs the build prerequisites for the current or overridden distribution.
|
|
# Side effects: refreshes apt package lists, installs packages, and prepends
|
|
# /usr/sbin to PATH so the build can find bpftool on Debian.
|
|
lqos_install_build_prerequisites() {
|
|
local distro extras
|
|
distro=$(lqos_detect_distro)
|
|
|
|
# Debian installs bpftool in /usr/sbin, which is not on the default
|
|
# non-root PATH there, and lqos_sys invokes bpftool by name during the
|
|
# build.
|
|
export PATH="/usr/sbin:$PATH"
|
|
|
|
if ! extras=$(lqos_distro_build_extras "$distro"); then
|
|
echo "Unsupported distribution '$distro' for automatic prerequisite install."
|
|
echo "Install these packages with your distribution's package manager:"
|
|
printf '%s\n' "${LQOS_COMMON_BUILD_PACKAGES[@]}" | sed 's/^/ /'
|
|
echo "Also install bpftool (required to build lqos_sys) and, optionally, perf."
|
|
return 1
|
|
fi
|
|
|
|
echo "Installing LibreQoS build prerequisites for $distro"
|
|
sudo apt-get update || echo "Warning: apt-get update failed; continuing with cached package lists"
|
|
sudo apt-get install -y "${LQOS_COMMON_BUILD_PACKAGES[@]}" || return 1
|
|
|
|
# Kernel tools packages track the running kernel and can be unavailable on
|
|
# custom or HWE kernels. Keep them best-effort so their absence cannot
|
|
# abort the common install.
|
|
# shellcheck disable=SC2086
|
|
if ! sudo apt-get install -y $extras; then
|
|
echo "Warning: failed to install: $extras"
|
|
echo "Install the distribution equivalents of bpftool (required by lqos_sys) and perf manually if the build fails."
|
|
fi
|
|
if ! command -v bpftool >/dev/null 2>&1; then
|
|
echo "Warning: bpftool was not found; lqos_sys cannot build without it."
|
|
fi
|
|
}
|