]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Rename internal pkgmngr dir to sandbox_tree
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 27 Aug 2024 08:51:45 +0000 (10:51 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 27 Aug 2024 09:24:20 +0000 (11:24 +0200)
13 files changed:
mkosi.conf.d/20-ubuntu/mkosi.conf.d/20-jammy.conf
mkosi.conf.d/20-ubuntu/mkosi.sandbox/etc/apt/sources.list.d/kernel-utils.sources [moved from mkosi.conf.d/20-ubuntu/mkosi.pkgmngr/etc/apt/sources.list.d/kernel-utils.sources with 100% similarity]
mkosi/__init__.py
mkosi/context.py
mkosi/distributions/centos.py
mkosi/distributions/debian.py
mkosi/distributions/rhel.py
mkosi/installer/apt.py
mkosi/installer/dnf.py
mkosi/installer/pacman.py
mkosi/installer/rpm.py
mkosi/installer/zypper.py
tests/test_config.py

index d926d3e9a5a321543b4f69427c86ff8c5e08e6f3..ef49c47805cec4dc5388e21d93b7c5bdbb7019c8 100644 (file)
@@ -4,4 +4,4 @@
 Release=jammy
 
 [Distribution]
-SandboxTrees=mkosi.pkgmngr
+SandboxTrees=mkosi.sandbox
index 742e75cc2ef986a2da568decbc667fbedbf46690..162749b51e290babbd4756bf65e907b8d3d9cb47 100644 (file)
@@ -1658,22 +1658,22 @@ def install_skeleton_trees(context: Context) -> None:
 
 def install_sandbox_trees(context: Context) -> None:
     # Ensure /etc exists in the sandbox
-    (context.pkgmngr / "etc").mkdir(exist_ok=True)
+    (context.sandbox_tree / "etc").mkdir(exist_ok=True)
 
     # Required to be able to access certificates in the sandbox when running from nix.
     if Path("/etc/static").is_symlink():
-        (context.pkgmngr / "etc/static").symlink_to(Path("/etc/static").readlink())
+        (context.sandbox_tree / "etc/static").symlink_to(Path("/etc/static").readlink())
 
-    (context.pkgmngr / "var/log").mkdir(parents=True)
+    (context.sandbox_tree / "var/log").mkdir(parents=True)
 
     if Path("/etc/passwd").exists():
-        shutil.copy("/etc/passwd", context.pkgmngr / "etc/passwd")
+        shutil.copy("/etc/passwd", context.sandbox_tree / "etc/passwd")
     if Path("/etc/group").exists():
-        shutil.copy("/etc/passwd", context.pkgmngr / "etc/group")
+        shutil.copy("/etc/passwd", context.sandbox_tree / "etc/group")
 
     if (p := context.config.tools() / "etc/crypto-policies").exists():
         copy_tree(
-            p, context.pkgmngr / "etc/crypto-policies",
+            p, context.sandbox_tree / "etc/crypto-policies",
             preserve=False,
             dereference=True,
             sandbox=context.config.sandbox,
@@ -1682,9 +1682,9 @@ def install_sandbox_trees(context: Context) -> None:
     if not context.config.sandbox_trees:
         return
 
-    with complete_step("Copying in package manager file trees…"):
+    with complete_step("Copying in sandbox trees…"):
         for tree in context.config.sandbox_trees:
-            install_tree(context.config, tree.source, context.pkgmngr, target=tree.target, preserve=False)
+            install_tree(context.config, tree.source, context.sandbox_tree, target=tree.target, preserve=False)
 
 
 def install_package_directories(context: Context, directories: Sequence[Path]) -> None:
@@ -2847,7 +2847,7 @@ def check_inputs(config: Config) -> None:
 
     trees = [
         ("skeleton", config.skeleton_trees),
-        ("package manager", config.sandbox_trees),
+        ("sandbox", config.sandbox_trees),
     ]
 
     if config.output_format != OutputFormat.none:
index 4beed80e757b2424b3e734ae9bfbf338b70a018c..22ed6d1ae3f7a0c4e3e86ed0754a281e076b798f 100644 (file)
@@ -31,7 +31,7 @@ class Context:
 
         self.package_dir.mkdir(exist_ok=True)
         self.staging.mkdir()
-        self.pkgmngr.mkdir()
+        self.sandbox_tree.mkdir()
         self.repository.mkdir()
         self.artifacts.mkdir()
         self.install_dir.mkdir()
@@ -45,8 +45,8 @@ class Context:
         return self.workspace / "staging"
 
     @property
-    def pkgmngr(self) -> Path:
-        return self.workspace / "pkgmngr"
+    def sandbox_tree(self) -> Path:
+        return self.workspace / "sandbox"
 
     @property
     def repository(self) -> Path:
@@ -76,13 +76,13 @@ class Context:
             devices=devices,
             vartmp=vartmp,
             scripts=scripts,
-            usroverlaydirs=[self.pkgmngr / "usr"] if (self.pkgmngr / "usr").exists() else [],
+            usroverlaydirs=[self.sandbox_tree / "usr"] if (self.sandbox_tree / "usr").exists() else [],
             options=[
                 *options,
                 # This mount is writable so we can create extra directories or symlinks inside of it as needed.
                 # This isn't a problem as the package manager directory is created by mkosi and thrown away when the
                 # build finishes.
-                "--bind", self.pkgmngr / "etc", "/etc",
-                "--bind", self.pkgmngr / "var/log", "/var/log",
+                "--bind", self.sandbox_tree / "etc", "/etc",
+                "--bind", self.sandbox_tree / "var/log", "/var/log",
             ],
         )
index e324620bc7af0dccabae67eee6d7da545d835bf3..c8afadeff64c7510396a887e5da2135040c07f93 100644 (file)
@@ -67,7 +67,7 @@ class Installer(DistributionInstaller):
             die(f"{cls.pretty_name()} Stream 8 or earlier variants are not supported")
 
         Dnf.setup(context, cls.repositories(context))
-        (context.pkgmngr / "etc/dnf/vars/stream").write_text(f"{context.config.release}-stream\n")
+        (context.sandbox_tree / "etc/dnf/vars/stream").write_text(f"{context.config.release}-stream\n")
         setup_rpm(context, dbpath=cls.dbpath(context))
 
     @classmethod
index 16eaebbb8e12a88caa54beaa323fbb71224a7d0b..d386da6ae15eede46eaa5c0ce1d406339dcc8c83 100644 (file)
@@ -141,8 +141,8 @@ class Installer(DistributionInstaller):
             "install",
             [
                 "-oDebug::pkgDPkgPm=1",
-                # context.pkgmngr is always mounted writable to /etc so let's use that as a channel to get the list of
-                # essential packages out of the sandbox.
+                # context.sandbox_tree is always mounted writable to /etc so let's use that as a channel to get the
+                # list of essential packages out of the sandbox.
                 "-oDPkg::Pre-Install-Pkgs::=cat >/etc/apt/essential",
                 "?essential",
                 "?exact-name(usr-is-merged)",
@@ -150,7 +150,7 @@ class Installer(DistributionInstaller):
             ],
         )
 
-        essential = (context.pkgmngr / "etc/apt/essential").read_text().strip().splitlines()
+        essential = (context.sandbox_tree / "etc/apt/essential").read_text().strip().splitlines()
 
         # Now, extract the debs to the chroot by first extracting the sources tar file out of the deb and
         # then extracting the tar file into the chroot.
index 5ffe0c496bf1d0a4fdc2d8bf35b52732ed88b1f4..653a42c15349a7362de76cb988a4f0b44911cfa4 100644 (file)
@@ -34,8 +34,8 @@ class Installer(centos.Installer):
             return None
 
         p = Path("etc/rhsm/ca/redhat-uep.pem")
-        if (context.pkgmngr / p).exists():
-            p = context.pkgmngr / p
+        if (context.sandbox_tree / p).exists():
+            p = context.sandbox_tree / p
         elif (Path("/") / p).exists():
             p = Path("/") / p
         else:
@@ -50,7 +50,7 @@ class Installer(centos.Installer):
 
         pattern = "etc/pki/entitlement/*-key.pem"
 
-        p = next((p for p in sorted(context.pkgmngr.glob(pattern))), None)
+        p = next((p for p in sorted(context.sandbox_tree.glob(pattern))), None)
         if not p:
             p = next((p for p in Path("/").glob(pattern)), None)
         if not p:
@@ -65,7 +65,7 @@ class Installer(centos.Installer):
 
         pattern = "etc/pki/entitlement/*.pem"
 
-        p = next((p for p in sorted(context.pkgmngr.glob(pattern)) if "key" not in p.name), None)
+        p = next((p for p in sorted(context.sandbox_tree.glob(pattern)) if "key" not in p.name), None)
         if not p:
             p = next((p for p in sorted(Path("/").glob(pattern)) if "key" not in p.name), None)
         if not p:
index 9559a283a471ece47a4e933adaffd9547b4fa309..01117d9684ef7b1f00b5daad8e248cee1e67f6f8 100644 (file)
@@ -97,10 +97,10 @@ class Apt(PackageManager):
 
     @classmethod
     def setup(cls, context: Context, repos: Iterable[AptRepository]) -> None:
-        (context.pkgmngr / "etc/apt").mkdir(exist_ok=True, parents=True)
-        (context.pkgmngr / "etc/apt/apt.conf.d").mkdir(exist_ok=True, parents=True)
-        (context.pkgmngr / "etc/apt/preferences.d").mkdir(exist_ok=True, parents=True)
-        (context.pkgmngr / "etc/apt/sources.list.d").mkdir(exist_ok=True, parents=True)
+        (context.sandbox_tree / "etc/apt").mkdir(exist_ok=True, parents=True)
+        (context.sandbox_tree / "etc/apt/apt.conf.d").mkdir(exist_ok=True, parents=True)
+        (context.sandbox_tree / "etc/apt/preferences.d").mkdir(exist_ok=True, parents=True)
+        (context.sandbox_tree / "etc/apt/sources.list.d").mkdir(exist_ok=True, parents=True)
 
         with umask(~0o755):
             # TODO: Drop once apt 2.5.4 is widely available.
@@ -109,11 +109,11 @@ class Apt(PackageManager):
 
             (context.root / "var/lib/dpkg/available").touch()
 
-        # We have a special apt.conf outside of pkgmngr dir that only configures "Dir::Etc" that we pass to APT_CONFIG
-        # to tell apt it should read config files from /etc/apt in case this is overridden by distributions. This is
-        # required because apt parses CLI configuration options after parsing its configuration files and as such we
-        # can't use CLI options to tell apt where to look for configuration files.
-        config = context.pkgmngr / "etc/apt.conf"
+        # We have a special apt.conf outside of the sandbox tree that only configures "Dir::Etc" that we pass to
+        # APT_CONFIG to tell apt it should read config files from /etc/apt in case this is overridden by distributions.
+        # This is required because apt parses CLI configuration options after parsing its configuration files and as
+        # such we can't use CLI options to tell apt where to look for configuration files.
+        config = context.sandbox_tree / "etc/apt.conf"
         if not config.exists():
             config.write_text(
                 textwrap.dedent(
@@ -123,7 +123,7 @@ class Apt(PackageManager):
                 )
             )
 
-        sources = context.pkgmngr / "etc/apt/sources.list.d/mkosi.sources"
+        sources = context.sandbox_tree / "etc/apt/sources.list.d/mkosi.sources"
         if not sources.exists():
             for repo in repos:
                 if repo.signedby and not repo.signedby.exists():
@@ -253,8 +253,8 @@ class Apt(PackageManager):
             ),
         )
 
-        (context.pkgmngr / "etc/apt/sources.list.d").mkdir(parents=True, exist_ok=True)
-        (context.pkgmngr / "etc/apt/sources.list.d/mkosi-local.sources").write_text(
+        (context.sandbox_tree / "etc/apt/sources.list.d").mkdir(parents=True, exist_ok=True)
+        (context.sandbox_tree / "etc/apt/sources.list.d/mkosi-local.sources").write_text(
             textwrap.dedent(
                 """\
                 Enabled: yes
index 9a137873a62865d68b77430987065cfea85e8d00..0160914b370e31bb6f7635b263368c43dd748e2e 100644 (file)
@@ -44,10 +44,10 @@ class Dnf(PackageManager):
 
     @classmethod
     def setup(cls, context: Context, repositories: Iterable[RpmRepository], filelists: bool = True) -> None:
-        (context.pkgmngr / "etc/dnf/vars").mkdir(parents=True, exist_ok=True)
-        (context.pkgmngr / "etc/yum.repos.d").mkdir(parents=True, exist_ok=True)
+        (context.sandbox_tree / "etc/dnf/vars").mkdir(parents=True, exist_ok=True)
+        (context.sandbox_tree / "etc/yum.repos.d").mkdir(parents=True, exist_ok=True)
 
-        config = context.pkgmngr / "etc/dnf/dnf.conf"
+        config = context.sandbox_tree / "etc/dnf/dnf.conf"
 
         if not config.exists():
             config.parent.mkdir(exist_ok=True, parents=True)
@@ -59,7 +59,7 @@ class Dnf(PackageManager):
 
         # The versionlock plugin will fail if enabled without a configuration file so lets' write a noop configuration
         # file to make it happy which can be overridden by users.
-        versionlock = context.pkgmngr / "etc/dnf/plugins/versionlock.conf"
+        versionlock = context.sandbox_tree / "etc/dnf/plugins/versionlock.conf"
         if not versionlock.exists():
             versionlock.parent.mkdir(parents=True, exist_ok=True)
             versionlock.write_text(
@@ -72,7 +72,7 @@ class Dnf(PackageManager):
                 )
             )
 
-        repofile = context.pkgmngr / "etc/yum.repos.d/mkosi.repo"
+        repofile = context.sandbox_tree / "etc/yum.repos.d/mkosi.repo"
         if not repofile.exists():
             repofile.parent.mkdir(exist_ok=True, parents=True)
             with repofile.open("w") as f:
@@ -219,7 +219,7 @@ class Dnf(PackageManager):
         run(["createrepo_c", context.repository],
             sandbox=context.sandbox(binary="createrepo_c", options=["--bind", context.repository, context.repository]))
 
-        (context.pkgmngr / "etc/yum.repos.d/mkosi-local.repo").write_text(
+        (context.sandbox_tree / "etc/yum.repos.d/mkosi-local.repo").write_text(
             textwrap.dedent(
                 """\
                 [mkosi]
index 8806a9c60b88aedd6c8b681baae7fe2a62f079a3..38175cd14bf91552d8cd7a16775fdf185041f02a 100644 (file)
@@ -77,9 +77,9 @@ class Pacman(PackageManager):
         with umask(~0o755):
             (context.root / "var/lib/pacman/local").mkdir(parents=True, exist_ok=True)
 
-        (context.pkgmngr / "etc/mkosi-local.conf").touch()
+        (context.sandbox_tree / "etc/mkosi-local.conf").touch()
 
-        config = context.pkgmngr / "etc/pacman.conf"
+        config = context.sandbox_tree / "etc/pacman.conf"
         if config.exists():
             return
 
@@ -126,7 +126,7 @@ class Pacman(PackageManager):
                     )
                 )
 
-            if any((context.pkgmngr / "etc/pacman.d/").glob("*.conf")):
+            if any((context.sandbox_tree / "etc/pacman.d/").glob("*.conf")):
                 f.write(
                     textwrap.dedent(
                         """\
@@ -186,7 +186,7 @@ class Pacman(PackageManager):
             sandbox=context.sandbox(binary="repo-add", options=["--bind", context.repository, context.repository]),
         )
 
-        (context.pkgmngr / "etc/mkosi-local.conf").write_text(
+        (context.sandbox_tree / "etc/mkosi-local.conf").write_text(
             textwrap.dedent(
                 """\
                 [mkosi]
index 185db91c644a438e6e2deca1384d12fd1bdbf108..39ef644f09923bfa4557a25a9e63453b91adaff3 100644 (file)
@@ -56,8 +56,8 @@ def find_rpm_gpgkey(
     if gpgpath := next((root / "usr/share/distribution-gpg-keys").rglob(key), None):
         return (Path("/") / gpgpath.relative_to(root)).as_uri()
 
-    if gpgpath := next(Path(context.pkgmngr / "etc/pki/rpm-gpg").rglob(key), None):
-        return (Path("/") / gpgpath.relative_to(context.pkgmngr)).as_uri()
+    if gpgpath := next(Path(context.sandbox_tree / "etc/pki/rpm-gpg").rglob(key), None):
+        return (Path("/") / gpgpath.relative_to(context.sandbox_tree)).as_uri()
 
     if context.config.repository_key_fetch:
         return fallback
@@ -70,7 +70,7 @@ def find_rpm_gpgkey(
 
 
 def setup_rpm(context: Context, *, dbpath: str = "/usr/lib/sysimage/rpm") -> None:
-    confdir = context.pkgmngr / "etc/rpm"
+    confdir = context.sandbox_tree / "etc/rpm"
     confdir.mkdir(parents=True, exist_ok=True)
     if not (confdir / "macros.lang").exists() and context.config.locale:
         (confdir / "macros.lang").write_text(f"%_install_langs {context.config.locale}")
@@ -88,7 +88,7 @@ def setup_rpm(context: Context, *, dbpath: str = "/usr/lib/sysimage/rpm") -> Non
     # Write an rpm sequoia policy that allows SHA1 as various distribution GPG keys (OpenSUSE) still use SHA1 for
     # various things.
     # TODO: Remove when all rpm distribution GPG keys have stopped using SHA1.
-    if not (p := context.pkgmngr / "etc/crypto-policies/back-ends/rpm-sequoia.config").exists():
+    if not (p := context.sandbox_tree / "etc/crypto-policies/back-ends/rpm-sequoia.config").exists():
         p.parent.mkdir(parents=True, exist_ok=True)
         p.write_text(
             textwrap.dedent(
index 1ef9689279890b120c895510db71375f418958bc..5ef0bf916f1edf8ee6bbcdace49271f7d367efb7 100644 (file)
@@ -45,7 +45,7 @@ class Zypper(PackageManager):
 
     @classmethod
     def setup(cls, context: Context, repos: Iterable[RpmRepository]) -> None:
-        config = context.pkgmngr / "etc/zypp/zypp.conf"
+        config = context.sandbox_tree / "etc/zypp/zypp.conf"
         config.parent.mkdir(exist_ok=True, parents=True)
 
         # rpm.install.excludedocs can only be configured in zypp.conf so we append
@@ -62,7 +62,7 @@ class Zypper(PackageManager):
                 )
             )
 
-        repofile = context.pkgmngr / "etc/zypp/repos.d/mkosi.repo"
+        repofile = context.sandbox_tree / "etc/zypp/repos.d/mkosi.repo"
         if not repofile.exists():
             repofile.parent.mkdir(exist_ok=True, parents=True)
             with repofile.open("w") as f:
@@ -141,7 +141,7 @@ class Zypper(PackageManager):
         run(["createrepo_c", context.repository],
             sandbox=context.sandbox(binary="createrepo_c", options=["--bind", context.repository, context.repository]))
 
-        (context.pkgmngr / "etc/zypp/repos.d/mkosi-local.repo").write_text(
+        (context.sandbox_tree / "etc/zypp/repos.d/mkosi-local.repo").write_text(
             textwrap.dedent(
                 """\
                 [mkosi]
index c6faa1059fd06f8b3c94f4b105d85743bbe9733f..433510883956c8030b5c13ffc14aba5c05b4eb64 100644 (file)
@@ -992,11 +992,11 @@ def test_paths_with_default_factory(tmp_path: Path) -> None:
     """
 
     with chdir(tmp_path):
-        Path("mkosi.pkgmngr.tar").touch()
+        Path("mkosi.sandbox.tar").touch()
         _, [config] = parse_config()
 
         assert config.sandbox_trees == [
-            ConfigTree(Path.cwd() / "mkosi.pkgmngr.tar", None),
+            ConfigTree(Path.cwd() / "mkosi.sandbox.tar", None),
         ]