Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 493154 - sys-apps/portage: trying to install files into /var/{cache,lib,lock,run}/ or /run/ should trigger a QA warning
Summary: sys-apps/portage: trying to install files into /var/{cache,lib,lock,run}/ or ...
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Portage team
: 492432 526386 (view as bug list)
Depends on:
Reported: 2013-12-02 21:13 UTC by SpanKY
Modified: 2022-04-15 09:38 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description SpanKY gentoo-dev 2013-12-02 21:13:44 UTC
packages need to be able to cope with files being deleted in these runtime state dirs, so allowing them to install anything in there at all doesn't make much sense.

we should be careful though and ignore people who just create the basedir.  i.e. ignore something like $D/var/lib/ existing but nothing underneath it.  that'll let packages like baselayout work w/out triggering a QA warning, and it means that the package is already doing the right thing -- it just needs the dir to exist, but otherwise it'll take care of seeding content inside of the dir.
Comment 1 Ben Kohler gentoo-dev 2013-12-02 21:16:31 UTC
*** Bug 492432 has been marked as a duplicate of this bug. ***
Comment 2 SpanKY gentoo-dev 2013-12-02 22:50:13 UTC
thanks, that bug has more good reasons for supporting this
Comment 3 Jonathan Callen (RETIRED) gentoo-dev 2013-12-06 03:13:08 UTC
I'm not sure that /var/lib/ or /var/cache/ are the kinds of runtime state dir that should be included; unlike /run, /var/run, and /var/lock, information in /var/lib/ is supposed to be preserved indefinately, and some trees under /var/cache/ need to be pre-created so that unpriviliged processes can create/use files under them.
Comment 4 SpanKY gentoo-dev 2013-12-09 04:43:07 UTC
(In reply to Jonathan Callen from comment #3)

yes & no.  here's the FHS spec:
"State information is generally used to preserve the condition of an application (or a group of inter-related applications) between invocations and between different instances of the same application. State information should generally remain valid after a reboot, should not be logging output, and should not be spooled data."
"/var/cache is intended for cached data from applications. Such data is locally generated as a result of time-consuming I/O or calculation. The application must be able to regenerate or restore the data. Unlike /var/spool, the cached files can be deleted without data loss. The data must remain valid between invocations of the application and rebooting the system."

that means if an app's data in there gets blown away, it needs to recover gracefully when possible.  it might mean that the user needs to manually intervene (like when mysql/psql have their databases destroyed), but daemons should recover automatically the majority of the time.

taken to the logical conclusion, packages should not be relying on the ebuild to initialize their dirs at install time.  mysql/psql packages have a pkg_config func to take care of this (re-initialize databases), but most can do it in their init.d scripts with things like `checkpath`.
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2014-10-22 07:19:41 UTC
*** Bug 526386 has been marked as a duplicate of this bug. ***
Comment 6 Xiami 2018-04-27 04:28:50 UTC
Any progress for /var/lib now?

I see TODO flags in install-qa-check.d/20runtime-directories . Should I avoid keepdir /var/lib/${PN} and doing that in init.d scripts or continue to use?
Comment 7 Larry the Git Cow gentoo-dev 2022-04-10 17:20:03 UTC
The bug has been referenced in the following commit(s):

commit 8ded447a1d194ad0190a174f7bb330417685d861
Author:     Sam James <>
AuthorDate: 2022-04-10 16:51:02 +0000
Commit:     Sam James <>
CommitDate: 2022-04-10 17:19:57 +0000

    install-qa-check.d/20runtime-directories: warn on /var/tmp too
    Signed-off-by: Sam James <>

 bin/install-qa-check.d/20runtime-directories | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 8 Larry the Git Cow gentoo-dev 2022-04-15 08:37:04 UTC
The bug has been referenced in the following commit(s):

commit bb044a3dd58f5d6ac0fa66dfe07daf3c6773480e
Author:     Sam James <>
AuthorDate: 2022-04-15 08:35:57 +0000
Commit:     Sam James <>
CommitDate: 2022-04-15 08:36:54 +0000

    sys-apps/portage: backport new QA checks; /run warning removal
    portage.git is currently undergoing a fair bit of refactoring
    and other non-trivial changes, so let's backport some useful bits.
    - Backport QA checks (eend w/o ebegin, ebegin w/o eend, /var/tmp install dir)
    - Drop obsolete /run-not-mounted warning
    Signed-off-by: Sam James <>

 sys-apps/portage/files/3.0.30-qa-checks.patch      | 137 ++++++++++
 .../portage/files/3.0.30-revert-run-warn.patch     |  64 +++++
 sys-apps/portage/portage-3.0.30-r2.ebuild          | 276 +++++++++++++++++++++
 3 files changed, 477 insertions(+)