Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-25 23:44:48 +03:00
1 parent 639362fbf5
commit bdd69f0aad
101 files changed
+22691 -531

No files matched your search

+227 -10
View File
@@ -11,6 +11,20 @@ Options:
--jobs N Parallel build jobs
--skip-tests Skip CTest and frontend tests
--no-clean Reuse the configured build directory
--update-url URL Emit an unsigned runtime feed payload for this artifact
--update-channel NAME
Feed channel (default: stable)
--update-feed-id NAME
Feed identifier (default: echoion-runtime)
--update-sequence N
Monotonic feed sequence (default: SOURCE_DATE_EPOCH)
--update-valid-days N
Feed lifetime in days (default: 30)
--official-update-feed-url URL
HTTPS aggregate feed embedded as the official default
--void-source DIR Use an explicit VoidLibrary source tree
--void-teamspeak-source DIR
Use an explicit VoidTeamspeak source tree
--container Build with containers/release.Dockerfile (the default)
--host Explicitly build directly on this host
-h, --help Show this help
@@ -24,6 +38,26 @@ die() {
exit 2
}
canonical_release_version() {
local value=$1
local prerelease identifier
if [[ ! $value =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$ ]]; then
return 1
fi
prerelease=${BASH_REMATCH[5]:-}
while [[ -n $prerelease ]]; do
if [[ $prerelease == *.* ]]; then
identifier=${prerelease%%.*}
prerelease=${prerelease#*.}
else
identifier=$prerelease
prerelease=
fi
[[ ! $identifier =~ ^0[0-9]+$ ]] || return 1
done
return 0
}
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
source_dir=$(cd -- "$script_dir/.." && pwd -P)
version=
@@ -33,6 +67,14 @@ jobs=
run_tests=1
clean_build=1
use_container=1
update_url=
update_channel=stable
update_feed_id=echoion-runtime
update_sequence=
update_valid_days=30
official_update_feed_url=
void_source=
void_teamspeak_source=
while (($#)); do
case $1 in
@@ -64,6 +106,46 @@ while (($#)); do
clean_build=0
shift
;;
--update-url)
(($# >= 2)) || die "--update-url requires a value"
update_url=$2
shift 2
;;
--update-channel)
(($# >= 2)) || die "--update-channel requires a value"
update_channel=$2
shift 2
;;
--update-feed-id)
(($# >= 2)) || die "--update-feed-id requires a value"
update_feed_id=$2
shift 2
;;
--update-sequence)
(($# >= 2)) || die "--update-sequence requires a value"
update_sequence=$2
shift 2
;;
--update-valid-days)
(($# >= 2)) || die "--update-valid-days requires a value"
update_valid_days=$2
shift 2
;;
--official-update-feed-url)
(($# >= 2)) || die "--official-update-feed-url requires a value"
official_update_feed_url=$2
shift 2
;;
--void-source)
(($# >= 2)) || die "--void-source requires a value"
void_source=$2
shift 2
;;
--void-teamspeak-source)
(($# >= 2)) || die "--void-teamspeak-source requires a value"
void_teamspeak_source=$2
shift 2
;;
--container)
use_container=1
shift
@@ -84,12 +166,35 @@ done
[[ $version =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$ ]] ||
die "--version must contain only letters, digits, dot, underscore, or dash"
canonical_release_version "$version" ||
die "--version must be canonical Semantic Versioning 2.0.0"
if [[ -n $jobs && ! $jobs =~ ^[1-9][0-9]*$ ]]; then
die "--jobs must be a positive integer"
fi
[[ $update_channel =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,255}$ ]] ||
die "--update-channel contains unsupported characters"
[[ $update_feed_id =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,255}$ ]] ||
die "--update-feed-id contains unsupported characters"
[[ -z $update_sequence || $update_sequence =~ ^[0-9]+$ ]] ||
die "--update-sequence must be a non-negative integer"
[[ $update_valid_days =~ ^[1-9][0-9]*$ && $update_valid_days -le 365 ]] ||
die "--update-valid-days must be between 1 and 365"
[[ -z $official_update_feed_url ||
$official_update_feed_url == https://* ]] ||
die "--official-update-feed-url must use HTTPS"
build_dir=$(realpath -m -- "$build_dir")
dist_dir=$(realpath -m -- "$dist_dir")
if [[ -n $void_source ]]; then
void_source=$(realpath -e -- "$void_source")
[[ -d $void_source && -f $void_source/CMakeLists.txt ]] ||
die "--void-source must name a VoidLibrary source directory"
fi
if [[ -n $void_teamspeak_source ]]; then
void_teamspeak_source=$(realpath -e -- "$void_teamspeak_source")
[[ -d $void_teamspeak_source && -f $void_teamspeak_source/CMakeLists.txt ]] ||
die "--void-teamspeak-source must name a VoidTeamspeak source directory"
fi
container_path() {
local path=$1
@@ -105,7 +210,18 @@ if ((use_container)); then
container_build_dir=$(container_path "$build_dir")
container_dist_dir=$(container_path "$dist_dir")
image="echoion-release-builder:gcc-16.1.0"
proxy_build_args=()
proxy_run_args=()
for proxy_name in HTTP_PROXY HTTPS_PROXY NO_PROXY http_proxy https_proxy no_proxy; do
if [[ -n ${!proxy_name:-} ]]; then
# Docker treats these predefined build arguments specially: their
# values are inherited without being recorded in the image history.
proxy_build_args+=(--build-arg "$proxy_name")
proxy_run_args+=(--env "$proxy_name")
fi
done
docker build \
"${proxy_build_args[@]}" \
--platform linux/amd64 \
--file "$source_dir/containers/release.Dockerfile" \
--tag "$image" \
@@ -118,6 +234,17 @@ if ((use_container)); then
--env HOME=/tmp/echoion-release-home
--env npm_config_cache=/tmp/echoion-npm-cache
)
container_args+=("${proxy_run_args[@]}")
if [[ -n $void_source ]]; then
container_args+=(
--volume "$void_source:/workspace-deps/VoidLibrary:ro"
)
fi
if [[ -n $void_teamspeak_source ]]; then
container_args+=(
--volume "$void_teamspeak_source:/workspace-deps/VoidTeamspeak:ro"
)
fi
if [[ -n ${SOURCE_DATE_EPOCH:-} ]]; then
container_args+=(--env "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH")
fi
@@ -130,6 +257,24 @@ if ((use_container)); then
[[ -n $jobs ]] && release_args+=(--jobs "$jobs")
((run_tests)) || release_args+=(--skip-tests)
((clean_build)) || release_args+=(--no-clean)
[[ -z $void_source ]] ||
release_args+=(--void-source /workspace-deps/VoidLibrary)
[[ -z $void_teamspeak_source ]] ||
release_args+=(--void-teamspeak-source /workspace-deps/VoidTeamspeak)
if [[ -n $update_url ]]; then
release_args+=(
--update-url "$update_url"
--update-channel "$update_channel"
--update-feed-id "$update_feed_id"
--update-valid-days "$update_valid_days"
)
[[ -z $update_sequence ]] ||
release_args+=(--update-sequence "$update_sequence")
fi
[[ -z $official_update_feed_url ]] ||
release_args+=(
--official-update-feed-url "$official_update_feed_url"
)
docker run --platform linux/amd64 "${container_args[@]}" "$image" \
bash scripts/release.sh "${release_args[@]}"
exit
@@ -141,12 +286,14 @@ case "$(uname -s)/$(uname -m)" in
esac
required_commands=(
cmake ninja npm python3 patchelf readelf tar zstd gzip sha256sum
cmake ninja npm python3 patchelf readelf tar zstd gzip sha256sum openssl
dpkg-query ldconfig
)
for command_name in "${required_commands[@]}"; do
command -v "$command_name" >/dev/null || die "required command not found: $command_name"
done
python3 "$source_dir/scripts/validate-semver.py" "$version" ||
die "--version must be canonical Semantic Versioning 2.0.0"
[[ -x $source_dir/packaging/install.sh ]] ||
die "installer source is missing: packaging/install.sh"
[[ -x $source_dir/packaging/uninstall.sh ]] ||
@@ -174,7 +321,30 @@ if ((clean_build)); then
fi
mkdir -p "$build_dir"
configure_args=(--preset linux-release -B "$build_dir")
configure_args=(
--preset linux-release
-B "$build_dir"
-DBUILD_SHARED_LIBS=ON
-DECHOION_STATIC_LINK=OFF
-DECHOION_REPRODUCIBLE_BUILD=ON
"-DECHOION_RUNTIME_VERSION=$version"
)
official_update_keys="$source_dir/.gitea/release-keys/official-update-keys.json"
[[ -f $official_update_keys ]] ||
die "official update trust store is missing: $official_update_keys"
official_update_keys_json=$(
python3 -c \
'import json,sys; print(json.dumps(json.load(open(sys.argv[1], encoding="utf-8")), separators=(",", ":")))' \
"$official_update_keys"
) || die "official update trust store is invalid"
configure_args+=(
"-DECHOION_UPDATE_PUBLIC_KEYS_JSON=$official_update_keys_json"
"-DECHOION_UPDATE_FEED_URL=$official_update_feed_url"
)
[[ -z $void_source ]] ||
configure_args+=("-DCPM_Void_SOURCE=$void_source")
[[ -z $void_teamspeak_source ]] ||
configure_args+=("-DCPM_VoidTeamspeak_SOURCE=$void_teamspeak_source")
npm --prefix "$source_dir/EchoionWeb/frontend" ci --no-audit --no-fund
cmake -E rm -rf "$source_dir/EchoionWeb/frontend/web-dist"
(
@@ -216,20 +386,47 @@ for runtime_name in libstdc++.so.6 libgcc_s.so.1; do
done
search_directories=$(IFS=';'; echo "${library_directories[*]}")
compiler_runtimes=$(IFS=';'; echo "${compiler_runtime_files[*]}")
resolver_libraries=("$build_dir/lib/Echoion.ts")
if [[ -d $stage/share/echoion/bootstrap-plugins ]]; then
while IFS= read -r -d '' plugin_library; do
resolver_libraries+=("$plugin_library")
done < <(
find "$stage/share/echoion/bootstrap-plugins" -type f -name '*.so' \
-print0 | LC_ALL=C sort -z
)
fi
resolver_library_list=$(IFS=';'; echo "${resolver_libraries[*]}")
cmake \
"-DBUNDLE_ROOT=$stage" \
"-DBUNDLE_RESOLVER_EXECUTABLE=$build_dir/bin/echoiond" \
"-DBUNDLE_RESOLVER_LIBRARIES=$build_dir/lib/Echoion.ts" \
"-DBUNDLE_RESOLVER_EXECUTABLES=$build_dir/bin/echoiond;$build_dir/bin/echoion-updater" \
"-DBUNDLE_RESOLVER_LIBRARIES=$resolver_library_list" \
"-DBUNDLE_SEARCH_DIRECTORIES=$search_directories" \
"-DBUNDLE_SEED_FILES=$compiler_runtimes" \
"-DPATCHELF_EXECUTABLE=$(command -v patchelf)" \
-P "$source_dir/cmake/BundleRuntimeDependencies.cmake"
# Bootstrap plugins are copied into writable managed-plugin state by the
# installer. Services and the portable launcher point the loader at current/lib;
# this relative path also keeps the immutable source artifact directly usable.
for plugin_library in "${resolver_libraries[@]:1}"; do
# shellcheck disable=SC2016 # Dynamic linker token, not a shell variable.
patchelf --set-rpath '$ORIGIN/../../../../../lib' "$plugin_library"
done
dependency_report="$build_dir/dependency-report.txt"
python3 "$source_dir/scripts/validate-release-elf.py" \
--root "$stage" \
--max-glibc 2.35 \
elf_validation_args=(
--root "$stage"
--report "$dependency_report"
--max-glibc 2.35
--forbid-content-prefix "$source_dir"
--forbid-content-prefix "$build_dir"
)
[[ -z $void_source ]] ||
elf_validation_args+=(--forbid-content-prefix "$void_source")
[[ -z $void_teamspeak_source ]] ||
elf_validation_args+=(--forbid-content-prefix "$void_teamspeak_source")
python3 "$source_dir/scripts/validate-release-elf.py" \
"${elf_validation_args[@]}"
collect_licenses() {
local destination=$1
@@ -325,10 +522,11 @@ archive="$dist_dir/$artifact_base.tar.zst"
installer="$dist_dir/$artifact_base.run"
external_manifest="$dist_dir/$artifact_base.manifest.json"
external_report="$dist_dir/$artifact_base.dependencies.txt"
feed_payload="$dist_dir/$artifact_base.update-payload.json"
rm -f -- \
"$archive" "$archive.tmp" \
"$installer" "$installer.tmp" \
"$external_manifest" "$external_report" \
"$external_manifest" "$external_report" "$feed_payload" \
"$dist_dir/SHA256SUMS"
bash "$source_dir/scripts/package-release-payload.sh" \
@@ -337,13 +535,31 @@ bash "$source_dir/scripts/package-release-payload.sh" \
install -m 0644 "$stage/manifest.json" "$external_manifest"
install -m 0644 "$dependency_report" "$external_report"
if [[ -n $update_url ]]; then
feed_args=(
--artifact "$archive"
--manifest "$external_manifest"
--version "$version"
--url "$update_url"
--channel "$update_channel"
--feed-id "$update_feed_id"
--valid-days "$update_valid_days"
--output-payload "$feed_payload"
)
[[ -z $update_sequence ]] ||
feed_args+=(--sequence "$update_sequence")
python3 "$source_dir/scripts/generate-update-feed.py" "${feed_args[@]}"
fi
(
cd "$dist_dir"
sha256sum \
checksum_files=(
"$(basename "$archive")" \
"$(basename "$installer")" \
"$(basename "$external_manifest")" \
"$(basename "$external_report")" >SHA256SUMS
"$(basename "$external_report")"
)
[[ -z $update_url ]] || checksum_files+=("$(basename "$feed_payload")")
sha256sum "${checksum_files[@]}" >SHA256SUMS
)
echo "Release created without starting Echoion:"
@@ -351,4 +567,5 @@ echo " $archive"
echo " $installer"
echo " $external_manifest"
echo " $external_report"
[[ -z $update_url ]] || echo " $feed_payload"
echo " $dist_dir/SHA256SUMS"