mgorny-dev-scripts icon indicating copy to clipboard operation
mgorny-dev-scripts copied to clipboard

pkgdiff-mg: use /var/tmp instead of /tmp as default TMPDIR

Open Flowdalic opened this issue 2 years ago • 8 comments

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.

Flowdalic avatar May 27 '23 11:05 Flowdalic

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 ;)

thesamesam avatar May 27 '23 11:05 thesamesam

The problem is, /tmp will get cleaned up on next boot while /var/tmp will clutter on until someone cleans it up.

mgorny avatar May 27 '23 15:05 mgorny

The problem is, /tmp will get cleaned up on next boot while /var/tmp will 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?

Flowdalic avatar May 29 '23 07:05 Flowdalic

Pushed version that considers if the script run on a systemd system.

Flowdalic avatar Jun 02 '23 06:06 Flowdalic

@mgorny friendly ping

Flowdalic avatar Jul 01 '23 17:07 Flowdalic

@mgorny another friendly ping

Flowdalic avatar Jul 31 '23 09:07 Flowdalic

@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).

Flowdalic avatar Sep 27 '23 15:09 Flowdalic

@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.

Flowdalic avatar Jun 13 '24 11:06 Flowdalic