]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
debian: also remove docs installed by debootstrap 263/head
authorAntonio Terceiro <asa@terceiro.xyz>
Fri, 7 Sep 2018 14:53:24 +0000 (11:53 -0300)
committerAntonio Terceiro <asa@terceiro.xyz>
Fri, 7 Sep 2018 15:02:12 +0000 (12:02 -0300)
On my tests, this reduces a minimal Debian stable rootfs from ~204 MB to
~157 MB

mkosi

diff --git a/mkosi b/mkosi
index 5f9ecfd7b3b20aed6ec1aed9541bb38f9a5f19af..c48979ed595159c160da7bd295d8d04c246015f9 100755 (executable)
--- a/mkosi
+++ b/mkosi
@@ -1323,19 +1323,24 @@ def install_debian_or_ubuntu(args, workspace, run_build_script, mirror):
         f.write("#!/bin/sh\n")
         f.write("exit 101")
     os.chmod(policyrcd, 0o755)
+
+    doc_paths = [
+        '/usr/share/locale',
+        '/usr/share/doc',
+        '/usr/share/man',
+        '/usr/share/groff',
+        '/usr/share/info',
+        '/usr/share/lintian',
+        '/usr/share/linda',
+    ]
     if not args.with_docs:
-        # Create dpkg.cfg to ingore documentation
+        # remove documentation installed by debootstrap
+        cmdline = ["rm", "-rf"] + doc_paths
+        run_workspace_command(args, workspace, *cmdline)
+        # Create dpkg.cfg to ingore documentation on new packages
         dpkg_conf = os.path.join(workspace, "root/etc/dpkg/dpkg.cfg.d/01_nodoc")
         with open(dpkg_conf, "w") as f:
-            f.writelines([
-                'path-exclude /usr/share/locale/*\n',
-                'path-exclude /usr/share/doc/*\n',
-                'path-exclude /usr/share/man/*\n',
-                'path-exclude /usr/share/groff/*\n',
-                'path-exclude /usr/share/info/*\n',
-                'path-exclude /usr/share/lintian/*\n',
-                'path-exclude /usr/share/linda/*\n',
-            ])
+            f.writelines(["path-exclude %s/*\n" % d for d in doc_paths])
 
     cmdline = ["/usr/bin/apt-get", "--assume-yes", "--no-install-recommends", "install"] + extra_packages
     run_workspace_command(args, workspace, network=True, env={'DEBIAN_FRONTEND': 'noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN': 'true'}, *cmdline)