Skip to content

Commit 7599437

Browse files
committed
pkgdiff-mg: under systemd use /var/tmp as default TMPDIR
pkgdiff can cause large files in the used temprorary directory that are not cleaned up on exit. Using /tmp for those, which is often a tmpfs, which means that the files consume main memory at first. Later the system may move the unused files on the tmpfs into swap. Under systemd, using /var/tmp for files that are not deleted by the creator, which is pkgdiff-mg in our case, is safe, since systemd will automatically delete old unused files from /var/tmp. Signed-off-by: Florian Schmaus <[email protected]>
1 parent 153fafa commit 7599437

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkgdiff-mg

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ cat2=$(get_category "${2}")
3232
fn1=${1##*/}
3333
fn2=${2##*/}
3434

35-
export PORTAGE_TMPDIR="${TMPDIR:-/tmp}"/mgorny-dev-scripts
35+
DEFAULT_TMPDIR=/tmp
36+
if [[ -d /run/systemd/system ]]; then
37+
# System booted via systemd, which automatically cleans up stale
38+
# files in /var/tmp.
39+
DEFAULT_TMPDIR=/var/tmp
40+
fi
41+
export PORTAGE_TMPDIR="${TMPDIR:-${DEFAULT_TMPDIR}}"/mgorny-dev-scripts
3642
export USE="${USE} test"
3743
mkdir -p "${PORTAGE_TMPDIR}"
3844
ebuild "${1}" unpack

0 commit comments

Comments
 (0)