]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Configure rpm _install_langs if locale is configured
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 2 Dec 2023 09:04:55 +0000 (10:04 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 4 Dec 2023 13:21:46 +0000 (14:21 +0100)
If the _install_langs macro is defined, rpm will only install locale
data corresponding to the locales in _install_langs. If Locale= is
set and macros.lang doesn't exist already, let's configure it ourselves
with _install_langs to save on disk space.

mkosi/installer/dnf.py

index 08bfea87e184df1f3c8df534717f6107ca90fe61..345b647f9d4ce73b33e64c2eb081acc3c76bd982 100644 (file)
@@ -95,8 +95,12 @@ def setup_dnf(state: MkosiState, repos: Iterable[Repo], filelists: bool = True)
 
                 f.write("\n")
 
+    macros = state.pkgmngr / "usr/lib/rpm/macros.d"
+    macros.mkdir(parents=True, exist_ok=True)
+    if not (macros / "macros.lang").exists() and state.config.locale:
+        (macros / "macros.lang").write_text(f"%_install_langs {state.config.locale}")
+
     rpmconfigdir = Path(run(["rpm", "--eval", "%{_rpmconfigdir}"], stdout=subprocess.PIPE).stdout.strip())
-    (state.pkgmngr / "usr/lib").mkdir(parents=True, exist_ok=True)
     copy_tree(state.config, rpmconfigdir, state.pkgmngr / "usr/lib/rpm", clobber=False)