From: Daan De Meyer Date: Tue, 27 Aug 2024 08:51:45 +0000 (+0200) Subject: Rename internal pkgmngr dir to sandbox_tree X-Git-Tag: v25~336^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fce088ba5d5641807a0d888932d6248f340dc8fc;p=thirdparty%2Fmkosi.git Rename internal pkgmngr dir to sandbox_tree --- diff --git a/mkosi.conf.d/20-ubuntu/mkosi.conf.d/20-jammy.conf b/mkosi.conf.d/20-ubuntu/mkosi.conf.d/20-jammy.conf index d926d3e9a..ef49c4780 100644 --- a/mkosi.conf.d/20-ubuntu/mkosi.conf.d/20-jammy.conf +++ b/mkosi.conf.d/20-ubuntu/mkosi.conf.d/20-jammy.conf @@ -4,4 +4,4 @@ Release=jammy [Distribution] -SandboxTrees=mkosi.pkgmngr +SandboxTrees=mkosi.sandbox diff --git a/mkosi.conf.d/20-ubuntu/mkosi.pkgmngr/etc/apt/sources.list.d/kernel-utils.sources b/mkosi.conf.d/20-ubuntu/mkosi.sandbox/etc/apt/sources.list.d/kernel-utils.sources similarity index 100% rename from mkosi.conf.d/20-ubuntu/mkosi.pkgmngr/etc/apt/sources.list.d/kernel-utils.sources rename to mkosi.conf.d/20-ubuntu/mkosi.sandbox/etc/apt/sources.list.d/kernel-utils.sources diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 742e75cc2..162749b51 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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: diff --git a/mkosi/context.py b/mkosi/context.py index 4beed80e7..22ed6d1ae 100644 --- a/mkosi/context.py +++ b/mkosi/context.py @@ -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", ], ) diff --git a/mkosi/distributions/centos.py b/mkosi/distributions/centos.py index e324620bc..c8afadeff 100644 --- a/mkosi/distributions/centos.py +++ b/mkosi/distributions/centos.py @@ -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 diff --git a/mkosi/distributions/debian.py b/mkosi/distributions/debian.py index 16eaebbb8..d386da6ae 100644 --- a/mkosi/distributions/debian.py +++ b/mkosi/distributions/debian.py @@ -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. diff --git a/mkosi/distributions/rhel.py b/mkosi/distributions/rhel.py index 5ffe0c496..653a42c15 100644 --- a/mkosi/distributions/rhel.py +++ b/mkosi/distributions/rhel.py @@ -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: diff --git a/mkosi/installer/apt.py b/mkosi/installer/apt.py index 9559a283a..01117d968 100644 --- a/mkosi/installer/apt.py +++ b/mkosi/installer/apt.py @@ -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 diff --git a/mkosi/installer/dnf.py b/mkosi/installer/dnf.py index 9a137873a..0160914b3 100644 --- a/mkosi/installer/dnf.py +++ b/mkosi/installer/dnf.py @@ -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] diff --git a/mkosi/installer/pacman.py b/mkosi/installer/pacman.py index 8806a9c60..38175cd14 100644 --- a/mkosi/installer/pacman.py +++ b/mkosi/installer/pacman.py @@ -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] diff --git a/mkosi/installer/rpm.py b/mkosi/installer/rpm.py index 185db91c6..39ef644f0 100644 --- a/mkosi/installer/rpm.py +++ b/mkosi/installer/rpm.py @@ -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( diff --git a/mkosi/installer/zypper.py b/mkosi/installer/zypper.py index 1ef968927..5ef0bf916 100644 --- a/mkosi/installer/zypper.py +++ b/mkosi/installer/zypper.py @@ -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] diff --git a/tests/test_config.py b/tests/test_config.py index c6faa1059..433510883 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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), ]