-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_fingerprints.sh
More file actions
63 lines (55 loc) · 1.92 KB
/
demo_fingerprints.sh
File metadata and controls
63 lines (55 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
set -euo pipefail
# Demonstrate deterministic database fingerprints persisted in build_fingerprints.
# Requires GLIMMONDATA (or SKA_DATA) to point at the glimmon archive and allows glimmondb.py to run.
CUSTOM_DIR="${1:-}"
echo "==> Ensuring environment is set (GLIMMONDATA or SKA_DATA) or custom dir provided..."
if [[ -n "${CUSTOM_DIR}" ]]; then
GLIMMON_DIR="${CUSTOM_DIR}"
elif [[ -n "${GLIMMONDATA:-}" ]]; then
GLIMMON_DIR="${GLIMMONDATA}"
elif [[ -n "${SKA_DATA:-}" ]]; then
GLIMMON_DIR="${SKA_DATA}/glimmon_archive"
else
echo "ERROR: Provide a directory argument or set GLIMMONDATA (or SKA_DATA)." >&2
exit 1
fi
GLIMMON_DIR="$(cd "${GLIMMON_DIR}" && pwd)"
DB_PATH="${GLIMMON_DIR}/glimmondb.sqlite3"
if [[ ! -f "${DB_PATH}" ]]; then
echo "ERROR: Expected database at ${DB_PATH} not found. Create or recreate it first." >&2
exit 1
fi
echo "==> Latest fingerprint (compact for ~110-char terminal):"
sqlite3 "${DB_PATH}" <<'SQL'
.headers on
.mode column
.width 8 16 16 16 12 12 8 8 8 20
SELECT version,
substr(limit_hash,1,14) || '..' AS limit_hash,
substr(state_hash,1,14) || '..' AS state_hash,
substr(version_hash,1,14) || '..' AS version_hash,
substr(db_sha256,1,12) || '..' AS db_sha,
db_size_bytes,
limit_count,
state_count,
version_count,
created_at
FROM build_fingerprints
ORDER BY version DESC
LIMIT 1;
SQL
echo "==> Latest version record:"
sqlite3 "${DB_PATH}" <<'SQL'
.headers on
.mode column
SELECT version, datesec, date FROM versions ORDER BY version DESC LIMIT 1;
SQL
LOG_PATH="${GLIMMON_DIR}/DB_Commit.log"
if [[ -f "${LOG_PATH}" ]]; then
echo "==> Recent fingerprint log entries (last few lines):"
rg -i "fingerprint|hash" -n "${LOG_PATH}" | tail -n 5 || true
else
echo "Log file not found at ${LOG_PATH}; skipping log tail."
fi
echo "==> Done. Above hashes/counts should remain identical across recreations if inputs are unchanged."