fix: bundle vec0.dylib in package + deploy install (4/4 M4 items)

This commit is contained in:
Accusys
2026-05-13 20:46:29 +08:00
parent e6aa45d7ea
commit edb0e0bf7a
3 changed files with 45 additions and 20 deletions

View File

@@ -21,7 +21,7 @@ echo "Time: $(date '+%Y-%m-%d %H:%M:%S')"
echo ""
# 0. Version & build compatibility check
echo "[0/8] Checking system version and build..."
echo "[0/9] Checking system version and build..."
PKG_VER=$(python3 -c "import json; f=json.load(open('$DIR/file_info.json')); print(f.get('momentry_version','?'))")
PKG_BUILD=$(python3 -c "import json; f=json.load(open('$DIR/file_info.json')); print(f.get('momentry_build','?'))")
SRV=$(curl -sf http://localhost:3003/health | python3 -c "
@@ -47,7 +47,7 @@ else
fi
# 1. Verify package integrity
echo "[1/8] Verifying package..."
echo "[1/9] Verifying package..."
REQUIRED_FILES=("data.sql" "file_info.json")
MISSING=0
for f in "${REQUIRED_FILES[@]}"; do
@@ -63,12 +63,12 @@ fi
echo " ✅ Package verified"
# 2. Pre-clean: remove existing identities for this file (avoids UNIQUE(name) conflicts on COPY)
echo "[2/8] Pre-cleaning existing identities for this file..."
echo "[2/9] Pre-cleaning existing identities for this file..."
"$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -c "DELETE FROM dev.identities WHERE file_uuid = '$UUID'" > /dev/null 2>&1
echo " ✅ Cleared identities for $UUID"
# 3. Import each table file in dependency order (FK constraints)
echo "[3/8] Importing DB data (per-table)..."
echo "[3/9] Importing DB data (per-table)..."
IMPORT_ORDER=(
"sql/dev_videos.sql"
"sql/dev_chunk.sql"
@@ -93,21 +93,21 @@ if [ -n "$VIDEO_FILE" ]; then
DEST="$DEMO_DIR/$VIDEO_NAME"
if [ ! -f "$DEST" ]; then
cp "$VIDEO_FILE" "$DEST"
echo "[4/8] Video copied: $VIDEO_NAME$DEMO_DIR"
echo "[4/9] Video copied: $VIDEO_NAME$DEMO_DIR"
else
echo "[4/8] Video already in demo dir, skipping"
echo "[4/9] Video already in demo dir, skipping"
fi
else
echo "[4/8] No video file in package, skipping"
echo "[4/9] No video file in package, skipping"
fi
# 5. Set video status to completed (package is fully processed)
echo "[5/8] Setting deployment status..."
echo "[5/9] Setting deployment status..."
"$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -c "UPDATE dev.videos SET status = 'completed' WHERE file_uuid = '$UUID'" > /dev/null 2>&1
echo " ✅ Status set to 'completed'"
# 6. Copy output files
echo "[6/8] Copying output files..."
echo "[6/9] Copying output files..."
COPIED=0
for f in "$DIR"/*.json "$DIR"/*.sqlite "$DIR"/*.sqlite; do
if [ -f "$f" ]; then
@@ -121,7 +121,16 @@ done
echo "$COPIED files copied to $OUTPUT_DIR"
# 7. Verify deployment
echo "[7/8] Verifying deployment..."
echo "[7/9] Installing vec0.dylib..."
if [ -f "$DIR/vec0.dylib" ]; then
cp "$DIR/vec0.dylib" "/tmp/vec0.dylib"
echo " ✅ vec0.dylib installed to /tmp/"
else
echo " ⚠️ vec0.dylib not found in package"
fi
# 8. Verify deployment
echo "[8/9] Verifying deployment..."
CHUNKS=$("$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -t -A -c "SELECT COUNT(*) FROM dev.chunk WHERE file_uuid='$UUID'" 2>/dev/null || echo "?")
FACES=$("$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -t -A -c "SELECT COUNT(*) FROM dev.face_detections WHERE file_uuid='$UUID'" 2>/dev/null || echo "?")
IDENTS=$("$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -t -A -c "SELECT COUNT(*) FROM dev.identities WHERE file_uuid='$UUID'" 2>/dev/null || echo "?")

View File

@@ -21,7 +21,7 @@ echo "Time: $(date '+%Y-%m-%d %H:%M:%S')"
echo ""
# 0. Version & build compatibility check
echo "[0/8] Checking system version and build..."
echo "[0/9] Checking system version and build..."
PKG_VER=$(python3 -c "import json; f=json.load(open('$DIR/file_info.json')); print(f.get('momentry_version','?'))")
PKG_BUILD=$(python3 -c "import json; f=json.load(open('$DIR/file_info.json')); print(f.get('momentry_build','?'))")
SRV=$(curl -sf http://localhost:3003/health | python3 -c "
@@ -47,7 +47,7 @@ else
fi
# 1. Verify package integrity
echo "[1/8] Verifying package..."
echo "[1/9] Verifying package..."
REQUIRED_FILES=("data.sql" "file_info.json")
MISSING=0
for f in "${REQUIRED_FILES[@]}"; do
@@ -63,12 +63,12 @@ fi
echo " ✅ Package verified"
# 2. Pre-clean: remove existing identities for this file (avoids UNIQUE(name) conflicts on COPY)
echo "[2/8] Pre-cleaning existing identities for this file..."
echo "[2/9] Pre-cleaning existing identities for this file..."
"$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -c "DELETE FROM dev.identities WHERE file_uuid = '$UUID'" > /dev/null 2>&1
echo " ✅ Cleared identities for $UUID"
# 3. Import each table file in dependency order (FK constraints)
echo "[3/8] Importing DB data (per-table)..."
echo "[3/9] Importing DB data (per-table)..."
IMPORT_ORDER=(
"sql/dev_videos.sql"
"sql/dev_chunk.sql"
@@ -93,21 +93,21 @@ if [ -n "$VIDEO_FILE" ]; then
DEST="$DEMO_DIR/$VIDEO_NAME"
if [ ! -f "$DEST" ]; then
cp "$VIDEO_FILE" "$DEST"
echo "[4/8] Video copied: $VIDEO_NAME$DEMO_DIR"
echo "[4/9] Video copied: $VIDEO_NAME$DEMO_DIR"
else
echo "[4/8] Video already in demo dir, skipping"
echo "[4/9] Video already in demo dir, skipping"
fi
else
echo "[4/8] No video file in package, skipping"
echo "[4/9] No video file in package, skipping"
fi
# 5. Set video status to completed (package is fully processed)
echo "[5/8] Setting deployment status..."
echo "[5/9] Setting deployment status..."
"$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -c "UPDATE dev.videos SET status = 'completed' WHERE file_uuid = '$UUID'" > /dev/null 2>&1
echo " ✅ Status set to 'completed'"
# 6. Copy output files
echo "[6/8] Copying output files..."
echo "[6/9] Copying output files..."
COPIED=0
for f in "$DIR"/*.json "$DIR"/*.sqlite "$DIR"/*.sqlite; do
if [ -f "$f" ]; then
@@ -121,7 +121,16 @@ done
echo "$COPIED files copied to $OUTPUT_DIR"
# 7. Verify deployment
echo "[7/8] Verifying deployment..."
echo "[7/9] Installing vec0.dylib..."
if [ -f "$DIR/vec0.dylib" ]; then
cp "$DIR/vec0.dylib" "/tmp/vec0.dylib"
echo " ✅ vec0.dylib installed to /tmp/"
else
echo " ⚠️ vec0.dylib not found in package"
fi
# 8. Verify deployment
echo "[8/9] Verifying deployment..."
CHUNKS=$("$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -t -A -c "SELECT COUNT(*) FROM dev.chunk WHERE file_uuid='$UUID'" 2>/dev/null || echo "?")
FACES=$("$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -t -A -c "SELECT COUNT(*) FROM dev.face_detections WHERE file_uuid='$UUID'" 2>/dev/null || echo "?")
IDENTS=$("$PG_BIN/psql" -U "$DB_USER" -d "$DB_NAME" -t -A -c "SELECT COUNT(*) FROM dev.identities WHERE file_uuid='$UUID'" 2>/dev/null || echo "?")

View File

@@ -537,6 +537,13 @@ async fn cmd_package(db: &PostgresDb, uuid: &str) -> Result<()> {
fs::copy(verify_src, outdir.join("verify.sh"))?;
}
// Bundle vec0.dylib for SQLite vector queries
let vec0_src = "/Users/accusys/momentry_core_0.1/scripts/vec0.dylib";
if Path::new(vec0_src).exists() {
fs::copy(vec0_src, outdir.join("vec0.dylib"))?;
println!(" vec0.dylib ({} KB)", fs::metadata(outdir.join("vec0.dylib"))?.len() / 1024);
}
// Create tar.gz
let tarball = Path::new(RELEASE_DIR).join(format!("{}_v{}.tar.gz", uuid, Utc::now().format("%Y%m%d_%H%M%S")));
let status = Command::new("tar")