with complete_step(f"Installing volatile packages for {context.config.distribution.pretty_name()}"):
context.config.distribution.package_manager(context.config).install(
- context, context.config.volatile_packages
+ context, context.config.volatile_packages, allow_downgrade=True
)
packages: Sequence[str],
*,
apivfs: bool = True,
+ allow_downgrade: bool = False,
) -> None:
pass
packages: Sequence[str],
*,
apivfs: bool = True,
+ allow_downgrade: bool = False,
) -> None:
# Debian policy is to start daemons by default. The policy-rc.d script can be used choose which ones
# to start. Let's install one that denies all daemon startups.
with umask(~0o644):
policyrcd.write_text("#!/bin/sh\nexit 101\n")
- cls.invoke(context, "install", packages, apivfs=apivfs)
+ arguments = []
+
+ if allow_downgrade:
+ arguments += ["--allow-downgrades"]
+
+ arguments += [*packages]
+
+ cls.invoke(context, "install", arguments, apivfs=apivfs)
policyrcd.unlink()
cmdline: list[PathString] = [
dnf,
"--assumeyes",
- "--best",
f"--releasever={context.config.release}",
"--installroot=/buildroot",
"--setopt=keepcache=1",
operation: str,
arguments: Sequence[str] = (),
*,
+ options: Sequence[str] = (),
apivfs: bool = False,
stdout: _FILE = None,
cached_metadata: bool = True,
) -> CompletedProcess:
try:
return run(
- cls.cmd(context, cached_metadata=cached_metadata) + [operation, *arguments],
+ cls.cmd(context, cached_metadata=cached_metadata) + [*options, operation, *arguments],
sandbox=cls.sandbox(context, apivfs=apivfs),
env=cls.finalize_environment(context),
stdout=stdout,
packages: Sequence[str],
*,
apivfs: bool = True,
+ allow_downgrade: bool = False,
) -> None:
- cls.invoke(context, "install", packages, apivfs=apivfs)
+ arguments = []
+ options = []
+
+ if allow_downgrade:
+ if Dnf.executable(context.config) == "dnf5":
+ arguments += ["--allow-downgrade"]
+ else:
+ options += ["--best"]
+
+ arguments += [*packages]
+
+ cls.invoke(context, "install", arguments, options=options, apivfs=apivfs)
@classmethod
def remove(cls, context: Context, packages: Sequence[str]) -> None:
packages: Sequence[str],
*,
apivfs: bool = True,
+ allow_downgrade: bool = False,
) -> None:
- arguments = ["--needed", "--assume-installed", "initramfs", *packages]
+ arguments = ["--needed", "--assume-installed", "initramfs"]
+
+ if allow_downgrade:
+ arguments += ["--sysupgrade", "--sysupgrade"]
+
+ arguments += [*packages]
+
cls.invoke(context, "--sync", arguments, apivfs=apivfs)
@classmethod
packages: Sequence[str],
*,
apivfs: bool = True,
+ allow_downgrade: bool = False,
) -> None:
arguments = [
"--download", "in-advance",
"--recommends" if context.config.with_recommends else "--no-recommends",
- *packages,
] # fmt: skip
+ if allow_downgrade:
+ arguments += ["--allow-downgrade"]
+
+ arguments += [*packages]
+
cls.invoke(context, "install", arguments, apivfs=apivfs)
@classmethod