diff --git a/docs/fhs-mapping.md b/docs/fhs-mapping.md index 52b3974305..12d969d45b 100644 --- a/docs/fhs-mapping.md +++ b/docs/fhs-mapping.md @@ -101,15 +101,28 @@ Hosts/resolv têm pipeline próprio (script `network-base-setup` lê - `timezone` → **Fase 7** (referenciado em patch do systemd; mover requer ajuste no patch) - `debug.archr` → **Fase 7** (stamp file trivial) -### Fase 3 — Class F + G: logs e temp (13 paths) +### Fase 3 — Class F + G: logs e temp -**Objetivo:** alinhar com convenção `/var/log` e `/var/tmp`. +**Status: concluída (2026-06-23).** Logs viram `/var/log/*` (que já é mount unit redirecionando para `/storage/.cache/log`); update vira `/var/cache/archr/update` via bridge symlink; overlayfs workdirs e bootloader handshake ficam no backing path por constraint de arquitetura. -- `/storage/.cache/log/journal` → `/var/log/journal` (já é convenção systemd) -- `/storage/.cache/log/runemu-debug.log` → `/var/log/archr/runemu-debug.log` -- `/storage/logfiles/` → `/var/log/archr/` -- `/storage/.tmp/*-workdir` → `/var/tmp/archr/*-workdir` -- `/storage/.update/` → `/var/cache/archr/update/` +| Path | Destino | Mecanismo | +|------|---------|-----------| +| `/storage/.cache/log/journal` | `/var/log/journal` | `var-log.mount` já existente (no-op) | +| `/storage/.cache/log/runemu-debug.log` | `/var/log/runemu-debug.log` | runemu.sh aponta direto pro `/var/log` (mount entrega) | +| `/storage/logfiles` | `/var/log/archr/archive` | createlog escreve via mount; tmpfiles cria backing | +| `/storage/.update` | `/var/cache/archr/update` | bridge symlink; consumers userland atualizados | + +**Permanecem no backing path por design:** + +- `/storage/.tmp/*-workdir` (assets, cores, database, games, joypads, overlays, shaders): são *workdirs* de `overlayfs` montados em `system.d/tmp-*.mount` units. O kernel exige que `upperdir` e `workdir` estejam no mesmo filesystem; como `upperdir=/storage/`, o `workdir` tem que ficar no mesmo `/storage`. Mover para `/var/tmp/archr` quebraria os 6 mount units de assets/cores/database/joypads/overlays/shaders do RetroArch. No-op. +- `/storage/.boot.hint`: arquivo de handshake entre o bootloader U-Boot e o sistema rodando, gravado pré-boot pelo bootloader e lido por `autostart/003-upgrade`. Compartilhar via FHS exigiria mexer no script u-boot, fora de escopo. No-op. + +**Pré-boot keep-as-is:** +- `busybox/scripts/init` (initramfs UPDATE_ROOT) +- `devices/RK3326/bootloader/update.sh` (escreve `.boot.hint`) +- `tmpfiles z_01_busybox.conf` (cria backing dirs) + +Userland tudo usa o path Arch-friendly. ### Fase 4 — Class D: state/data persistente (37 paths) @@ -194,5 +207,5 @@ Migration scripts ficam em `projects/ArchR/packages/archr/sources/post-update.d/ - [x] Fase 0 concluída (2026-06-23): `010-archr-fhs` em `/etc/profile.d`, archr(7) com seção ENVIRONMENT, vars apontando para `/storage/...`. Risco zero. - [x] Fase 1 marcada como no-op (2026-06-23): systemd já entrega `/etc/{modules-load.d,sysctl.d,tmpfiles.d,udev/{hwdb,rules}.d,systemd/*conf.d}` via symlinks de build-time. FHS-correto sem mudança. Detalhes na seção da Fase 1 deste documento. - [x] Fase 2 concluída (2026-06-23): 5 caches realmente regeneráveis migrados via bridge symlinks (mesa, fontconfig, kernel-overlays, locpath, fstrim.run). Paths state/log realocados para F3/F4. Detalhes na Fase 2. -- [ ] Fase 3 — não iniciada (Class F+G: logs e temp). +- [x] Fase 3 concluída (2026-06-23): logs reaproveitam `var-log.mount` (/var/log = /storage/.cache/log), update bridged via `/var/cache/archr/update`, overlayfs workdirs e bootloader handshake permanecem no backing path por constraint. - [ ] Fase 4..7 — não iniciadas. diff --git a/packages/sysutils/busybox/scripts/createlog b/packages/sysutils/busybox/scripts/createlog index 1b2319e82b..090516bde4 100755 --- a/packages/sysutils/busybox/scripts/createlog +++ b/packages/sysutils/busybox/scripts/createlog @@ -177,8 +177,10 @@ mkdir -p $BASEDIR/$LOGDIR done # pack logfiles - mkdir -p /storage/logfiles - zip -jq /storage/logfiles/log-$DATE.zip $BASEDIR/$LOGDIR/* + # /var/log is /storage/.cache/log via var-log.mount on ArchR; lands on + # the rw overlay through the FHS path. + mkdir -p /var/log/archr/archive + zip -jq /var/log/archr/archive/log-$DATE.zip $BASEDIR/$LOGDIR/* # remove logdir rm -rf ${BASEDIR:?}/$LOGDIR diff --git a/projects/ArchR/packages/archr/package.mk b/projects/ArchR/packages/archr/package.mk index 5af1ca6bf8..bbaffc5a41 100644 --- a/projects/ArchR/packages/archr/package.mk +++ b/projects/ArchR/packages/archr/package.mk @@ -58,6 +58,10 @@ EOF # both `touch /var/cache/archr/fstrim.run` (writes through) and # readers checking the stamp. ln -sf /storage/.cache/fstrim.run ${INSTALL}/var/cache/archr/fstrim.run + # Image-based updates: backing path /storage/.update is what the + # pre-boot bootloader scripts know about and cannot move; userland + # tooling reads/writes through the FHS bridge. + ln -sf /storage/.update ${INSTALL}/var/cache/archr/update } post_install() { diff --git a/projects/ArchR/packages/archr/sources/scripts/archr-update b/projects/ArchR/packages/archr/sources/scripts/archr-update index 7124053e38..4dfb9e5016 100755 --- a/projects/ArchR/packages/archr/sources/scripts/archr-update +++ b/projects/ArchR/packages/archr/sources/scripts/archr-update @@ -85,17 +85,17 @@ main_update() { exit 1 fi - # Ensure that the /storage/.update folder exists. - if [ ! -d "/storage/.update" ]; then - mkdir -p /storage/.update || { echo "Failed to create /storage/.update directory."; exit 1; } + # Ensure that the /var/cache/archr/update folder exists. + if [ ! -d "/var/cache/archr/update" ]; then + mkdir -p /var/cache/archr/update || { echo "Failed to create /var/cache/archr/update directory."; exit 1; } fi # Extract the file name from the update URL. filename=$(basename "$update_url") - # Define download destinations inside /storage/.update folder using the original file names. - update_file="/storage/.update/${filename}" - checksum_file="/storage/.update/${filename}.sha256" + # Define download destinations inside /var/cache/archr/update folder using the original file names. + update_file="/var/cache/archr/update/${filename}" + checksum_file="/var/cache/archr/update/${filename}.sha256" # Download the update file. echo "Downloading update file..." diff --git a/projects/ArchR/packages/archr/sources/scripts/automount b/projects/ArchR/packages/archr/sources/scripts/automount index 1354242f65..4f97c3bd62 100755 --- a/projects/ArchR/packages/archr/sources/scripts/automount +++ b/projects/ArchR/packages/archr/sources/scripts/automount @@ -6,7 +6,7 @@ . /etc/os-release ### Vars -UPDATE_ROOT="/storage/.update" +UPDATE_ROOT="/var/cache/archr/update" MOUNT_GAMES=$(get_setting system.automount) GAMES_DEVICE=$(get_setting system.gamesdevice) MS_PATH="/storage/roms" diff --git a/projects/ArchR/packages/archr/sources/scripts/factoryreset b/projects/ArchR/packages/archr/sources/scripts/factoryreset index 2f7851a382..6a079e1b02 100755 --- a/projects/ArchR/packages/archr/sources/scripts/factoryreset +++ b/projects/ArchR/packages/archr/sources/scripts/factoryreset @@ -78,6 +78,9 @@ case "${1}" in umount /storage/roms 2>/dev/null ||: umount /storage/games-external 2>/dev/null ||: cd / + # /storage/.update is the backing path that the pre-boot bootloader + # scripts know about; preserve it by the real path (the FHS bridge + # /var/cache/archr/update points at the same dir). find /storage -mindepth 1 \( ! -regex '^/storage/.update.*' -a ! -regex '^/storage/roms.*' -a ! -regex '^/storage/games-.*' \) -delete 2>/dev/null mkdir /storage/.config/ sync 2>/dev/null diff --git a/projects/ArchR/packages/archr/sources/scripts/runemu.sh b/projects/ArchR/packages/archr/sources/scripts/runemu.sh index 57974e0e3c..686dad3872 100755 --- a/projects/ArchR/packages/archr/sources/scripts/runemu.sh +++ b/projects/ArchR/packages/archr/sources/scripts/runemu.sh @@ -10,8 +10,10 @@ ### Shell trace + persistent debug log are gated by system.loglevel=verbose. ### Default (off/none/quiet) writes nothing to microSD on launch. +### /var/log is mounted from /storage/.cache/log by var-log.mount, so +### /var/log/runemu-debug.log lands on the rw overlay and survives. if [ "$(get_setting system.loglevel)" = "verbose" ]; then - RUNEMU_DEBUG="/storage/.cache/log/runemu-debug.log" + RUNEMU_DEBUG="/var/log/runemu-debug.log" mkdir -p "$(dirname "${RUNEMU_DEBUG}")" exec 2>>"${RUNEMU_DEBUG}" set -x diff --git a/projects/ArchR/packages/network/samba/config/smb.conf b/projects/ArchR/packages/network/samba/config/smb.conf index aeef16df6e..85d89085aa 100644 --- a/projects/ArchR/packages/network/samba/config/smb.conf +++ b/projects/ArchR/packages/network/samba/config/smb.conf @@ -50,11 +50,13 @@ # writeable shares of disks and paths under /storage [update] - path = /storage/.update + path = /var/cache/archr/update available = yes browseable = yes public = yes writeable = yes + follow symlinks = yes + wide links = yes [games-roms] path = /storage/roms diff --git a/projects/ArchR/packages/sysutils/systemd/tmpfiles.d/z_01_archr.conf b/projects/ArchR/packages/sysutils/systemd/tmpfiles.d/z_01_archr.conf index e6d7eadba8..d408d0b20e 100644 --- a/projects/ArchR/packages/sysutils/systemd/tmpfiles.d/z_01_archr.conf +++ b/projects/ArchR/packages/sysutils/systemd/tmpfiles.d/z_01_archr.conf @@ -6,4 +6,8 @@ d /run/archr/debug 0755 root root - - d /run/dbus 0755 root root - - d /storage/.cache/rfkill 0755 root root - - d /storage/.cache/mesa_shader_cache 0755 root root - - +# /var/log is /storage/.cache/log via var-log.mount; this creates the +# archive subdir for createlog's log-DATE.zip dumps in an FHS-friendly +# place. The trailing /var/log/archr path is what users and samba see. +d /storage/.cache/log/archr/archive 0755 root root - - L+ /var/lib/systemd/rfkill - - - - /storage/.cache/rfkill