@classmethod
def install_packages(cls, state: MkosiState, packages: Sequence[str], apivfs: bool = True) -> None:
if shutil.which("zypper"):
- invoke_zypper(state, "install", packages, ["--download", "in-advance"], apivfs=apivfs)
+ options = [
+ "--download", "in-advance",
+ "--recommends" if state.config.with_recommends else "--no-recommends",
+ ]
+ invoke_zypper(state, "install", packages, options, apivfs=apivfs)
else:
invoke_dnf(state, "install", packages, apivfs=apivfs)
)
)
- config = state.pkgmngr / "etc/apt/apt.conf"
- if not config.exists():
- # Anything that users can override with dropins is written into the config file.
- config.write_text(
- textwrap.dedent(
- f"""\
- APT::Install-Recommends "{str(state.config.with_recommends).lower()}";
- """
- )
- )
-
sources = state.pkgmngr / "etc/apt/sources.list"
if not sources.exists():
with sources.open("w") as f:
command,
"-o", f"APT::Architecture={debarch}",
"-o", f"APT::Architectures={debarch}",
+ "-o", f"APT::Install-Recommends={str(state.config.with_recommends).lower()}",
"-o", "APT::Immediate-Configure=off",
"-o", "APT::Get::Assume-Yes=true",
"-o", "APT::Get::AutomaticRemove=true",
if not config.exists():
config.parent.mkdir(exist_ok=True, parents=True)
with config.open("w") as f:
- f.write(
- textwrap.dedent(
- f"""\
- [main]
- install_weak_deps={int(state.config.with_recommends)}
- """
- )
- )
-
# Make sure we download filelists so all dependencies can be resolved.
# See https://bugzilla.redhat.com/show_bug.cgi?id=2180842
if dnf_executable(state).endswith("dnf5") and filelists:
- f.write("optional_metadata_types=filelists\n")
+ f.write("[main]\noptional_metadata_types=filelists\n")
repofile = state.pkgmngr / "etc/yum.repos.d/mkosi.repo"
if not repofile.exists():
f"--setopt=reposdir={state.pkgmngr / 'etc/yum.repos.d'}",
f"--setopt=varsdir={state.pkgmngr / 'etc/dnf/vars'}",
f"--setopt=persistdir={state.pkgmngr / 'var/lib/dnf'}",
+ f"--setopt=install_weak_deps={int(state.config.with_recommends)}",
"--setopt=check_config_file_age=0",
"--disable-plugin=*" if dnf.endswith("dnf5") else "--disableplugin=*",
"--enable-plugin=builddep" if dnf.endswith("dnf5") else "--enableplugin=builddep",
def setup_zypper(state: MkosiState, repos: Sequence[RpmRepository]) -> None:
config = state.pkgmngr / "etc/zypp/zypp.conf"
- if not config.exists():
- config.parent.mkdir(exist_ok=True, parents=True)
- with config.open("w") as f:
- f.write(
- textwrap.dedent(
- f"""\
- [main]
- rpm.install.excludedocs = {yes_no(not state.config.with_docs)}
- solver.onlyRequires = {yes_no(not state.config.with_recommends)}
- """
- )
+ config.parent.mkdir(exist_ok=True, parents=True)
+
+ # rpm.install.excludedocs can only be configured in zypp.conf so we append
+ # to any user provided config file.
+ with config.open("a") as f:
+ f.write(
+ textwrap.dedent(
+ f"""
+ [main]
+ rpm.install.excludedocs = {yes_no(not state.config.with_docs)}
+ """
)
+ )
repofile = state.pkgmngr / "etc/zypp/repos.d/mkosi.repo"
if not repofile.exists():