testsAndMisc/linux_configuration/scripts/mtk_root/lib/dump_verify.sh
Krzysztof kuhy Rudnicki 7e967de79b
Some checks are pending
Pre-commit checks / pre-commit (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Split seven more linux_configuration scripts
10-recon.sh, install_exercism.sh, fix_arch_performance.sh,
format_sd_card.sh, setup_dot_resolver.sh, fix_unity.sh and
20-dump-stock.sh, all now under the cap.

Splitting a file twice is the risky move: the second cut on
20-dump-stock.sh dropped the first cut's source line, leaving
verify_dump called but never defined, and the repair then landed the
line inside the lib instead of the entry script. Both fixed - the entry
sources both libs and no lib sources another. Grep the source lines
after any double split.

fix_unity.sh's desktop_dir is read across the seam; renamed to
DESKTOP_DIR to match the file's own convention for globals.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 18:56:05 +02:00

32 lines
956 B
Bash
Executable File

#!/bin/bash
# Dump verification and reporting for the stock partition dump.
#
# Sourced by 20-dump-stock.sh; split out to keep it under the 250-line cap.
# Sourced rather than run, so it inherits the caller's strict mode and
# the helper functions and variables defined above the source line.
verify_dump() {
local label="$1" path="$2"
local size="" verdict="" sha=""
if [[ ! -f $path ]]; then
mtk_error "${label}: no file produced at ${path}"
return 1
fi
size="$(mtk_file_size "$path")"
sha="$(mtk_sha256 "$path")"
if verdict="$(mtk_sane_ramdisk_size "$size")"; then
mtk_info "${label}: ${verdict}, sha256 ${sha}"
else
# mtkclient exits 0 on a truncated read, so size is the only signal that
# something went wrong short of parsing the image.
mtk_warn "${label}: ${verdict}"
mtk_warn "${label}: sha256 ${sha}"
mtk_warn "Inspect this image before trusting it as a backup."
return 1
fi
return 0
}