Files
guara/scripts/make-fixtures.sh
T
Lucas RayanandClaude Sonnet 5 6328220c60
CI / Format and clippy (push) Successful in 1m57s
CI / Dependency audit (push) Successful in 13s
CI / Check desktop app (Linux) (push) Successful in 3m54s
CI / Tests (Linux) (push) Failing after 7m25s
Release / Create release (push) Successful in 6s
Release / CLI (linux-aarch64) (push) Successful in 1m48s
Release / CLI (linux-x86_64) (push) Successful in 2m39s
Release / Desktop app (linux-aarch64) (push) Successful in 10m9s
Release / Desktop app (linux-x86_64) (push) Successful in 12m20s
Release / Desktop app (windows) (push) Successful in 7m32s
Release / Build latest.json (push) Successful in 5s
chore(i18n): finish translating code comments and scripts to English
Completes the English-only standardization for code, comments, scripts
and CI templates (UI/CLI-facing strings stay bilingual pt-BR/en,
untouched). Covers the remaining crates/, apps/gui/ui/ and
apps/gui/src-tauri/ comments, .gitea/ workflow and template comments,
.githooks/ hooks, and the scripts/ source comments for the files
already renamed in a prior commit (check.sh, generate-logo.py,
install-hooks.sh).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VAyr8d7HuAdUGB6aA5xmDD
2026-10-30 20:43:02 -03:00

84 lines
3.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Generates test disk images (FAT32, exFAT, NTFS, ext4) populated with known files,
# deletes a subset of them, and writes expected SHA-256 digests to <out>/expected-<fs>.txt.
#
# Usage: scripts/make-fixtures.sh <output-dir> [fat32 exfat ntfs ext4]
# Requires (Linux): mtools, dosfstools, exfatprogs/exfat-fuse, ntfs-3g, e2fsprogs,
# imagemagick, zip, python3, and FUSE for exFAT/NTFS.
set -euo pipefail
OUT="$(realpath -m "${1:?usage: $0 <output-dir> [fs...]}")"
shift || true
FSES=("${@:-fat32 exfat ntfs ext4}")
[ $# -eq 0 ] && FSES=(fat32 exfat ntfs ext4)
mkdir -p "$OUT"
SIZE_MB=96
CONTENT="$OUT/content"
rm -rf "$CONTENT"; mkdir -p "$CONTENT/Documentos/Trabalho" "$CONTENT/Fotos"
# --- test content (mix of formats with and without file signatures) ---
convert -size 1400x900 plasma:fractal -quality 92 "$CONTENT/Fotos/praia.jpg"
convert -size 900x700 plasma:red-blue "$CONTENT/Fotos/montanha.png"
convert -size 600x400 plasma:green-yellow "$CONTENT/Fotos/mantida.jpg"
head -c 700000 /dev/urandom | base64 > "$CONTENT/Documentos/Trabalho/notas.txt"
head -c 3000000 /dev/urandom > "$CONTENT/Documentos/dados.bin"
python3 - "$CONTENT" <<'PY'
import sys, sqlite3, os
d = sys.argv[1]
pdf = b"%PDF-1.4\n" + b"".join(b"%% line %d padding %s\n" % (i, os.urandom(40).hex().encode()) for i in range(6000)) + b"trailer\n<< /Root 1 0 R >>\n%%EOF\n"
open(d + "/Documentos/Trabalho/relatorio.pdf", "wb").write(pdf)
db = d + "/Documentos/contatos.db"
c = sqlite3.connect(db)
c.execute("create table t(id integer primary key, v text)")
c.executemany("insert into t(v) values (?)", [(os.urandom(64).hex(),) for _ in range(4000)])
c.commit(); c.close()
PY
mkdir -p "$OUT/zip" && ( cd "$OUT/zip" && rm -rf * && mkdir -p word _rels && echo '<?xml version="1.0"?><Types/>' > '[Content_Types].xml' \
&& head -c 400000 /dev/urandom | base64 > word/document.xml && zip -q -r "$CONTENT/Documentos/Trabalho/tese.docx" . )
rm -rf "$OUT/zip"
# Files that will be DELETED (paths relative to $CONTENT)
DELETE=(Fotos/praia.jpg Fotos/montanha.png Documentos/Trabalho/notas.txt Documentos/Trabalho/relatorio.pdf Documentos/Trabalho/tese.docx Documentos/contatos.db Documentos/dados.bin)
write_expected() { # $1=fs
: > "$OUT/expected-$1.txt"
for f in "${DELETE[@]}"; do
echo "$(sha256sum "$CONTENT/$f" | cut -d' ' -f1) $f" >> "$OUT/expected-$1.txt"
done
}
mnt_cleanup() { fusermount -u "$1" 2>/dev/null || true; rmdir "$1" 2>/dev/null || true; }
for fs in "${FSES[@]}"; do
img="$OUT/$fs.img"
rm -f "$img"; truncate -s ${SIZE_MB}M "$img"
case $fs in
fat32)
mkfs.vfat -F 32 -n GUARATEST "$img" >/dev/null
mcopy -i "$img" -s -m "$CONTENT"/* ::
for f in "${DELETE[@]}"; do mdel -i "$img" "::/$f"; done
;;
exfat)
# Without unprivileged FUSE, only the empty filesystem is formatted here;
# the Rust test injects entries directly (see crates/guara-core/tests/exfat.rs).
mkfs.exfat -L GUARATEST "$img" >/dev/null
;;
ntfs)
# ntfscp writes to the root directory; "deleting" clears the in-use bit on the MFT
# record, matching standard NTFS deletion behavior (clusters and filename remain).
mkntfs -F -Q -L GUARATEST "$img" >/dev/null 2>&1
for f in $(cd "$CONTENT" && find . -type f | sed 's|^\./||'); do
ntfscp -f "$img" "$CONTENT/$f" "/$(basename "$f")" >/dev/null 2>&1
done
python3 "$(dirname "$0")/ntfs-mark-deleted.py" "$img" "${DELETE[@]}"
;;
ext4)
mkfs.ext4 -q -F -L GUARATEST -d "$CONTENT" "$img"
for f in "${DELETE[@]}"; do debugfs -w -R "rm /$f" "$img" >/dev/null 2>&1; done
;;
esac
write_expected "$fs"
echo "ok: $img"
done