chore: add error handling and cc-opt injection to build scripts
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set -Eeuo pipefail
|
||||
|
||||
MODULE_NAME="${MODULE_NAME:-ngx_http_monitoring_module}"
|
||||
DEB_PACKAGE_NAME="${DEB_PACKAGE_NAME:-libnginx-mod-http-monitoring}"
|
||||
@@ -18,6 +18,22 @@ GITHUB_SHA="${GITHUB_SHA:-unknown}"
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
on_error() {
|
||||
local status="$?"
|
||||
local line="${BASH_LINENO[0]:-unknown}"
|
||||
|
||||
echo "::error::distro release build failed at line ${line} with exit code ${status}" >&2
|
||||
|
||||
if [[ -n "${WORK_ROOT:-}" && -d "$WORK_ROOT" ]]; then
|
||||
find "$WORK_ROOT" -path '*/objs/autoconf.err' -type f -print -exec sed -n '1,160p' {} \; >&2 || true
|
||||
find "$WORK_ROOT" -path '*/objs/*.log' -type f -print -exec sed -n '1,160p' {} \; >&2 || true
|
||||
fi
|
||||
|
||||
exit "$status"
|
||||
}
|
||||
|
||||
trap on_error ERR
|
||||
|
||||
slugify() {
|
||||
tr '[:upper:]' '[:lower:]' \
|
||||
| sed -E 's/[^a-z0-9.+~]+/./g; s/^[.]+//; s/[.]+$//'
|
||||
@@ -255,9 +271,7 @@ apt-get build-dep -y --no-install-recommends "${source_package}=${source_version
|
||||
|| apt-get build-dep -y --no-install-recommends "$source_package"
|
||||
|
||||
nginx_build_info="$build_root/nginx-build-info.json"
|
||||
python3 /work/scripts/nginx-build-info.py --nginx-src "$nginx_src" --json > "$nginx_build_info"
|
||||
modules_path="$(python3 /work/scripts/nginx-build-info.py --modules-path)"
|
||||
configure_line="$(python3 /work/scripts/nginx-build-info.py --nginx-src "$nginx_src" --configure-line)"
|
||||
|
||||
case "$modules_path" in
|
||||
/*) ;;
|
||||
@@ -269,9 +283,17 @@ deb_revision_slug="$(printf '%s%s.nginx%s' "$distro_id" "$distro_version" "$sour
|
||||
deb_version="${NEXT_VERSION}-1+${deb_revision_slug}"
|
||||
build_metadata="$(printf '%s.%s.%s' "$distro_slug" "$deb_arch" "$source_version_slug" | slugify)"
|
||||
module_cflags="-DNGX_HTTP_MONITORING_MODULE_VERSION=\\\"${NEXT_VERSION}\\\" -DNGX_HTTP_MONITORING_BUILD_METADATA=\\\"${build_metadata}\\\""
|
||||
python3 /work/scripts/nginx-build-info.py \
|
||||
--nginx-src "$nginx_src" \
|
||||
--extra-cc-opt "$module_cflags" \
|
||||
--json > "$nginx_build_info"
|
||||
configure_line="$(python3 /work/scripts/nginx-build-info.py \
|
||||
--nginx-src "$nginx_src" \
|
||||
--extra-cc-opt "$module_cflags" \
|
||||
--configure-line)"
|
||||
|
||||
cd "$nginx_src"
|
||||
eval "./configure ${configure_line} --with-cc-opt=\"${module_cflags}\" --add-dynamic-module=/work"
|
||||
eval "./configure ${configure_line} --add-dynamic-module=/work"
|
||||
|
||||
build_jobs="$(nproc)"
|
||||
if [[ "$TARGET_ARCH" != "linux-x86_64" && "$build_jobs" -gt 2 ]]; then
|
||||
|
||||
Reference in New Issue
Block a user