ci: cache verified sqlite native asset

This commit is contained in:
2026-08-21 13:32:43 +08:00
parent ef35dc748a
commit 9f87914235
Vendored
+39
View File
@@ -111,6 +111,45 @@ PY
stage('Build arm64 Internal Release') {
steps {
dir('frontend') {
sh '''
set -euo pipefail
# sqlite3 native hooks use a workspace-local cache, which cleanWs
# removes. Prime it from a verified node-local cache so a transient
# GitHub connection failure cannot waste an entire Gradle build.
sqlite_package_dir=$(python3 - <<'PY'
import json, pathlib, urllib.parse
config = json.loads(pathlib.Path('.dart_tool/package_config.json').read_text(encoding='utf-8'))
package = next(item for item in config['packages'] if item['name'] == 'sqlite3')
uri = urllib.parse.urlparse(package['rootUri'])
if uri.scheme != 'file':
raise SystemExit(f"unexpected sqlite3 package URI: {package['rootUri']}")
print(pathlib.Path(urllib.parse.unquote(uri.path)).resolve())
PY
)
sqlite_asset='libsqlcipher.arm64.android.so'
sqlite_hash=$(sed -n "s/.*'$sqlite_asset': '\\([0-9a-f]\\{64\\}\\)'.*/\\1/p" \
"$sqlite_package_dir/lib/src/hook/asset_hashes.dart")
test "${#sqlite_hash}" -eq 64
sqlite_cache_dir="/home/nanxunai/.cache/jizhang/sqlite3/$sqlite_hash"
sqlite_cache_file="$sqlite_cache_dir/libsqlcipher.so"
sqlite_cache_tmp="$sqlite_cache_file.tmp"
mkdir -p "$sqlite_cache_dir"
if ! printf '%s %s\n' "$sqlite_hash" "$sqlite_cache_file" | sha256sum -c -; then
rm -f "$sqlite_cache_tmp"
sqlite_release=$(basename "$sqlite_package_dir")
curl --fail --location --retry 8 --retry-all-errors --retry-delay 3 \
--connect-timeout 20 --max-time 600 \
--output "$sqlite_cache_tmp" \
"https://github.com/simolus3/sqlite3.dart/releases/download/$sqlite_release/$sqlite_asset"
printf '%s %s\n' "$sqlite_hash" "$sqlite_cache_tmp" | sha256sum -c -
mv -f "$sqlite_cache_tmp" "$sqlite_cache_file"
fi
sqlite_hook_dir=".dart_tool/hooks_runner/shared/sqlite3/build/download-${sqlite_hash:0:8}"
mkdir -p "$sqlite_hook_dir"
cp "$sqlite_cache_file" "$sqlite_hook_dir/libsqlcipher.so"
'''
retry(3) {
sh '''
set -euo pipefail