]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add `mkosi.pkgmngr` path to `PackageManagerTrees=`
authorMichael Ferrari <nekkodroid404@gmail.com>
Wed, 10 Jul 2024 00:29:49 +0000 (02:29 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 10 Jul 2024 08:27:35 +0000 (10:27 +0200)
mkosi/config.py
mkosi/resources/mkosi.md
tests/test_config.py

index 524bca5351391cf3c0849cce4378d78990999a7a..e7575958ef9ba31e6bf028989152e1d2e1cc226d 100644 (file)
@@ -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,
     ),
 
index 3ce7af2ead355692e95eba433d43a2f748f92470..1a690664a5347604623a0665b7cf8964633fbe1b 100644 (file)
@@ -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.
index a7151fadfd0c75e758a192faaef502c8cae34223..b82d2ab905998ca2c5f05b536fedb186523d755c 100644 (file)
@@ -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",
     [