TMPDIR, bitbake v posix
Hi
When some task uses mktemp(1) or similar functionality (e.g. the python tempfile module) to create a temporary file or dir, those end up being created in the global /tmp directory. That's obviously not ideal, as those might be left behind in case of an unclean shutdown or if the script is not properly written, and won't be cleaned by do_clean or RM_WORK. Also, /tmp is often a tmpfs instance, while some tasks might want to create rather large temporary files.
Most such utilities/interfaces respect the TMPDIR environment variable, if set. However, since that name is used by bitbake for a rather central concept, one cannot simply 'export TMPDIR', as one doesn't want that top-level build dir polluted by random build files, and it still wouldn't be removed by do_clean or RM_WORK. Ideally, all tasks would have a TMPDIR _environment_ variable set to something below ${WORKDIR}, maybe even something unique per task (say ${T}/${taskname}.d). But there's no simple way to do that that doesn't conflict with bitbake's use of the TMPDIR name.
Can we do anything about this?
(1) Do nothing, live with this limitation.
(2) Special-case TMPDIR, so that all tasks are created with a proper value of TMPDIR in the environment, not derived from the bitbake variable of the same name. Could be settable with some new TASK_TMPDIR or do_foo[tmpdir] flag. Somewhat hacky, though.
(3) Bite the bullet and plan for renaming TMPDIR -> BBTMPDIR, so that the TMPDIR name becomes available for use with its standard POSIX meaning. Obviously a huge thing to do, but hopefully most direct TMPDIR references are in core or bitbake and used for deriving other standard variables.
Something like meta-oe's references to ${TMPDIR}/hosttools could/should just be replaced by ${HOSTTOOLS_DIR}. Grepping around, there are also a few places that reference ${TMPDIR}/work-shared, and core could expose a name for that location as well that other meta-layers could use, again isolating them from an eventual TMPDIR->BBTMPDIR rename.
(4) ??
Rasmus