From: Michael Ferrari Date: Wed, 10 Jul 2024 00:29:49 +0000 (+0200) Subject: Add `mkosi.pkgmngr` path to `PackageManagerTrees=` X-Git-Tag: v24~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff760651d880b422fbabcb6904dedee5690f33d8;p=thirdparty%2Fmkosi.git Add `mkosi.pkgmngr` path to `PackageManagerTrees=` --- diff --git a/mkosi/config.py b/mkosi/config.py index 524bca535..e7575958e 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1955,6 +1955,7 @@ SETTINGS = ( default_factory=lambda ns: ns.skeleton_trees, default_factory_depends=("skeleton_trees",), help="Use a package manager tree to configure the package manager", + paths=("mkosi.pkgmngr", "mkosi.pkgmngr.tar",), universal=True, ), diff --git a/mkosi/resources/mkosi.md b/mkosi/resources/mkosi.md index 3ce7af2ea..1a690664a 100644 --- a/mkosi/resources/mkosi.md +++ b/mkosi/resources/mkosi.md @@ -477,10 +477,16 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, the build. `PackageManagerTrees=`, `--package-manager-tree=` -: This option mirrors the above `SkeletonTrees=` option and defaults to the - same value if not configured otherwise, but installs the files to a - subdirectory of the workspace directory instead of the OS tree. This - subdirectory of the workspace is used to configure the package manager. +: Takes a comma separated list of colon separated path pairs. The first + path of each pair refers to a directory to copy into the OS tree + before invoking the package manager. This option is similar to the + `SkeletonTrees=` option, but installs the files to a subdirectory of + the workspace directory instead of the OS tree. This subdirectory of + the workspace is used to configure the package manager. If the + `mkosi.pkgmngr/` directory is found in the local directory it is used + for this purpose with the root directory as target (also see the **Files** + section below). If not configured in any way this value will default to + the same value of `SkeletonTrees=`. `mkosi` will look for the package manager configuration and related files in the configured package manager trees. Unless specified @@ -2297,6 +2303,15 @@ local directory: copied will be owned by root. To preserve ownership, use a tar archive. +* The **`mkosi.pkgmngr/`** directory or **`mkosi.pkgmngr.tar`** archive + may be used to configure the package manager without the files being + inserted into the image. If the files should be included in the image + `mkosi.skeleton/` and `mkosi.skeleton.tar` should be used instead. + + When using the directory, file ownership is not preserved: all files + copied will be owned by root. To preserve ownership, use a tar + archive. + * The **`mkosi.nspawn`** nspawn settings file will be copied into the same place as the output image file, if it exists. This is useful since nspawn looks for settings files next to image files it boots, for additional container runtime settings. diff --git a/tests/test_config.py b/tests/test_config.py index a7151fadf..b82d2ab90 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -977,6 +977,29 @@ def test_package_manager_tree(tmp_path: Path, skel: Optional[Path], pkgmngr: Opt assert conf.package_manager_trees == pkgmngr_expected +def test_paths_with_default_factory(tmp_path: Path) -> None: + """ + If both paths= and default_factory= are defined, default_factory= should not + be used when at least one of the files/directories from paths= has been found. + """ + + with chdir(tmp_path): + + Path("mkosi.skeleton.tar").touch() + _, [config] = parse_config() + + assert config.package_manager_trees == [ + ConfigTree(Path.cwd() / "mkosi.skeleton.tar", None), + ] + + Path("mkosi.pkgmngr.tar").touch() + _, [config] = parse_config() + + assert config.package_manager_trees == [ + ConfigTree(Path.cwd() / "mkosi.pkgmngr.tar", None), + ] + + @pytest.mark.parametrize( "sections,args,warning_count", [