armbian-next: introduce tmpfs-utils.sh; put LOGDIR and WORKDIR under tmpfs; set CCACHE_TEMPDIR under WORKDIR

- introduce generic `prepare_tmpfs_for()`, which manages it's own cleanup/dir removal
- use it for `WORKDIR` (which is `TMPDIR`) and `LOGDIR`
  - adapt previous cleanup handlers for those, so they delete their contents but not the dir itself (which might be mounted)
- also: make `ARMBIAN_LOG_CLI_ID` readonly together with other superglobals
- set `XDG_RUNTIME_DIR` & `XDG_RUNTIME_DIR` together with `TMPDIR`
- kernel-make.sh: pass `CCACHE_TEMPDIR` down to Kernel make (thanks @the-Going)
This commit is contained in:
Ricardo Pardini
2023-01-16 16:01:42 +01:00
parent d6200a30e6
commit 2d9f9216eb
6 changed files with 129 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# This is called both early in compile.sh, but also after processing cmdline params in the cli entrypoint.sh
# This is called both early in compile.sh, but also after processing cmdline params in the cli entrypoint.sh
function logging_init() {
# defaults.
# if stdout is a terminal, then default SHOW_LOG to yes
@@ -101,10 +101,10 @@ function print_current_asset_log_base_file() {
}
function discard_logs_tmp_dir() {
# Linux allows us to be more careful, but really, those are log files we're talking about.
# Do not delete the dir itself, since it might be a tmpfs mount.
if [[ "$(uname)" == "Linux" ]]; then
rm -rf --one-file-system "${LOGDIR}"
rm -rf --one-file-system "${LOGDIR:?}"/* # Note this is protected by :?
else
rm -rf "${LOGDIR}"
rm -rf "${LOGDIR:?}"/* # Note this is protected by :?
fi
}