From: Daan De Meyer Date: Mon, 3 Apr 2023 09:47:24 +0000 (+0200) Subject: Name all directory options consistenly X-Git-Tag: v15~268^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=010f0ddf3ff8a9c7d5075b7b8ccece54514067ec;p=thirdparty%2Fmkosi.git Name all directory options consistenly Use shorthand for the CLI option and longform for the config file option. --- diff --git a/mkosi.md b/mkosi.md index afeb6e8af..02ca1d28c 100644 --- a/mkosi.md +++ b/mkosi.md @@ -230,7 +230,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0", Linux, additional repositories must be passed in the form `::` (e.g. `myrepo::https://myrepo.net`). -`RepositoryDirectories`, `--repository-directory` +`RepositoryDirectories`, `--repo-dir=` : This option can (for now) only be used with RPM-based distributions and Arch Linux. It takes a comma separated list of directories containing extra repository @@ -435,7 +435,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0", root or `/usr` partition along with its Verity partition and unified kernel. -`RepartDirectory=`, `--repart-directory` +`RepartDirectory=`, `--repart-dir=` : Path to a directory containing systemd-repart partition definition files that are used when mkosi invokes systemd-repart when building a disk image. If not @@ -533,7 +533,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0", normally run during the source build process. Note that this option has no effect unless the `mkosi.build` build script honors it. -`Cache=`, `--cache=` +`CacheDirectory=`, `--cache-dir=` : Takes a path to a directory to use as package cache for the distribution package manager used. If this option is not used, but a @@ -631,7 +631,7 @@ a boolean argument: either "1", "yes", or "true" to enable, or "0", is automatically used for this purpose (also see the "Files" section below). -`InstallDirectory=`, `--install-directory=` +`InstallDirectory=`, `--install-dir=` : Takes a path of a directory to use as the install directory. The directory used this way is shared between builds and allows the @@ -1245,7 +1245,7 @@ with `mkosi.skeleton` but nothing else. re-building of images. Specifically: 1. The package cache of the distribution package manager may be cached - between builds. This is configured with the `--cache=` option or + between builds. This is configured with the `--cache-dir=` option or the `mkosi.cache/` directory. This form of caching relies on the distribution's package manager, and caches distribution packages (RPM, DEB, …) after they are downloaded, but before they are diff --git a/mkosi/__init__.py b/mkosi/__init__.py index af06c51ed..dbec4c995 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -1270,6 +1270,9 @@ class ArgumentParserMkosi(argparse.ArgumentParser): "QCow2": "--qcow2", "OutputDirectory": "--output-dir", "WorkspaceDirectory": "--workspace-dir", + "CacheDirectory": "--cache-dir", + "RepartDirectory": "--repart-dir", + "BuildDirectory": "--build-dir", "NSpawnSettings": "--settings", "CheckSum": "--checksum", "BMap": "--bmap", @@ -1281,7 +1284,7 @@ class ArgumentParserMkosi(argparse.ArgumentParser): "PostInstallationScript": "--postinst-script", "TarStripSELinuxContext": "--tar-strip-selinux-context", "SignExpectedPCR": "--sign-expected-pcr", - "RepositoryDirectories": "--repository-directory", + "RepositoryDirectories": "--repo-dir", "Credentials": "--credential", } @@ -1463,7 +1466,7 @@ def create_parser() -> ArgumentParserMkosi: help="Repositories to use", ) group.add_argument( - "--repository-directory", + "--repo-dir", action=CommaDelimitedListAction, default=[], metavar="PATH", @@ -1607,9 +1610,8 @@ def create_parser() -> ArgumentParserMkosi: help="Generate split partitions", ) group.add_argument( - "--repart-directory", + "--repart-dir", metavar="PATH", - dest="repart_dir", help="Directory containing systemd-repart partition definitions", ) group.add_argument( @@ -1681,8 +1683,7 @@ def create_parser() -> ArgumentParserMkosi: help="Enable root autologin", ) group.add_argument( - "--cache", - dest="cache_path", + "--cache-dir", help="Package cache path", type=Path, metavar="PATH", @@ -1740,21 +1741,13 @@ def create_parser() -> ArgumentParserMkosi: type=Path, ) group.add_argument( - "--build-dir", # Compatibility option - help=argparse.SUPPRESS, + "--build-dir", type=Path, metavar="PATH", - ) - group.add_argument( - "--build-directory", - dest="build_dir", help="Path to use as persistent build directory", - type=Path, - metavar="PATH", ) group.add_argument( - "--install-directory", - dest="install_dir", + "--install-dir", help="Path to use as persistent install directory", type=Path, metavar="PATH", @@ -2137,9 +2130,9 @@ def unlink_output(config: MkosiConfig) -> None: empty_directory(config.install_dir) if remove_package_cache: - if config.cache_path is not None: + if config.cache_dir is not None: with complete_step("Clearing out package cache…"): - empty_directory(config.cache_path) + empty_directory(config.cache_dir) def parse_boolean(s: str) -> bool: @@ -2201,10 +2194,10 @@ def find_builddir(args: argparse.Namespace) -> None: def find_cache(args: argparse.Namespace) -> None: subdir = f"{args.distribution}~{args.release}" - if args.cache_path is not None: - args.cache_path = Path(args.cache_path, subdir) + if args.cache_dir is not None: + args.cache_dir = Path(args.cache_dir, subdir) elif os.path.exists("mkosi.cache/"): - args.cache_path = Path("mkosi.cache", subdir) + args.cache_dir = Path("mkosi.cache", subdir) else: return @@ -2486,8 +2479,8 @@ def load_args(args: argparse.Namespace) -> MkosiConfig: args.credentials = load_credentials(args) args.kernel_command_line_extra = load_kernel_command_line_extra(args) - if args.cache_path is not None: - args.cache_path = args.cache_path.absolute() + if args.cache_dir is not None: + args.cache_dir = args.cache_dir.absolute() if args.extra_trees: for i in range(len(args.extra_trees)): @@ -2537,7 +2530,7 @@ def load_args(args: argparse.Namespace) -> MkosiConfig: die("Images built without the --bootable option cannot be booted using qemu", MkosiNotSupportedException) if args.repo_dirs and not (is_dnf_distribution(args.distribution) or args.distribution == Distribution.arch): - die("--repository-directory is only supported on DNF based distributions and Arch") + die("--repo-dir is only supported on DNF based distributions and Arch") if args.repo_dirs: args.repo_dirs = [p.absolute() for p in args.repo_dirs] @@ -2773,7 +2766,7 @@ def print_summary(config: MkosiConfig) -> None: ): print(" With Documentation:", yes_no(config.with_docs)) - print(" Package Cache:", none_to_none(config.cache_path)) + print(" Package Cache:", none_to_none(config.cache_dir)) print(" Extra Trees:", line_join_source_target_list(config.extra_trees)) print(" Skeleton Trees:", line_join_source_target_list(config.skeleton_trees)) print(" CleanPackageMetadata:", yes_no_or(config.clean_package_metadata)) @@ -2838,8 +2831,8 @@ def make_cache_dir(state: MkosiState) -> None: # If no cache directory is configured, it'll be located in the workspace which is owned by root in the # userns so we have to run as the same user. run(["mkdir", "-p", state.cache], - user=state.uid if state.config.cache_path else 0, - group=state.gid if state.config.cache_path else 0) + user=state.uid if state.config.cache_dir else 0, + group=state.gid if state.config.cache_dir else 0) def make_install_dir(state: MkosiState) -> None: @@ -3221,7 +3214,7 @@ def need_cache_tree(state: MkosiState) -> bool: def build_stuff(uid: int, gid: int, config: MkosiConfig) -> None: workspace = tempfile.TemporaryDirectory(dir=config.workspace_dir or Path.cwd(), prefix=".mkosi.tmp") workspace_dir = Path(workspace.name) - cache = config.cache_path or workspace_dir / "cache" + cache = config.cache_dir or workspace_dir / "cache" state = MkosiState( uid=uid, @@ -3260,8 +3253,8 @@ def build_stuff(uid: int, gid: int, config: MkosiConfig) -> None: calculate_signature(state) save_manifest(state, manifest) - if state.config.cache_path: - acl_toggle_remove(state.config, state.config.cache_path, state.uid, allow=True) + if state.config.cache_dir: + acl_toggle_remove(state.config, state.config.cache_dir, state.uid, allow=True) for p in state.config.output_paths(): if state.staging.joinpath(p.name).exists(): diff --git a/mkosi/backend.py b/mkosi/backend.py index d8355dbdf..a72ab70ea 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -262,7 +262,7 @@ class MkosiConfig: remove_packages: list[str] with_docs: bool with_tests: bool - cache_path: Path + cache_dir: Path extra_trees: list[tuple[Path, Optional[Path]]] skeleton_trees: list[tuple[Path, Optional[Path]]] clean_package_metadata: Union[bool, str] diff --git a/mkosi/distributions/openmandriva.py b/mkosi/distributions/openmandriva.py index 91ebb2e30..08a0ab1ec 100644 --- a/mkosi/distributions/openmandriva.py +++ b/mkosi/distributions/openmandriva.py @@ -10,10 +10,6 @@ from mkosi.log import complete_step class OpenmandrivaInstaller(DistributionInstaller): - @classmethod - def cache_path(cls) -> list[str]: - return ["var/cache/dnf"] - @classmethod def filesystem(cls) -> str: return "ext4"