Skip to content

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

Open
Flowdalic wants to merge 1 commit intogentoo:masterfrom
Flowdalic:pkgdiff-mg-tmpdir
Open

pkgdiff-mg: use /var/tmp instead of /tmp as default TMPDIR#19
Flowdalic wants to merge 1 commit intogentoo:masterfrom
Flowdalic:pkgdiff-mg-tmpdir

Conversation

@Flowdalic
Copy link
Copy Markdown
Member

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.

@thesamesam
Copy link
Copy Markdown
Member

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

@mgorny
Copy link
Copy Markdown
Member

mgorny commented May 27, 2023

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

@Flowdalic
Copy link
Copy Markdown
Member Author

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 Flowdalic force-pushed the pkgdiff-mg-tmpdir branch from d892fc6 to 815b442 Compare May 29, 2023 19:58
@Flowdalic
Copy link
Copy Markdown
Member Author

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

@Flowdalic
Copy link
Copy Markdown
Member Author

@mgorny friendly ping

@Flowdalic
Copy link
Copy Markdown
Member Author

@mgorny another friendly ping

@Flowdalic
Copy link
Copy Markdown
Member Author

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

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 <flow@gentoo.org>
@Flowdalic Flowdalic force-pushed the pkgdiff-mg-tmpdir branch from 7599437 to 9681cd4 Compare June 13, 2024 06:49
@Flowdalic
Copy link
Copy Markdown
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants