Files
qingjian/apps/linux/scripts/package.sh
T
yenharvey 5e48eb19a4 chore(release): 语言模型与含章·通变改从模型仓库取,停用 data-vN
之前 lm.qj 和含章·通变装在主仓库的 data-vN 数据包里,由 data.lock 钉住,
换一个文件就要重打整包、发新号。
现在两者在 qingjian-models 各自发版(lm-v1.0.0、hanzhang-tongbian-v1.0.0),
tools/release/models.lock 钉住标签与压缩包的 SHA-256,models-fetch.py 按 manifest 逐块下载、拼回核对后解到原来的位置。
data-fetch.sh 依次调 models-fetch.py 与 dicts-fetch.py,两者共用 mirror.py(Gitee 与 GitHub 同时请求、先回来的用)。
删掉 data.lock 与 data-bundle.sh;build-info.json 改记 lm.qj 与通变的摘要。
mac 打包每次按锁文件取语言模型,不再按 TSV 新旧自行重打;Linux 预编译包带模型缓存,安装时不联网解开。
lm-v1.0.0 与通变都和 data-v10 里的同一份字节。

测试:本机 data-fetch 全取一遍并核对;mac pkg 里的 lm.qj 与发版那份一致;Linux files.py resources 与模拟离线安装通过。Windows build.ps1 与 release.yml 没跑。
2026-11-10 15:18:30 +08:00

37 lines
2.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# //! 打预编译包 target/linux-package/qingjian-<版本>-linux-<cpu>.tar.gz:Server、设置程序、Fcitx5 插件、产品数据与安装脚本。
# //! 先跑 tools/release/data-fetch.sh;包里按仓库相对路径放文件,解开后的 install.sh 与源码安装共用 files.py 的清单与校验。
set -euo pipefail
root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../../.." && pwd)
cd "$root"
version=$(sed -n 's/^version = "\(.*\)"/\1/p' apps/linux/server/Cargo.toml | head -1)
if [[ "$version" == *-dev ]]; then
version+="-$(git rev-parse --short=7 HEAD)"
git diff --quiet HEAD || version+='+'
fi
tools/release/data-fetch.sh --verify
[[ -f data/models/hanzhang-tongbian/hanzhang-tongbian-small.qjm && -f data/generated/dict.qj ]] || { echo '缺少产品数据或含章模型,先运行 tools/release/data-fetch.sh' >&2; exit 1; }
cargo_output=$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' "${CARGO_TARGET_DIR:-$root/target}")
cargo build --release --locked -p qingjian-linux-server -p qingjian-settings --target-dir "$cargo_output"
cmake_output="$root/target/fcitx5-package"
cmake -S apps/linux/fcitx5 -B "$cmake_output" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
cmake --build "$cmake_output" --parallel "${CMAKE_BUILD_PARALLEL_LEVEL:-2}"
name="qingjian-$version-linux-$(uname -m)"
out="$root/target/linux-package"
stage="$out/$name"
rm -rf "$stage" "$out/$name.tar.gz"
mkdir -p "$stage/bin" "$stage/lib"
install -m 755 "$cargo_output/release/qingjian-linux-server" "$cargo_output/release/qingjian-settings" "$stage/bin/"
install -m 755 "$cmake_output/qingjian.so" "$stage/lib/"
install -m 755 apps/linux/scripts/package-install.sh "$stage/install.sh"
install -m 755 apps/linux/scripts/uninstall.sh "$stage/"
install -m 644 apps/linux/scripts/files.py "$stage/"
# 产品数据只带下载缓存,install.sh 装前不联网解开(files.py 按 dicts.lock / models.lock 校验缓存与解出的文件)
cp -r --parents LICENSE apps/settings/linux assets/icon/linux/hicolor assets/stroke/LICENSE-CNS11643.txt apps/linux/fcitx5/data assets/sample assets/levels assets/emoji \
tools/release/mirror.py tools/release/dicts.lock tools/release/dicts-fetch.py target/release-data/dicts \
tools/release/models.lock tools/release/models-fetch.py target/release-data/models "$stage/"
tar -C "$out" -czf "$out/$name.tar.gz" "$name"
echo "已打包:$out/$name.tar.gz"