[PATCH] isar-mmdebstrap: reduce rootfs size as much as possible

37 views
Skip to first unread message

srinuv...@siemens.com

unread,
Jan 9, 2025, 7:17:57 AM1/9/25
to isar-...@googlegroups.com, cedric.h...@siemens.com, ami...@ilbers.de, srinuvasan
From: srinuvasan <srinuv...@siemens.com>

reduce the rootfs image size by excluding man and doc, this
changes significantly reduce size from (~80MB) to (~64MB).

Signed-off-by: srinuvasan <srinuv...@siemens.com>
---
meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
index 931f6f13..1e2ad40f 100644
--- a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
+++ b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
@@ -24,6 +24,14 @@ DPKG_HOOKS ?= "${@'--hook-dir='+d.getVar('MM_HOOK_JESSIE') \
MMHOOKS:focal ?= "${DPKG_HOOKS}"
MMHOOKS:buster ?= "${DPKG_HOOKS}"

+CLEANUP_DOCS = "--dpkgopt='path-exclude=/usr/share/man/*' \
+ --dpkgopt='path-include=/usr/share/man/man[1-9]/*' \
+ --dpkgopt='path-exclude=/usr/share/locale/*' \
+ --dpkgopt='path-include=/usr/share/locale/locale.alias' \
+ --dpkgopt='path-exclude=/usr/share/doc/*' \
+ --dpkgopt='path-include=/usr/share/doc/*/copyright' \
+ --dpkgopt='path-include=/usr/share/doc/*/changelog.Debian.*'"
+
DISTRO_BOOTSTRAP_KEYRING = "${WORKDIR}/distro-keyring.gpg"

def get_distro_have_https_source(d):
@@ -199,6 +207,7 @@ do_bootstrap() {
--customize-hook='sed -i "/en_US.UTF-8 UTF-8/s/^#//g" "$1/etc/locale.gen"' \
--customize-hook='chroot "$1" /usr/sbin/locale-gen' \
--customize-hook='chroot "$1" /usr/bin/apt-get -y clean' \
+ ${CLEANUP_DOCS} \
--skip=cleanup/apt \
--skip=download/empty \
${@get_apt_opts(d, '--aptopt')} \
--
2.39.5

Cedric Hombourger

unread,
Jan 9, 2025, 7:41:32 AM1/9/25
to isar-users
Le jeudi 9 janvier 2025 à 13:17:57 UTC+1, srinuv...@siemens.com a écrit :
From: srinuvasan <srinuv...@siemens.com>

reduce the rootfs image size by excluding man and doc, this
changes significantly reduce size from (~80MB) to (~64MB).

Signed-off-by: srinuvasan <srinuv...@siemens.com>
---
meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
index 931f6f13..1e2ad40f 100644
--- a/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
+++ b/meta/recipes-core/isar-mmdebstrap/isar-mmdebstrap.inc
@@ -24,6 +24,14 @@ DPKG_HOOKS ?= "${@'--hook-dir='+d.getVar('MM_HOOK_JESSIE') \
MMHOOKS:focal ?= "${DPKG_HOOKS}"
MMHOOKS:buster ?= "${DPKG_HOOKS}"

+CLEANUP_DOCS = "--dpkgopt='path-exclude=/usr/share/man/*' \
+ --dpkgopt='path-include=/usr/share/man/man[1-9]/*' \
+ --dpkgopt='path-exclude=/usr/share/locale/*' \
+ --dpkgopt='path-include=/usr/share/locale/locale.alias' \
+ --dpkgopt='path-exclude=/usr/share/doc/*' \
+ --dpkgopt='path-include=/usr/share/doc/*/copyright' \
+ --dpkgopt='path-include=/usr/share/doc/*/changelog.Debian.*'"
+

Not.a good idea IMO - some users may want to build images with man pages / documentation
At best this could be an image extension. It could take informed decisions: if /usr/bin/man isn’t there then remove man pages. Users should be able to enable/disable that customisation

Anton Mikanovich

unread,
Jan 9, 2025, 7:58:37 AM1/9/25
to Cedric Hombourger, isar-users, Srinuvasan Arjunan
Agree, but maybe we can introduce some kind of global switch (features
implementation from Chris can be helpful here) to enable such kind of hacks.
And of course it should be disabled by default.

Cedric Hombourger

unread,
Jan 9, 2025, 8:16:08 AM1/9/25
to isar-users
I would surely vote for Chris’ implementation since it is something he has implemented at my request :). Glad to see that we have a use-case for it (within this layer itself). Good feedback / suggestions Anton.

Arjunan, Srinu

unread,
Jan 9, 2025, 9:23:10 AM1/9/25
to Anton Mikanovich, Cedric Hombourger, isar-users
Thanks cedric and anton for the review. Let's wait for Chris's changes and try to use this one as a switch.

Best Regards,
Srinu

Jan Kiszka

unread,
Jan 9, 2025, 10:20:19 AM1/9/25
to srinuv...@siemens.com, isar-...@googlegroups.com, cedric.h...@siemens.com, ami...@ilbers.de
On 09.01.25 13:17, srinuvasan.a via isar-users wrote:
> From: srinuvasan <srinuv...@siemens.com>
>
> reduce the rootfs image size by excluding man and doc, this
> changes significantly reduce size from (~80MB) to (~64MB).
>

What's the (final) difference to isar-exclude-docs?

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center

Arjunan, Srinu

unread,
Jan 9, 2025, 10:27:21 AM1/9/25
to Kiszka, Jan, isar-...@googlegroups.com, cedric.h...@siemens.com, ami...@ilbers.de
I validated the isar-mmdebstrap-target rootfs with and without docs, I could able to see approx 17MB differences.

Note: compared the compressed rootfs (rootfs.tar.zst) file

Many thanks,
Srinu

-----Original Message-----
From: Kiszka, Jan (FT RPD CED) <jan.k...@siemens.com>
Sent: 09 January 2025 20:50
To: Arjunan, Srinu (FT FDS CES LX PBU 2) <srinuv...@siemens.com>; isar-...@googlegroups.com
Cc: Hombourger, Cedric (FT FDS CES LX) <cedric.h...@siemens.com>; ami...@ilbers.de
Subject: Re: [PATCH] isar-mmdebstrap: reduce rootfs size as much as possible

Jan Kiszka

unread,
Jan 9, 2025, 10:30:00 AM1/9/25
to Arjunan, Srinu (FT FDS CES LX PBU 2), isar-...@googlegroups.com, Hombourger, Cedric (FT FDS CES LX), ami...@ilbers.de
On 09.01.25 16:27, Arjunan, Srinu (FT FDS CES LX PBU 2) wrote:
> I validated the isar-mmdebstrap-target rootfs with and without docs, I could able to see approx 17MB differences.
>

That is not my point.

Are you trying to optimize the intermediate artifact sizes or the final
image? The latter should also be addressed by using isar-exclude-docs.
The former would need some stronger motivation, I would say...

Jan

Arjunan, Srinu

unread,
Jan 10, 2025, 1:02:43 AM1/10/25
to Kiszka, Jan, isar-...@googlegroups.com, cedric.h...@siemens.com, ami...@ilbers.de
Hi Jan,

I hope this isar-exclude-docs package can be used to exclude the documentation in the image rootfs, but here I introduced this customization for the bootstrap rootfs.

Additionally we are cleaning the locales under /usr/share in the bootstrap rootfs.

With this reduced size of the bootstrap rootfs, we achieve the sbuildchroot-<host/target> size also reduced.

Jan Kiszka

unread,
Jan 10, 2025, 1:13:10 AM1/10/25
to Arjunan, Srinu (FT FDS CES LX PBU 2), isar-...@googlegroups.com, Hombourger, Cedric (FT FDS CES LX), ami...@ilbers.de
On 10.01.25 07:02, Arjunan, Srinu (FT FDS CES LX PBU 2) wrote:
> Hi Jan,
>
> I hope this isar-exclude-docs package can be used to exclude the documentation in the image rootfs, but here I introduced this customization for the bootstrap rootfs.
>
> Additionally we are cleaning the locales under /usr/share in the bootstrap rootfs.
>
> With this reduced size of the bootstrap rootfs, we achieve the sbuildchroot-<host/target> size also reduced.
>

Still no reason to not use that existing package, maybe extending it. It
already comes with the configurability that your approach is missing and
cannot introduce that nicely.

Jan

Jan Kiszka

unread,
Jan 10, 2025, 1:18:04 AM1/10/25
to Arjunan, Srinu (FT FDS CES LX PBU 2), isar-...@googlegroups.com, Hombourger, Cedric (FT FDS CES LX), ami...@ilbers.de
On 10.01.25 07:13, Jan Kiszka wrote:
> On 10.01.25 07:02, Arjunan, Srinu (FT FDS CES LX PBU 2) wrote:
>> Hi Jan,
>>
>> I hope this isar-exclude-docs package can be used to exclude the documentation in the image rootfs, but here I introduced this customization for the bootstrap rootfs.
>>
>> Additionally we are cleaning the locales under /usr/share in the bootstrap rootfs.
>>
>> With this reduced size of the bootstrap rootfs, we achieve the sbuildchroot-<host/target> size also reduced.
>>
>
> Still no reason to not use that existing package, maybe extending it. It
> already comes with the configurability that your approach is missing and
> cannot introduce that nicely.
>

Plus, your approach cleans up before all packages have been install,
isar-exclude-docs does that afterwards. So, yours is architecturally
inferior. I really see no reason to go this way.

Anton Mikanovich

unread,
Jan 10, 2025, 2:19:23 AM1/10/25
to Jan Kiszka, Arjunan, Srinu (FT FDS CES LX PBU 2), isar-...@googlegroups.com, Hombourger, Cedric (FT FDS CES LX)
10/01/2025 08:13, Jan Kiszka wrote:
> Still no reason to not use that existing package, maybe extending it. It
> already comes with the configurability that your approach is missing and
> cannot introduce that nicely.
>
> Jan

Hello Jan,

The main reason not to use isar-exclude-docs is that this package
doesn't exist
during bootstrap rootfs preparations. Moreover to build it we need bootstrap
recipe building already finished.

Cedric Hombourger

unread,
Jan 10, 2025, 2:24:45 AM1/10/25
to isar-users
Too be  honest, I am not sure why we would want to apply any optimizations at the bootstrap phase as needs for images or sbuild environments are not known at that stage (eg one may want man pages in the SDK). Am I missing something?

Jan Kiszka

unread,
Jan 10, 2025, 3:04:52 AM1/10/25
to Anton Mikanovich, Arjunan, Srinu (FT FDS CES LX PBU 2), isar-...@googlegroups.com, Hombourger, Cedric (FT FDS CES LX)
What matters is the final image, not the bootstrapped one. And this is
what the postinst script of isar-exclude-docs addresses. The hook of
this patch only addresses what the essential packages bring in form of
docs & Co., thus fails to achieve its declared goal.
Reply all
Reply to author
Forward
0 new messages