mgorny-dev-scripts
mgorny-dev-scripts copied to clipboard
pkgdiff-mg: use /var/tmp instead of /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.
In any case, using /var/tmp instead of /tmp as default TMPDIR for pkgdiff-mg is sensible. As a genral rule of thumb, /tmp should be used for smaller, size bounded files only; /var/tmp for everything else.
Heh, I've been bitten by this a few times, actually (e.g. Chromium and such stack up).
Maybe we should even install a tmpfiles.d snippet in the ebuild for the new location ;)
The problem is, /tmp will get cleaned up on next boot while /var/tmp will clutter on until someone cleans it up.
The problem is,
/tmpwill get cleaned up on next boot while/var/tmpwill clutter on until someone cleans it up.
systemd systems will typically automatically clean up /var/tmp. How about we add some logic to detect if systemd is installed and running, and then use /var/tmp and otherwise keep the current behavior?
Pushed version that considers if the script run on a systemd system.
@mgorny friendly ping
@mgorny another friendly ping
@mgorny and another friendly ping.
I've updated to systemd check to be even more lightweight, by checking for the /run/systemd/system directory (inspired by systemd.eclass).
@mgorny ping, please consider this (or close this PR).
I've been using this for a while now on all my (systemd) dev machines and like to avoid having it to put it in /etc/portage/patches but rather have it upstream.