From 742dcdc02262ff337dae3872da1d5051cf033b7b Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Tue, 31 Dec 2024 00:07:17 +0200 Subject: [PATCH] Add proper bootstrapping for other repos in CI/CD --- .github/build/bootstrap.bash | 52 +++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/.github/build/bootstrap.bash b/.github/build/bootstrap.bash index f06ef56ff..2868e731d 100755 --- a/.github/build/bootstrap.bash +++ b/.github/build/bootstrap.bash @@ -4,8 +4,52 @@ # Copyright Ilia Ross # Bootstrap the build process -# Source general build functions -source "./functions.bash" || exit 1 +# Bootstrap URL +BUILD_BOOTSTRAP_URL="https://raw.githubusercontent.com/webmin/webmin/master/.github/build" -# Source build variables -source ./environment.bash || exit 1 +# Bootstrap scripts +BOOTSTRAP_SCRIPTS=( + "environment.bash" + "functions.bash" + "build-deb-module.bash" + "build-deb-package.bash" + "build-rpm-module.bash" + "build-rpm-package.bash" +) + +bootstrap() { + local base_url="$BUILD_BOOTSTRAP_URL/" + local script_dir + script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + download_script() { + local script_url="$1" + local script_path="$2" + for downloader in "curl -fsSL" "wget -qO-"; do + if command -v "${downloader%% *}" >/dev/null 2>&1; then + if eval "$downloader \"$script_url\" > \"$script_path\""; then + chmod +x "$script_path" + return 0 + fi + fi + done + return 1 + } + for script in "${BOOTSTRAP_SCRIPTS[@]}"; do + local script_path="$script_dir/$script" + if [ ! -f "$script_path" ]; then + if ! download_script "${base_url}${script}" "$script_path"; then + echo "Error: Failed to download $script. Cannot continue." + exit 1 + fi + fi + done + + # Source general build functions + source "$script_dir/functions.bash" || exit 1 + + # Source build variables + source "$script_dir/environment.bash" || exit 1 +} + +# Bootstrap build environment +bootstrap || exit 1