]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Drop --include-directory
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 9 Feb 2023 09:01:07 +0000 (10:01 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 9 Feb 2023 14:13:30 +0000 (15:13 +0100)
Let's get rid of one more source of mounts. --include-dir can be replaced
by using --incremental and reading includes from the cached build image
tree. In the future, once build images become regular images, users can
read includes by simply using --directory output and reading includes
from the regular image output tree.

NEWS.md
mkosi.md
mkosi/__init__.py
mkosi/backend.py
mkosi/mounts.py

diff --git a/NEWS.md b/NEWS.md
index 1be4645983f770845235b77e3276d970726fa474..2b3679a83d11e0b73120b1a89a8ea62315ffda50 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -43,6 +43,8 @@
 - Removed `--source-file-transfer`, `--source-file-transfer-final`, `--source-resolve-symlinks` and
   `--source-resolve-symlinks-final` in favor of always mounting the source directory into the build image.
   `--source-file-transfer-final` might be reimplemented in the future using virtiofsd.
+- Dropped `--include-dir` option. Usage can be replaced by using `--incremental` and reading includes from
+  the cached build image tree.
 
 ## v14
 
index a59b7f185f164b95da2ee3534ca39f4f7db49feb..fc64bd40fe17436a0a3602b7b25d881d9052d4f6 100644 (file)
--- a/mkosi.md
+++ b/mkosi.md
@@ -714,18 +714,6 @@ a machine ID.
   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
index 82c80b35d551787533579c2e07f86ce8cdad484e..996ed7578e9b4cefcab5ca3e3d66ec04b32d4f05 100644 (file)
@@ -65,7 +65,7 @@ from mkosi.log import (
     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,
@@ -188,9 +188,6 @@ def mount_image(state: MkosiState, cached: bool) -> Iterator[None]:
             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
 
 
@@ -1845,13 +1842,6 @@ def create_parser() -> ArgumentParserMkosi:
         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",
@@ -2302,10 +2292,6 @@ def unlink_output(config: MkosiConfig) -> None:
             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)
@@ -2495,7 +2481,6 @@ def load_args(args: argparse.Namespace) -> MkosiConfig:
 
     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")
@@ -2622,9 +2607,6 @@ def load_args(args: argparse.Namespace) -> MkosiConfig:
     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()
 
@@ -2973,7 +2955,6 @@ def print_summary(config: MkosiConfig) -> None:
 
     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))
@@ -3357,9 +3338,6 @@ def run_build_script(state: MkosiState) -> None:
             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.
index d2a8f99abc4ed8748b3449b625d5f86b74949ae3..50f0a4a4cc304d873394d7de8b90ca33fd65f6e1 100644 (file)
@@ -289,7 +289,6 @@ class MkosiConfig:
     environment: dict[str, str]
     build_sources: Path
     build_dir: Optional[Path]
-    include_dir: Optional[Path]
     install_dir: Optional[Path]
     build_packages: list[str]
     skip_final_phase: bool
index 9bb624b3b0b27d841ed45012d242f8078d916c18..5fecc91d109b03a4666cbdd0819b31805c008156 100644 (file)
@@ -6,7 +6,7 @@ import os
 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
@@ -82,15 +82,6 @@ def mount(
         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,