695 lines
23 KiB
Bash
Executable File
695 lines
23 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
usage: scripts/release.sh --version VERSION [options]
|
|
|
|
Options:
|
|
--build-dir DIR Clean build directory (default: build-relwithdebinfo)
|
|
--dist-dir DIR Release output directory (default: dist)
|
|
--jobs N Parallel build jobs
|
|
--skip-tests Skip CTest and frontend tests
|
|
--skip-component-packages
|
|
Build only the Echoion product artifacts; component
|
|
packages are published by their own repositories
|
|
--no-clean Reuse the configured build directory
|
|
--update-channel NAME
|
|
Component package channel (default: stable)
|
|
--update-sequence N
|
|
Monotonic component sequence (default: SOURCE_DATE_EPOCH)
|
|
--official-update-feed-url URL
|
|
HTTPS channel catalog embedded as the official default
|
|
--void-source DIR Use an explicit VoidLibrary source tree
|
|
--void-teamspeak-source DIR
|
|
Use an explicit VoidTeamspeak source tree
|
|
--component-workspace DIR
|
|
Directory containing the nine permanent component repos
|
|
(default: parent of this Echoion checkout)
|
|
--container Build with containers/release.Dockerfile (the default)
|
|
--host Explicitly build directly on this host
|
|
-h, --help Show this help
|
|
|
|
The release process never starts echoiond. Runtime validation uses readelf.
|
|
EOF
|
|
}
|
|
|
|
die() {
|
|
echo "release: $*" >&2
|
|
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)
|
|
# shellcheck source-path=SCRIPTDIR
|
|
# shellcheck source=lib/docker-daemon-path.sh
|
|
source "$script_dir/lib/docker-daemon-path.sh"
|
|
version=
|
|
build_dir="$source_dir/build-relwithdebinfo"
|
|
dist_dir="$source_dir/dist"
|
|
jobs=
|
|
run_tests=1
|
|
clean_build=1
|
|
package_components=1
|
|
use_container=1
|
|
update_channel=stable
|
|
update_sequence=
|
|
official_update_feed_url=
|
|
void_source=
|
|
void_teamspeak_source=
|
|
component_workspace=$(dirname -- "$source_dir")
|
|
|
|
while (($#)); do
|
|
case $1 in
|
|
--version)
|
|
(($# >= 2)) || die "--version requires a value"
|
|
version=$2
|
|
shift 2
|
|
;;
|
|
--build-dir)
|
|
(($# >= 2)) || die "--build-dir requires a value"
|
|
build_dir=$2
|
|
shift 2
|
|
;;
|
|
--dist-dir)
|
|
(($# >= 2)) || die "--dist-dir requires a value"
|
|
dist_dir=$2
|
|
shift 2
|
|
;;
|
|
--jobs)
|
|
(($# >= 2)) || die "--jobs requires a value"
|
|
jobs=$2
|
|
shift 2
|
|
;;
|
|
--skip-tests)
|
|
run_tests=0
|
|
shift
|
|
;;
|
|
--skip-component-packages)
|
|
package_components=0
|
|
shift
|
|
;;
|
|
--no-clean)
|
|
clean_build=0
|
|
shift
|
|
;;
|
|
--update-channel)
|
|
(($# >= 2)) || die "--update-channel requires a value"
|
|
update_channel=$2
|
|
shift 2
|
|
;;
|
|
--update-sequence)
|
|
(($# >= 2)) || die "--update-sequence requires a value"
|
|
update_sequence=$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
|
|
;;
|
|
--component-workspace)
|
|
(($# >= 2)) || die "--component-workspace requires a value"
|
|
component_workspace=$2
|
|
shift 2
|
|
;;
|
|
--container)
|
|
use_container=1
|
|
shift
|
|
;;
|
|
--host)
|
|
use_container=0
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
die "unknown argument: $1"
|
|
;;
|
|
esac
|
|
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"
|
|
[[ -z $update_sequence || $update_sequence =~ ^[0-9]+$ ]] ||
|
|
die "--update-sequence must be a non-negative integer"
|
|
[[ -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")
|
|
component_workspace=$(realpath -e -- "$component_workspace")
|
|
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
|
|
component_ids=(
|
|
EchoionApi
|
|
EchoionCore
|
|
EchoionDesktop
|
|
EchoionHost
|
|
EchoionPluginUrlShortenerExternal
|
|
EchoionPluginUrlShortenerInternal
|
|
EchoionStandalone
|
|
EchoionUpdater
|
|
EchoionWeb
|
|
)
|
|
for component_id in "${component_ids[@]}"; do
|
|
[[ -f $component_workspace/$component_id/CMakeLists.txt &&
|
|
-d $component_workspace/$component_id/.git ]] ||
|
|
die "missing permanent component repository: $component_workspace/$component_id"
|
|
done
|
|
|
|
container_path() {
|
|
local path=$1
|
|
case $path in
|
|
"$source_dir") echo /workspace ;;
|
|
"$source_dir"/*) echo "/workspace/${path#"$source_dir"/}" ;;
|
|
*) die "container build and dist directories must be inside $source_dir" ;;
|
|
esac
|
|
}
|
|
|
|
if ((use_container)); then
|
|
command -v docker >/dev/null || die "docker is required for --container"
|
|
container_build_dir=$(container_path "$build_dir")
|
|
container_dist_dir=$(container_path "$dist_dir")
|
|
docker_source_dir=$(docker_daemon_path "$source_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" \
|
|
"$source_dir"
|
|
container_args=(
|
|
--rm
|
|
--user "$(id -u):$(id -g)"
|
|
--volume "$docker_source_dir:/workspace"
|
|
--workdir /workspace
|
|
--env HOME=/tmp/echoion-release-home
|
|
--env npm_config_cache=/tmp/echoion-npm-cache
|
|
)
|
|
for component_id in "${component_ids[@]}"; do
|
|
docker_component_source=$(
|
|
docker_daemon_path "$component_workspace/$component_id"
|
|
)
|
|
container_args+=(
|
|
--volume
|
|
"$docker_component_source:/workspace-components/$component_id"
|
|
)
|
|
done
|
|
container_args+=("${proxy_run_args[@]}")
|
|
if [[ -n $void_source ]]; then
|
|
docker_void_source=$(docker_daemon_path "$void_source")
|
|
container_args+=(
|
|
--volume "$docker_void_source:/workspace-deps/VoidLibrary:ro"
|
|
)
|
|
fi
|
|
if [[ -n $void_teamspeak_source ]]; then
|
|
docker_void_teamspeak_source=$(docker_daemon_path "$void_teamspeak_source")
|
|
container_args+=(
|
|
--volume "$docker_void_teamspeak_source:/workspace-deps/VoidTeamspeak:ro"
|
|
)
|
|
fi
|
|
if [[ -n ${SOURCE_DATE_EPOCH:-} ]]; then
|
|
container_args+=(--env "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH")
|
|
fi
|
|
release_args=(
|
|
--host
|
|
--version "$version"
|
|
--build-dir "$container_build_dir"
|
|
--dist-dir "$container_dist_dir"
|
|
--component-workspace /workspace-components
|
|
)
|
|
[[ -n $jobs ]] && release_args+=(--jobs "$jobs")
|
|
((run_tests)) || release_args+=(--skip-tests)
|
|
((package_components)) || release_args+=(--skip-component-packages)
|
|
((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)
|
|
release_args+=(--update-channel "$update_channel")
|
|
[[ -z $update_sequence ]] ||
|
|
release_args+=(--update-sequence "$update_sequence")
|
|
[[ -z $official_update_feed_url ]] ||
|
|
release_args+=(
|
|
--official-update-feed-url "$official_update_feed_url"
|
|
)
|
|
if [[ $docker_source_dir != "$source_dir" ]]; then
|
|
echo "release: mapped container workspace through the Docker daemon mount table"
|
|
fi
|
|
docker run --rm --platform linux/amd64 \
|
|
--volume "$docker_source_dir:/workspace:ro" \
|
|
"$image" \
|
|
test -x /workspace/scripts/release.sh ||
|
|
die "Docker daemon cannot access the checked-out source tree"
|
|
docker run --platform linux/amd64 "${container_args[@]}" "$image" \
|
|
bash scripts/release.sh "${release_args[@]}"
|
|
exit
|
|
fi
|
|
|
|
case "$(uname -s)/$(uname -m)" in
|
|
Linux/x86_64|Linux/amd64) ;;
|
|
*) die "host release builds require Linux x86_64; use the amd64 container builder" ;;
|
|
esac
|
|
|
|
required_commands=(
|
|
cmake file 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 ]] ||
|
|
die "uninstaller source is missing: packaging/uninstall.sh"
|
|
[[ -f $source_dir/packaging/service/echoion.service.in ]] ||
|
|
die "service template is missing: packaging/service/echoion.service.in"
|
|
|
|
if [[ -z ${SOURCE_DATE_EPOCH:-} ]]; then
|
|
SOURCE_DATE_EPOCH=$(git -C "$source_dir" log -1 --format=%ct 2>/dev/null || true)
|
|
[[ $SOURCE_DATE_EPOCH =~ ^[0-9]+$ ]] || SOURCE_DATE_EPOCH=0
|
|
fi
|
|
export SOURCE_DATE_EPOCH
|
|
|
|
safe_remove_tree() {
|
|
local path=$1
|
|
case $path in
|
|
"$source_dir"/build*|/tmp/*) ;;
|
|
*) die "refusing to clean non-build path outside source build*/ or /tmp: $path" ;;
|
|
esac
|
|
rm -rf -- "$path"
|
|
}
|
|
|
|
if ((clean_build)); then
|
|
safe_remove_tree "$build_dir"
|
|
fi
|
|
mkdir -p "$build_dir"
|
|
|
|
configure_args=(
|
|
--preset linux-release
|
|
-B "$build_dir"
|
|
-DBUILD_SHARED_LIBS=ON
|
|
-DECHOION_STATIC_LINK=OFF
|
|
-DECHOION_RELEASE_BUILD=ON
|
|
-DECHOION_REPRODUCIBLE_BUILD=ON
|
|
"-DECHOION_RELEASE_VERSION=$version"
|
|
"-DECHOION_RUNTIME_VERSION=$version"
|
|
"-DECHOION_TOOLCHAIN_ABI=linux-x86_64-glibc-2.35-cxx26"
|
|
"-DECHOION_COMPONENT_WORKSPACE=$component_workspace"
|
|
)
|
|
for component_id in "${component_ids[@]}"; do
|
|
configure_args+=(
|
|
"-DCPM_${component_id}_SOURCE=$component_workspace/$component_id"
|
|
)
|
|
done
|
|
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")
|
|
web_frontend="$component_workspace/EchoionWeb/frontend"
|
|
npm --prefix "$web_frontend" ci --no-audit --no-fund
|
|
cmake -E rm -rf "$web_frontend/web-dist"
|
|
release_prefix_maps=(
|
|
"$source_dir=Echoion"
|
|
"$build_dir=EchoionBuild"
|
|
"$component_workspace=EchoionComponents"
|
|
)
|
|
[[ -z $void_source ]] ||
|
|
release_prefix_maps+=("$void_source=VoidLibrary")
|
|
[[ -z $void_teamspeak_source ]] ||
|
|
release_prefix_maps+=("$void_teamspeak_source=VoidTeamspeak")
|
|
release_c_flags=${CFLAGS:-}
|
|
release_cxx_flags=${CXXFLAGS:-}
|
|
for release_prefix_map in "${release_prefix_maps[@]}"; do
|
|
release_c_flags+=" -ffile-prefix-map=$release_prefix_map"
|
|
release_c_flags+=" -fmacro-prefix-map=$release_prefix_map"
|
|
release_c_flags+=" -fdebug-prefix-map=$release_prefix_map"
|
|
release_cxx_flags+=" -ffile-prefix-map=$release_prefix_map"
|
|
release_cxx_flags+=" -fmacro-prefix-map=$release_prefix_map"
|
|
release_cxx_flags+=" -fdebug-prefix-map=$release_prefix_map"
|
|
done
|
|
(
|
|
cd "$source_dir"
|
|
CFLAGS="$release_c_flags" CXXFLAGS="$release_cxx_flags" \
|
|
cmake "${configure_args[@]}"
|
|
)
|
|
build_args=(--build "$build_dir" --config RelWithDebInfo)
|
|
[[ -n $jobs ]] && build_args+=(--parallel "$jobs")
|
|
cmake "${build_args[@]}"
|
|
|
|
if ((run_tests)); then
|
|
ctest --test-dir "$build_dir" --build-config RelWithDebInfo --output-on-failure
|
|
npm --prefix "$web_frontend" test
|
|
npm --prefix "$web_frontend" run i18n:check
|
|
fi
|
|
|
|
stage="$build_dir/runtime-stage"
|
|
safe_remove_tree "$stage"
|
|
cmake --install "$build_dir" \
|
|
--config RelWithDebInfo \
|
|
--component Runtime \
|
|
--prefix "$stage"
|
|
|
|
certificate_bundle=${ECHOION_CA_BUNDLE:-/etc/ssl/certs/ca-certificates.crt}
|
|
[[ -s $certificate_bundle ]] ||
|
|
die "TLS certificate bundle is missing or empty: $certificate_bundle"
|
|
install -D -m 0644 -- "$certificate_bundle" \
|
|
"$stage/share/echoion/certs/ca-certificates.crt"
|
|
|
|
mapfile -t library_directories < <(
|
|
find "$build_dir" -type f \( -name '*.so' -o -name '*.so.*' -o -name '*.ts' \) \
|
|
-printf '%h\n' | LC_ALL=C sort -u
|
|
)
|
|
library_directories+=("$stage/lib")
|
|
cxx_compiler=$("$source_dir/scripts/configured-cxx-compiler.sh" "$build_dir")
|
|
compiler_runtime_files=()
|
|
for runtime_name in libstdc++.so.6 libgcc_s.so.1; do
|
|
runtime_path=$(
|
|
"$cxx_compiler" -print-file-name="$runtime_name"
|
|
) || die "cannot locate $runtime_name with $cxx_compiler"
|
|
[[ $runtime_path == /* && -f $runtime_path ]] ||
|
|
die "$cxx_compiler did not return an existing absolute path for $runtime_name"
|
|
compiler_runtime_files+=("$runtime_path")
|
|
library_directories+=("$(dirname -- "$runtime_path")")
|
|
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_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. Search the active release closure from managed, portable/manual,
|
|
# and immutable bootstrap locations, then allow plugin-private dependencies.
|
|
# shellcheck disable=SC2016 # Dynamic linker token, not a shell variable.
|
|
plugin_runpath='$ORIGIN/../../../../../../current/lib:$ORIGIN/../../current/lib:$ORIGIN/lib'
|
|
for plugin_library in "${resolver_libraries[@]:1}"; do
|
|
patchelf --set-rpath "$plugin_runpath" "$plugin_library"
|
|
done
|
|
|
|
dependency_report="$build_dir/dependency-report.txt"
|
|
elf_validation_args=(
|
|
--root "$stage"
|
|
--report "$dependency_report"
|
|
--max-glibc 2.35
|
|
--require-first-party-debug-info
|
|
--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
|
|
local candidate relative package_name license_name digest target package source_path soname
|
|
local -a license_roots=(
|
|
"$component_workspace/EchoionApi"
|
|
"$component_workspace/EchoionCore"
|
|
"$component_workspace/EchoionHost"
|
|
"$component_workspace/EchoionStandalone"
|
|
"$component_workspace/EchoionWeb"
|
|
"$component_workspace/EchoionUpdater"
|
|
"$component_workspace/EchoionDesktop"
|
|
"$component_workspace/EchoionPluginUrlShortenerInternal"
|
|
"$component_workspace/EchoionPluginUrlShortenerExternal"
|
|
"$build_dir/_deps"
|
|
)
|
|
if [[ -n ${GCC_ROOT:-} && -d $GCC_ROOT/share/licenses ]]; then
|
|
license_roots+=("$GCC_ROOT/share/licenses")
|
|
fi
|
|
if [[ -n ${BOOST_ROOT:-} && -d $BOOST_ROOT/share/licenses ]]; then
|
|
license_roots+=("$BOOST_ROOT/share/licenses")
|
|
fi
|
|
if [[ -n ${FFMPEG_ROOT:-} && -d $FFMPEG_ROOT/share/licenses ]]; then
|
|
license_roots+=("$FFMPEG_ROOT/share/licenses")
|
|
fi
|
|
mkdir -p "$destination"
|
|
|
|
for source_path in "${license_roots[@]}"; do
|
|
[[ -d $source_path ]] || continue
|
|
while IFS= read -r -d '' candidate; do
|
|
relative=${candidate#"$source_path"/}
|
|
if [[ $relative == */* ]]; then
|
|
package_name=${relative%%/*}
|
|
else
|
|
package_name=$(basename -- "$source_path")
|
|
fi
|
|
license_name=$(basename -- "$candidate")
|
|
package_name=${package_name//[^A-Za-z0-9._+-]/_}
|
|
license_name=${license_name//[^A-Za-z0-9._+-]/_}
|
|
digest=$(sha256sum "$candidate" | cut -c1-12)
|
|
target="$destination/${package_name}--${license_name}--${digest}"
|
|
install -m 0644 -- "$candidate" "$target"
|
|
done < <(
|
|
find "$source_path" -maxdepth 5 -type f \
|
|
\( -iname 'LICENSE' -o -iname 'LICENSE.txt' -o \
|
|
-iname 'LICENSE.md' -o -iname 'LICENSE.rst' -o \
|
|
-iname 'LICENSE-*' -o -iname 'LICENSE_*' -o \
|
|
-iname 'COPYING' -o -iname 'COPYING.*' -o \
|
|
-iname 'NOTICE' -o -iname 'NOTICE.*' -o \
|
|
-iname 'COPYRIGHT' -o -iname 'COPYRIGHT.*' \) \
|
|
-not -path '*/node_modules/*' -not -path '*/.git/*' \
|
|
-print0 | LC_ALL=C sort -z
|
|
)
|
|
done
|
|
|
|
if command -v dpkg-query >/dev/null && command -v ldconfig >/dev/null; then
|
|
while IFS= read -r soname; do
|
|
[[ -n $soname ]] || continue
|
|
source_path=$(ldconfig -p 2>/dev/null |
|
|
awk -v name="$soname" '
|
|
$1 == name && !path { path = $NF }
|
|
END { if (path) print path }
|
|
')
|
|
[[ -n $source_path ]] || continue
|
|
package=$(dpkg-query -S "$(readlink -f -- "$source_path")" 2>/dev/null |
|
|
sed -n '1s/: .*//p') || package=
|
|
[[ -n $package ]] || continue
|
|
package=${package%%:*}
|
|
candidate="/usr/share/doc/${package}/copyright"
|
|
[[ -f $candidate ]] || continue
|
|
install -m 0644 -- "$candidate" "$destination/${package}--copyright"
|
|
done < <(
|
|
find "$stage/lib" -maxdepth 1 \( -type f -o -type l \) \
|
|
-printf '%f\n' | LC_ALL=C sort -u
|
|
)
|
|
fi
|
|
|
|
candidate=/usr/share/doc/ca-certificates/copyright
|
|
if [[ -f $candidate ]]; then
|
|
install -m 0644 -- "$candidate" \
|
|
"$destination/ca-certificates--copyright"
|
|
fi
|
|
}
|
|
|
|
collect_licenses "$stage/share/echoion/licenses"
|
|
python3 "$source_dir/scripts/collect-frontend-licenses.py" \
|
|
--node-modules "$web_frontend/node_modules" \
|
|
--output "$stage/share/echoion/licenses/frontend"
|
|
|
|
python3 "$source_dir/scripts/generate-release-manifest.py" \
|
|
--root "$stage" \
|
|
--version "$version" \
|
|
--build-type RelWithDebInfo \
|
|
--output "$stage/manifest.json"
|
|
|
|
# Installer helpers are mutable prefix-level files and intentionally are not
|
|
# included in manifest.files. They are added only after the immutable manifest.
|
|
install -m 0755 "$source_dir/packaging/install.sh" "$stage/install.sh"
|
|
install -m 0755 "$source_dir/packaging/uninstall.sh" "$stage/uninstall.sh"
|
|
|
|
mkdir -p "$dist_dir"
|
|
component_stage_root="$build_dir/component-staging"
|
|
if ((package_components)); then
|
|
safe_remove_tree "$component_stage_root"
|
|
mkdir -p "$component_stage_root"
|
|
while IFS=$'\t' read -r component_id package_id; do
|
|
component_root="$component_stage_root/$package_id"
|
|
cmake --install "$build_dir" \
|
|
--config RelWithDebInfo \
|
|
--component "Package${component_id}" \
|
|
--prefix "$component_root"
|
|
|
|
component_executables=()
|
|
component_libraries=()
|
|
while IFS= read -r -d '' component_elf; do
|
|
case $(file --brief --mime-type "$component_elf") in
|
|
application/x-executable|application/x-pie-executable|application/x-sharedlib) ;;
|
|
*) continue ;;
|
|
esac
|
|
case ${component_elf#"$component_root"/} in
|
|
bin/*) component_executables+=("$component_elf") ;;
|
|
*) component_libraries+=("$component_elf") ;;
|
|
esac
|
|
done < <(
|
|
find "$component_root" -type f -print0 | LC_ALL=C sort -z
|
|
)
|
|
if ((${#component_executables[@]} || ${#component_libraries[@]})); then
|
|
component_executable_list=$(
|
|
IFS=';'
|
|
echo "${component_executables[*]}"
|
|
)
|
|
component_library_list=$(
|
|
IFS=';'
|
|
echo "${component_libraries[*]}"
|
|
)
|
|
cmake \
|
|
"-DBUNDLE_ROOT=$component_root" \
|
|
"-DBUNDLE_EXECUTABLES=$component_executable_list" \
|
|
"-DBUNDLE_LIBRARIES=$component_library_list" \
|
|
"-DBUNDLE_SEARCH_DIRECTORIES=$search_directories" \
|
|
"-DBUNDLE_SEED_FILES=$compiler_runtimes" \
|
|
"-DPATCHELF_EXECUTABLE=$(command -v patchelf)" \
|
|
-P "$source_dir/cmake/BundleComponentDependencies.cmake"
|
|
fi
|
|
done < <(
|
|
python3 -c \
|
|
'import json,sys; data=json.load(open(sys.argv[1], encoding="utf-8"))["components"]; [print(name, data[name]["packageId"], sep="\t") for name in sorted(data)]' \
|
|
"$source_dir/components.json"
|
|
)
|
|
fi
|
|
|
|
artifact_base="echoion-${version}-linux-x86_64"
|
|
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"
|
|
component_dist="$dist_dir/components"
|
|
rm -f -- \
|
|
"$archive" "$archive.tmp" \
|
|
"$installer" "$installer.tmp" \
|
|
"$external_manifest" "$external_report" \
|
|
"$dist_dir/SHA256SUMS"
|
|
cmake -E rm -rf "$component_dist"
|
|
|
|
bash "$source_dir/scripts/package-release-payload.sh" \
|
|
"$stage" "$artifact_base" "$SOURCE_DATE_EPOCH" \
|
|
"$archive" "$installer" "$build_dir"
|
|
|
|
install -m 0644 "$stage/manifest.json" "$external_manifest"
|
|
install -m 0644 "$dependency_report" "$external_report"
|
|
if ((package_components)); then
|
|
component_sequence=${update_sequence:-$SOURCE_DATE_EPOCH}
|
|
if [[ $component_sequence == 0 ]]; then
|
|
component_sequence=1
|
|
fi
|
|
python3 "$source_dir/scripts/package-components.py" \
|
|
--registry "$source_dir/components.json" \
|
|
--lock "$source_dir/components.lock.json" \
|
|
--staging-root "$component_stage_root" \
|
|
--output "$component_dist" \
|
|
--channel "$update_channel" \
|
|
--sequence "$component_sequence" \
|
|
--product-version "$version" \
|
|
--build-type RelWithDebInfo \
|
|
--toolchain-contract linux-x86_64-glibc-2.35-cxx26
|
|
fi
|
|
(
|
|
cd "$dist_dir"
|
|
mapfile -t checksum_files < <(
|
|
find . -type f ! -name SHA256SUMS -printf '%P\n' |
|
|
LC_ALL=C sort
|
|
)
|
|
sha256sum "${checksum_files[@]}" >SHA256SUMS
|
|
)
|
|
|
|
echo "Release created without starting Echoion:"
|
|
echo " $archive"
|
|
echo " $installer"
|
|
echo " $external_manifest"
|
|
echo " $external_report"
|
|
((package_components)) && echo " $component_dist"
|
|
echo " $dist_dir/SHA256SUMS"
|