chore: restore product scaffold to rollback baseline

This commit is contained in:
Edison Jwa
2026-05-29 14:02:04 +09:00
parent 2896f14ec9
commit fe6e07353e
434 changed files with 27278 additions and 63230 deletions
-116
View File
@@ -1,116 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
APP_DIR="$REPO_ROOT/apps/chanora_flutter"
PUBSPEC="$APP_DIR/pubspec.yaml"
OBOE_DIR="$(cd "$REPO_ROOT/.." && pwd)/oboe-rs"
DIST_DIR="$REPO_ROOT/dist/android"
TMP_DIR=""
cleanup() {
if [[ -n "$TMP_DIR" && -d "$TMP_DIR" ]]; then
rm -rf "$TMP_DIR"
fi
}
trap cleanup EXIT
require_cmd() {
local cmd=$1
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "ERROR: required command '$cmd' is not on PATH." >&2
exit 1
fi
}
require_file() {
local path=$1
local label=$2
if [[ ! -f "$path" ]]; then
echo "ERROR: missing $label at $path" >&2
exit 1
fi
}
ensure_release_signing() {
if [[ -n "${CHANORA_RELEASE_STORE_FILE:-}" ]]; then
local missing=()
[[ -n "${CHANORA_RELEASE_STORE_PASSWORD:-}" ]] || missing+=("CHANORA_RELEASE_STORE_PASSWORD")
[[ -n "${CHANORA_RELEASE_KEY_ALIAS:-}" ]] || missing+=("CHANORA_RELEASE_KEY_ALIAS")
[[ -n "${CHANORA_RELEASE_KEY_PASSWORD:-}" ]] || missing+=("CHANORA_RELEASE_KEY_PASSWORD")
if (( ${#missing[@]} > 0 )); then
printf 'ERROR: release signing is partially configured; missing %s\n' "${missing[*]}" >&2
exit 1
fi
require_file "$CHANORA_RELEASE_STORE_FILE" "release keystore"
return
fi
require_cmd keytool
TMP_DIR="$(mktemp -d "${TMPDIR:-/tmp}/chanora-android-aab.XXXXXX")"
export CHANORA_RELEASE_STORE_FILE="$TMP_DIR/chanora-release.keystore"
export CHANORA_RELEASE_STORE_PASSWORD="${CHANORA_RELEASE_STORE_PASSWORD:-chanora-ci}"
export CHANORA_RELEASE_KEY_ALIAS="${CHANORA_RELEASE_KEY_ALIAS:-chanora-ci}"
export CHANORA_RELEASE_KEY_PASSWORD="${CHANORA_RELEASE_KEY_PASSWORD:-$CHANORA_RELEASE_STORE_PASSWORD}"
keytool -genkeypair \
-storetype PKCS12 \
-keystore "$CHANORA_RELEASE_STORE_FILE" \
-storepass "$CHANORA_RELEASE_STORE_PASSWORD" \
-keypass "$CHANORA_RELEASE_KEY_PASSWORD" \
-alias "$CHANORA_RELEASE_KEY_ALIAS" \
-keyalg RSA \
-keysize 2048 \
-validity 3650 \
-dname "CN=Chanora CI,O=Chanora,OU=Engineering,L=Seoul,S=Seoul,C=KR" \
-noprompt >/dev/null 2>&1
printf 'Generated ephemeral Android release keystore: %s\n' "$CHANORA_RELEASE_STORE_FILE"
}
main() {
require_cmd flutter
require_file "$PUBSPEC" "Flutter pubspec"
if [[ ! -f "$OBOE_DIR/Cargo.toml" ]]; then
cat >&2 <<EOF
ERROR: missing sibling oboe-rs checkout at:
$OBOE_DIR
This repository's Android-targeted Rust manifest currently depends on a local
oboe-rs fork. Clone it before running this script:
git clone https://github.com/edisonjwa/oboe-rs.git "$OBOE_DIR"
EOF
exit 1
fi
ensure_release_signing
local app_version
app_version="$(sed -n 's/^version:[[:space:]]*//p' "$PUBSPEC" | head -n1)"
if [[ -z "$app_version" ]]; then
echo "ERROR: could not read version from $PUBSPEC" >&2
exit 1
fi
(
cd "$APP_DIR"
flutter pub get
flutter build appbundle --release
)
local source_aab="$APP_DIR/build/app/outputs/bundle/release/app-release.aab"
require_file "$source_aab" "Android release app bundle"
mkdir -p "$DIST_DIR"
local output="$DIST_DIR/chanora-${app_version}-release.aab"
cp "$source_aab" "$output"
printf 'Built Android release bundle: %s\n' "$output"
}
main "$@"
-160
View File
@@ -1,160 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
APP_DIR="$REPO_ROOT/apps/chanora_flutter"
PUBSPEC="$APP_DIR/pubspec.yaml"
OBOE_DIR="$(cd "$REPO_ROOT/.." && pwd)/oboe-rs"
DIST_DIR="$REPO_ROOT/dist/linux"
STAGE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/chanora-linux-deb.XXXXXX")"
PKG_ROOT="$STAGE_DIR/package"
INSTALL_ROOT="$PKG_ROOT/opt/chanora"
ICON_SRC="$APP_DIR/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png"
cleanup() {
rm -rf "$STAGE_DIR"
}
trap cleanup EXIT
require_cmd() {
local cmd=$1
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "ERROR: required command '$cmd' is not on PATH." >&2
exit 1
fi
}
require_file() {
local path=$1
local label=$2
if [[ ! -f "$path" ]]; then
echo "ERROR: missing $label at $path" >&2
exit 1
fi
}
resolve_arch() {
if command -v dpkg >/dev/null 2>&1; then
dpkg --print-architecture
return
fi
case "$(uname -m)" in
x86_64) echo "amd64" ;;
aarch64 | arm64) echo "arm64" ;;
*)
echo "ERROR: unsupported Linux architecture '$(uname -m)'" >&2
exit 1
;;
esac
}
flutter_linux_arch() {
case "$1" in
amd64) echo "x64" ;;
arm64) echo "arm64" ;;
*)
echo "ERROR: unsupported Flutter Linux architecture '$1'" >&2
exit 1
;;
esac
}
main() {
require_cmd flutter
require_cmd dpkg-deb
require_file "$PUBSPEC" "Flutter pubspec"
require_file "$ICON_SRC" "launcher icon"
if [[ ! -f "$OBOE_DIR/Cargo.toml" ]]; then
cat >&2 <<EOF
ERROR: missing sibling oboe-rs checkout at:
$OBOE_DIR
This repository's Android-targeted Rust manifest currently depends on a local
oboe-rs fork, so Cargo manifest loading fails until that sibling checkout
exists. Clone it before running this script:
git clone https://github.com/edisonjwa/oboe-rs.git "$OBOE_DIR"
EOF
exit 1
fi
local app_version
app_version="$(sed -n 's/^version:[[:space:]]*//p' "$PUBSPEC" | head -n1)"
if [[ -z "$app_version" ]]; then
echo "ERROR: could not read version from $PUBSPEC" >&2
exit 1
fi
local deb_version
deb_version="${app_version/-/~}"
local arch
arch="$(resolve_arch)"
local flutter_arch
flutter_arch="$(flutter_linux_arch "$arch")"
(
cd "$APP_DIR"
flutter pub get
flutter build linux --release
)
local bundle_dir="$APP_DIR/build/linux/$flutter_arch/release/bundle"
local app_binary="$bundle_dir/chanora_flutter"
require_file "$app_binary" "Linux release bundle binary"
require_file "$bundle_dir/lib/libonnxruntime.so" "bundled Linux ONNX Runtime shared library"
mkdir -p \
"$PKG_ROOT/DEBIAN" \
"$INSTALL_ROOT" \
"$PKG_ROOT/usr/bin" \
"$PKG_ROOT/usr/share/applications" \
"$PKG_ROOT/usr/share/icons/hicolor/256x256/apps"
cp -R "$bundle_dir/." "$INSTALL_ROOT/"
cat >"$PKG_ROOT/DEBIAN/control" <<EOF
Package: chanora
Version: $deb_version
Section: net
Priority: optional
Architecture: $arch
Maintainer: Chanora Project Contributors
Depends: libasound2, libgtk-3-0, libpipewire-0.3-0, libpulse0, libstdc++6
Description: Chanora voice client for TeamSpeak-compatible servers
Chanora is a Flutter + Rust voice client for TeamSpeak-compatible servers.
EOF
cat >"$PKG_ROOT/usr/bin/chanora" <<'EOF'
#!/bin/sh
exec /opt/chanora/chanora_flutter "$@"
EOF
chmod 0755 "$PKG_ROOT/usr/bin/chanora"
cat >"$PKG_ROOT/usr/share/applications/chanora.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Chanora
GenericName=Voice Client
Comment=Voice client for TeamSpeak-compatible servers
Exec=/usr/bin/chanora
Icon=chanora
Terminal=false
Categories=Network;Chat;AudioVideo;
StartupNotify=true
EOF
cp "$ICON_SRC" "$PKG_ROOT/usr/share/icons/hicolor/256x256/apps/chanora.png"
mkdir -p "$DIST_DIR"
local output="$DIST_DIR/chanora_${deb_version}_${arch}.deb"
dpkg-deb --build --root-owner-group "$PKG_ROOT" "$output" >/dev/null
printf 'Built Linux package: %s\n' "$output"
}
main "$@"
+7 -121
View File
@@ -6,9 +6,7 @@
# - Rust stable with x86_64-unknown-linux-gnu target
# - Flutter 3.41.9+ stable on PATH
# - CMake 3.13+, pkg-config, GTK3 dev headers, clang
# - System libopus development package (libopus-dev / opus-devel)
# - Optional: CHANORA_ONNXRUNTIME_SHARED_LIB=/abs/path/libonnxruntime.so
# to override the ONNX Runtime shared library bundled under bundle/lib/
# - System libopus dev package (libopus-dev / opus-devel)
# - flutter_rust_bridge_codegen 2.12.0 (only if regenerating bindings)
#
# Usage (from the repo root ~/chanora):
@@ -28,8 +26,6 @@ VERSION="v0.2.0-beta.1"
SKIP_RUST=0
REGEN=0
TARGET="x86_64-unknown-linux-gnu"
ONNXRUNTIME_SHARED_LIB="${CHANORA_ONNXRUNTIME_SHARED_LIB:-}"
ONNXRUNTIME_VERSION="${CHANORA_ONNXRUNTIME_VERSION:-1.26.0}"
while [[ $# -gt 0 ]]; do
case "$1" in
@@ -52,65 +48,11 @@ echo "Repo root : $REPO_ROOT"
echo "Version : $VERSION"
echo "Target : $TARGET"
echo "Build Rust: $([ "$SKIP_RUST" = 1 ] && echo skip || echo yes)"
echo "Bundle ORT: ${ONNXRUNTIME_SHARED_LIB:-auto ($ONNXRUNTIME_VERSION)}"
bar
resolve_onnxruntime_shared_lib() {
if [[ -n "$ONNXRUNTIME_SHARED_LIB" ]]; then
if [[ ! -f "$ONNXRUNTIME_SHARED_LIB" ]]; then
echo " ERROR: CHANORA_ONNXRUNTIME_SHARED_LIB does not exist:" >&2
echo " $ONNXRUNTIME_SHARED_LIB" >&2
exit 1
fi
return
fi
local ort_arch
case "$TARGET" in
x86_64-unknown-linux-gnu) ort_arch="x64" ;;
aarch64-unknown-linux-gnu) ort_arch="aarch64" ;;
*)
echo " ERROR: automatic ONNX Runtime bundling does not support target $TARGET." >&2
echo " Set CHANORA_ONNXRUNTIME_SHARED_LIB=/absolute/path/to/libonnxruntime.so." >&2
exit 1
;;
esac
local archive_name="onnxruntime-linux-${ort_arch}-${ONNXRUNTIME_VERSION}.tgz"
local cache_dir="$REPO_ROOT/.cache/onnxruntime/$ONNXRUNTIME_VERSION/$ort_arch"
local archive_path="$cache_dir/$archive_name"
local extract_dir="$cache_dir/extracted"
local extracted_lib="$extract_dir/onnxruntime-linux-${ort_arch}-${ONNXRUNTIME_VERSION}/lib/libonnxruntime.so"
local url="https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VERSION}/${archive_name}"
if [[ ! -f "$extracted_lib" ]]; then
mkdir -p "$cache_dir" "$extract_dir"
if [[ ! -f "$archive_path" ]]; then
if ! command -v curl >/dev/null; then
echo " ERROR: curl is required to download ONNX Runtime automatically." >&2
echo " Install curl or set CHANORA_ONNXRUNTIME_SHARED_LIB." >&2
exit 1
fi
echo " Downloading ONNX Runtime $ONNXRUNTIME_VERSION for linux-$ort_arch"
curl --fail --location --show-error --output "$archive_path" "$url"
fi
rm -rf "$extract_dir"
mkdir -p "$extract_dir"
tar -xzf "$archive_path" -C "$extract_dir"
fi
if [[ ! -f "$extracted_lib" ]]; then
echo " ERROR: ONNX Runtime archive did not contain expected library:" >&2
echo " $extracted_lib" >&2
exit 1
fi
ONNXRUNTIME_SHARED_LIB="$extracted_lib"
}
# ---------- 1. Verify toolchain ----------
echo "[1/6] Verify toolchain"
for cmd in cargo rustc flutter cmake pkg-config clang gcc tar; do
for cmd in cargo rustc flutter cmake pkg-config clang gcc; do
if ! command -v "$cmd" >/dev/null; then
echo " ERROR: '$cmd' not on PATH. See docs/release/linux-build.md." >&2
exit 1
@@ -124,52 +66,11 @@ if ! pkg-config --exists gtk+-3.0 2>/dev/null; then
exit 1
fi
# Verify libopus development files. tsclientlib's audio feature pulls in
# audiopus, which links libopus for Linux builds/tests.
# Verify libopus dev headers (needed by audiopus_sys to link)
if ! pkg-config --exists opus 2>/dev/null; then
echo " ERROR: opus pkg-config metadata not found." >&2
echo " Install the Opus development package (libopus-dev on" >&2
echo " Debian/Ubuntu or opus-devel on Fedora)." >&2
echo " ERROR: opus dev headers not found. Install libopus-dev (Debian/Ubuntu) or opus-devel (Fedora)." >&2
exit 1
fi
printf " %-12s : %s\n" "opus" "$(pkg-config --modversion opus)"
# Verify the exact PipeWire pkg-config modules the primary Linux voice backend uses.
# `pipewire-0.3` is not the module name exposed by distro packages; the crates
# resolve `libpipewire-0.3` and `libspa-0.2`.
if ! pkg-config --exists libpipewire-0.3 2>/dev/null; then
echo " ERROR: libpipewire-0.3 pkg-config metadata not found." >&2
echo " Install PipeWire development headers (for example pipewire-devel" >&2
echo " on Fedora or libpipewire-0.3-dev on Debian/Ubuntu)." >&2
exit 1
fi
if ! pkg-config --exists libspa-0.2 2>/dev/null; then
echo " ERROR: libspa-0.2 pkg-config metadata not found." >&2
echo " Install the PipeWire SPA development headers packaged with" >&2
echo " your distro's PipeWire development package." >&2
exit 1
fi
printf " %-12s : %s\n" "libpipewire" "$(pkg-config --modversion libpipewire-0.3)"
printf " %-12s : %s\n" "libspa" "$(pkg-config --modversion libspa-0.2)"
# Verify PulseAudio development files used by the fallback Linux voice backend.
if ! pkg-config --exists libpulse 2>/dev/null; then
echo " ERROR: libpulse pkg-config metadata not found." >&2
echo " Install PulseAudio development headers (for example libpulse-dev" >&2
echo " on Debian/Ubuntu, pulseaudio-libs-devel on Fedora, or libpulse" >&2
echo " on Arch Linux)." >&2
exit 1
fi
if ! pkg-config --exists libpulse-simple 2>/dev/null; then
echo " ERROR: libpulse-simple pkg-config metadata not found." >&2
echo " Install PulseAudio simple API development headers." >&2
exit 1
fi
printf " %-12s : %s\n" "libpulse" "$(pkg-config --modversion libpulse)"
printf " %-12s : %s\n" "pulse-simple" "$(pkg-config --modversion libpulse-simple)"
resolve_onnxruntime_shared_lib
echo " ORT source : $ONNXRUNTIME_SHARED_LIB"
# Verify Rust target
if ! rustup target list --installed | grep -q "^$TARGET$"; then
@@ -223,8 +124,6 @@ fi
# ---------- 5. flutter build linux --release ----------
echo "[5/6] flutter build linux --release"
cd "$FLUTTER_APP"
export CHANORA_BRIDGE_SHARED_LIB="$BRIDGE_SO"
export CHANORA_ONNXRUNTIME_SHARED_LIB="$ONNXRUNTIME_SHARED_LIB"
flutter pub get
flutter build linux --release
@@ -235,25 +134,12 @@ if [[ ! -f "$EXE" ]]; then
exit 1
fi
# Copy the bridge .so into the bundle's lib/ directory so dart:ffi finds it.
mkdir -p "$BUNDLE_DIR/lib"
rm -f "$BUNDLE_DIR/lib/libonnxruntime.so"
cp "$ONNXRUNTIME_SHARED_LIB" "$BUNDLE_DIR/lib/libonnxruntime.so"
cp "$BRIDGE_SO" "$BUNDLE_DIR/lib/"
echo " Bundle dir : $BUNDLE_DIR"
echo " EXE : $EXE"
echo " Bridge .so : $BUNDLE_DIR/lib/libchanora_bridge.so"
if [[ ! -f "$BUNDLE_DIR/lib/libchanora_bridge.so" ]]; then
echo " ERROR: bridge shared library missing from Linux bundle:" >&2
echo " $BUNDLE_DIR/lib/libchanora_bridge.so" >&2
exit 1
fi
if [[ -f "$BUNDLE_DIR/lib/libonnxruntime.so" ]]; then
echo " ORT .so : $BUNDLE_DIR/lib/libonnxruntime.so"
else
echo " ERROR: ONNX Runtime bundle file missing after flutter build:" >&2
echo " $BUNDLE_DIR/lib/libonnxruntime.so" >&2
exit 1
fi
# ---------- 6. Package the bundle ----------
echo "[6/6] Package release tarball"
@@ -276,4 +162,4 @@ echo " target/$TARGET/release/libchanora_bridge.so"
echo " Bundle dir:"
echo " $BUNDLE_DIR/"
echo " Tarball:"
echo " $TAR_PATH"
echo " $TAR_PATH"
-18
View File
@@ -1,18 +0,0 @@
#!/usr/bin/env bash
# Source this file before local verification commands:
# source tools/dev-env.sh
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_root="$(cd "${script_dir}/.." && pwd)"
if [[ -x "${repo_root}/.flutter-home/flutter/bin/flutter" ]]; then
export PATH="${repo_root}/.flutter-home/flutter/bin:${PATH}"
elif [[ -n "${FLUTTER_HOME:-}" && -x "${FLUTTER_HOME}/bin/flutter" ]]; then
export PATH="${FLUTTER_HOME}/bin:${PATH}"
elif [[ -x "${HOME}/sdks/flutter/bin/flutter" ]]; then
export PATH="${HOME}/sdks/flutter/bin:${PATH}"
fi
if [[ -d "${HOME}/.cargo/bin" ]]; then
export PATH="${HOME}/.cargo/bin:${PATH}"
fi