From: Daan De Meyer Date: Thu, 9 Feb 2023 09:01:07 +0000 (+0100) Subject: Drop --include-directory X-Git-Tag: v15~340 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a44afafded4e35f744f8e63743da44bf17d5e77e;p=thirdparty%2Fmkosi.git Drop --include-directory 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. --- diff --git a/NEWS.md b/NEWS.md index 1be464598..2b3679a83 100644 --- 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 diff --git a/mkosi.md b/mkosi.md index a59b7f185..fc64bd40f 100644 --- 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 diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 82c80b35d..996ed7578 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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. diff --git a/mkosi/backend.py b/mkosi/backend.py index d2a8f99ab..50f0a4a4c 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -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 diff --git a/mkosi/mounts.py b/mkosi/mounts.py index 9bb624b3b..5fecc91d1 100644 --- a/mkosi/mounts.py +++ b/mkosi/mounts.py @@ -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,