is automatically used for this purpose (also see the "Files" section
below).
-`IncludeDirectory=`, `--include-directory=`
-
-: Takes a path of a directory to use as the include directory. This
- directory is mounted at `/usr/include` when building the build image
- and running the build script. This means all include files installed
- to `/usr/include` will be stored in this directory. This is useful
- to make include files available on the host system for use by
- language servers to provide code completion. If this option is not
- specified, but a directory `mkosi.includedir/` exists in the local
- directory, it is automatically used for this purpose (also see the
- "Files" section below).
-
`InstallDirectory=`, `--install-directory=`
: Takes a path of a directory to use as the install directory. The
warn,
)
from mkosi.manifest import Manifest
-from mkosi.mounts import dissect_and_mount, mount_bind, mount_overlay, scandir_recursive
+from mkosi.mounts import dissect_and_mount, mount_overlay, scandir_recursive
from mkosi.remove import unlink_try_hard
from mkosi.run import (
become_root,
workdir.mkdir()
stack.enter_context(mount_overlay(base, state.root, workdir, state.root))
- if state.do_run_build_script and state.config.include_dir and not cached:
- stack.enter_context(mount_bind(state.config.include_dir, state.root / "usr/include"))
-
yield
type=Path,
metavar="PATH",
)
- group.add_argument(
- "--include-directory",
- dest="include_dir",
- help="Path to use as persistent include directory",
- type=Path,
- metavar="PATH",
- )
group.add_argument(
"--install-directory",
dest="install_dir",
with complete_step("Clearing out build directory…"):
empty_directory(config.build_dir)
- if config.include_dir is not None:
- with complete_step("Clearing out include directory…"):
- empty_directory(config.include_dir)
-
if config.install_dir is not None:
with complete_step("Clearing out install directory…"):
empty_directory(config.install_dir)
args_find_path(args, "nspawn_settings", "mkosi.nspawn")
args_find_path(args, "build_script", "mkosi.build")
- args_find_path(args, "include_dir", "mkosi.includedir/")
args_find_path(args, "install_dir", "mkosi.installdir/")
args_find_path(args, "postinst_script", "mkosi.postinst")
args_find_path(args, "prepare_script", "mkosi.prepare")
if args.build_dir is not None:
args.build_dir = args.build_dir.absolute()
- if args.include_dir is not None:
- args.include_dir = args.include_dir.absolute()
-
if args.install_dir is not None:
args.install_dir = args.install_dir.absolute()
print(" Build Sources:", config.build_sources)
print(" Build Directory:", none_to_none(config.build_dir))
- print(" Include Directory:", none_to_none(config.include_dir))
print(" Install Directory:", none_to_none(config.install_dir))
print(" Build Packages:", line_join_list(config.build_packages))
print(" Skip final phase:", yes_no(config.skip_final_phase))
bwrap += ["--bind", state.config.build_dir, "/work/build"]
env |= dict(BUILDDIR="/work/build")
- if state.config.include_dir is not None:
- bwrap += ["--bind", state.config.include_dir, "/usr/include"]
-
cmd = ["setpriv", f"--reuid={state.uid}", f"--regid={state.gid}", "--clear-groups", f"/work/{state.config.build_script.name}"]
# When we're building the image because it's required for another verb, any passed arguments are
# most likely intended for the target verb, and not for "build", so don't add them in that case.
import stat
from collections.abc import Iterator, Sequence
from pathlib import Path
-from typing import Callable, ContextManager, Deque, Optional, TypeVar, Union, cast
+from typing import Callable, Deque, Optional, TypeVar, Union, cast
from mkosi.log import complete_step
from mkosi.run import run
run(["umount", "--no-mtab", "--recursive", where])
-def mount_bind(what: Path, where: Optional[Path] = None, read_only: bool = False) -> ContextManager[Path]:
- if where is None:
- where = what
-
- os.makedirs(what, 0o755, True)
- os.makedirs(where, 0o755, True)
- return mount(what, where, operation="--bind")
-
-
@contextlib.contextmanager
def mount_overlay(
lower: Path,