Release=jammy
[Distribution]
-SandboxTrees=mkosi.pkgmngr
+SandboxTrees=mkosi.sandbox
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,
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:
trees = [
("skeleton", config.skeleton_trees),
- ("package manager", config.sandbox_trees),
+ ("sandbox", config.sandbox_trees),
]
if config.output_format != OutputFormat.none:
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()
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:
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",
],
)
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
"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)",
],
)
- 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.
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:
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:
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:
@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.
(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(
)
)
- 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():
),
)
- (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
@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)
# 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(
)
)
- 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:
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]
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
)
)
- if any((context.pkgmngr / "etc/pacman.d/").glob("*.conf")):
+ if any((context.sandbox_tree / "etc/pacman.d/").glob("*.conf")):
f.write(
textwrap.dedent(
"""\
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]
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
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}")
# 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(
@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
)
)
- 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:
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]
"""
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),
]