)
from mkosi.sysupdate import run_sysupdate
from mkosi.tree import copy_tree, make_tree, move_tree, rmtree
-from mkosi.user import become_root_cmd
+from mkosi.user import INVOKING_USER, become_root_cmd
from mkosi.util import (
PathString,
current_home_dir,
def run_verb(args: Args, images: Sequence[Config], *, resources: Path) -> None:
images = list(images)
+ if args.verb == Verb.init:
+ copy_tree(resources / "tmpfiles.d", INVOKING_USER.tmpfiles_dir(), preserve=False)
+ log_notice(f"Copied mkosi tmpfiles dropins to {INVOKING_USER.tmpfiles_dir()}")
+ return
+
if args.verb == Verb.completion:
return print_completion(args, resources=resources)
completion = enum.auto()
sysupdate = enum.auto()
sandbox = enum.auto()
+ init = enum.auto()
def supports_cmdline(self) -> bool:
return self in (
Verb.documentation,
Verb.dependencies,
Verb.completion,
+ Verb.init,
)
# the synopsis below is supposed to be indented by two spaces
usage="\n "
+ textwrap.dedent("""\
- mkosi [options…] {b}summary{e}
+ mkosi [options…] {b}init{e}
+ mkosi [options…] {b}summary{e}
mkosi [options…] {b}cat-config{e}
mkosi [options…] {b}build{e} [-- command line…]
mkosi [options…] {b}shell{e} [-- command line…]
# SYNOPSIS
+`mkosi [options…] init`
+
`mkosi [options…] summary`
`mkosi [options…] cat-config`
The following command line verbs are known:
+`init`
+: Initialize **mkosi**. This is a one time operation that sets up various
+ config files required for an optimal experience. Currently this only
+ initialized a `tmpfiles.d` dropin for the mkosi package cache
+ directory to make sure old, unused files are cleaned up
+ automatically.
+
`summary`
: Show a human-readable summary of all options used for building the images.
This will parse the command line and configuration files, but only print
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+d %C/mkosi - - - 90d
return d
+ @classmethod
+ def tmpfiles_dir(cls) -> Path:
+ config = Path(os.getenv("XDG_CONFIG_HOME", Path.home() / ".config"))
+ if config in (Path("/"), Path("/root")):
+ return Path("/etc/tmpfiles.d")
+
+ return config / "user-tmpfiles.d"
+
@classmethod
def chown(cls, path: Path) -> None:
# If we created a file/directory in a parent directory owned by a regular user, make sure the path
"mkosi-tools/**/*",
"mkosi-vm/**/*",
"repart/**/*",
+ "tmpfiles.d/*",
]
[tool.isort]