* [RFC PATCH] meta/classes: Add strip-image @ 2025-09-03 15:20 'Quirin Gylstorff' via isar-users 2025-09-03 16:19 ` 'Jan Kiszka' via isar-users 0 siblings, 1 reply; 7+ messages in thread From: 'Quirin Gylstorff' via isar-users @ 2025-09-03 15:20 UTC (permalink / raw) To: isar-users From: Quirin Gylstorff <quirin.gylstorff@siemens.com> This class provides the optional functionality to strip packages and files from a image. This allows the user to reduce the image size. IMPORTANT: This is an expert feature and can lead to broken images. Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> --- The default settings will reduce the space around 40MB. It is currently a RFC to collect information about the usage. Should we integrate by default or should the user add this on demand? For a default integration I would drop the deletion: - /vmlinuz* - /boot - /usr/include - initramfs-tools meta/classes/strip-image.bbclass | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 meta/classes/strip-image.bbclass diff --git a/meta/classes/strip-image.bbclass b/meta/classes/strip-image.bbclass new file mode 100644 index 00000000..edff3fd4 --- /dev/null +++ b/meta/classes/strip-image.bbclass @@ -0,0 +1,64 @@ +# strip image helper +# +# This software is a part of ISAR. +# Copyright (C) Siemens AG, 2025 +# +# SPDX-License-Identifier: MIT +# This class provides functions to remove pacakges and files +# from the image + +# Default list of files to be removed: +# - remove kernel and initrd +# - remove all documentation +# - remove all include files +IMAGE_STRIP_FILES += " \ + /vmlinuz* \ + /boot \ + /usr/share/doc \ + /usr/share/info \ + /usr/share/man \ + /usr/include \ +" + +do_strip_files_from_image[vardeps] = "${IMAGE_STRIP_FILES}" +do_strip_files_from_image[network] = "${TASK_USE_SUDO}" +do_strip_files_from_image() { +i if [ -n "${IMAGE_STRIP_FILES}" ]; then + cat <<EOF | sudo tee "${IMAGE_ROOTFS}/purge.sh" +#!/usr/bin/env sh +set -x +for elem in ${IMAGE_STRIP_FILES}; do + find \$elem ! -type d -exec rm -rf {} \; +done +rm -f /purge.sh +EOF + sudo chmod 755 "${IMAGE_ROOTFS}/purge.sh" + sudo -E chroot "${IMAGE_ROOTFS}" "/purge.sh" + fi +} +addtask strip_files_from_image before do_rootfs_finalize after do_generate_initramfs +IMAGE_STRIP_PACKAGES += " \ + initramfs-tools \ + initramfs-tools-core \ + locales \ +" +do_strip_packages_from_image[vardeps] = "${IMAGE_STRIP_PACKAGES}" +do_strip_packages_from_image[network] = "${TASK_USE_SUDO}" +do_strip_packages_from_image() { + bbnote "IMAGE_PACKAGES_REMOVE: ${IMAGE_PACKAGES_REMOVE}" + if [ -n "${IMAGE_STRIP_PACKAGES}" ]; then + RMPKGS=$(dpkg-query \ + --admindir=${IMAGE_ROOTFS}/var/lib/dpkg/ \ + -f '${Package}\n' \ + -W ${IMAGE_STRIP_PACKAGES} 2>/dev/null || true) + + if [ -n "${RMPKGS}" ]; then + bbnote "Removing packages: ${RMPKGS}" + sudo -E chroot "${IMAGE_ROOTFS}" \ + dpkg --purge --force-depends --force-remove-essential ${RMPKGS} + else + bbnote "Packages have already been purged or could not be found" + fi + fi +} +addtask strip_packages_from_image before do_strip_files_from_image do_rootfs_finalize after do_rootfs_postprocess -- 2.50.1 -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/20250903152055.1353354-1-Quirin.Gylstorff%40siemens.com. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] meta/classes: Add strip-image 2025-09-03 15:20 [RFC PATCH] meta/classes: Add strip-image 'Quirin Gylstorff' via isar-users @ 2025-09-03 16:19 ` 'Jan Kiszka' via isar-users 2025-09-03 17:13 ` 'Quirin Gylstorff' via isar-users 0 siblings, 1 reply; 7+ messages in thread From: 'Jan Kiszka' via isar-users @ 2025-09-03 16:19 UTC (permalink / raw) To: Quirin Gylstorff, isar-users On 03.09.25 17:20, 'Quirin Gylstorff' via isar-users wrote: > From: Quirin Gylstorff <quirin.gylstorff@siemens.com> > > This class provides the optional functionality to strip packages > and files from a image. This allows the user to reduce the image > size. > > IMPORTANT: This is an expert feature and can lead to broken images. > Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> > --- > > The default settings will reduce the space around 40MB. It is currently > a RFC to collect information about the usage. > > Should we integrate by default or should the user add this on demand? > For a default integration I would drop the deletion: > - /vmlinuz* > - /boot > - /usr/include > - initramfs-tools > The approach isar-exclude-docs takes for docs cannot be used here? And we want that approach to stay for cleaning docs? Or what is the relation between the two? Jan -- Siemens AG, Foundational Technologies Linux Expert Center -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/8d2554d1-789e-4838-a515-eeb2cef78e10%40siemens.com. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] meta/classes: Add strip-image 2025-09-03 16:19 ` 'Jan Kiszka' via isar-users @ 2025-09-03 17:13 ` 'Quirin Gylstorff' via isar-users 2025-09-04 8:37 ` 'Jan Kiszka' via isar-users 0 siblings, 1 reply; 7+ messages in thread From: 'Quirin Gylstorff' via isar-users @ 2025-09-03 17:13 UTC (permalink / raw) To: Jan Kiszka, isar-users On 9/3/25 18:19, Jan Kiszka wrote: > On 03.09.25 17:20, 'Quirin Gylstorff' via isar-users wrote: >> From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> >> This class provides the optional functionality to strip packages >> and files from a image. This allows the user to reduce the image >> size. >> >> IMPORTANT: This is an expert feature and can lead to broken images. >> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >> --- >> >> The default settings will reduce the space around 40MB. It is currently >> a RFC to collect information about the usage. >> >> Should we integrate by default or should the user add this on demand? >> For a default integration I would drop the deletion: >> - /vmlinuz* >> - /boot >> - /usr/include >> - initramfs-tools >> > > The approach isar-exclude-docs takes for docs cannot be used here? And > we want that approach to stay for cleaning docs? Or what is the relation > between the two? We can use isar-exclude-docs or the use the same implementation. I didn't use it as it only removes around 3M from /usr/share/docs in my tests from against an unmodified target. The second part is that isar-exclude-docs is executed during the pacakge installation. Which makes it impossible to remove other files(e.g. /usr/bin/apt-*). > > Jan > Quirin -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/981ff797-16e0-408a-aa37-68bf7c1f03b5%40siemens.com. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] meta/classes: Add strip-image 2025-09-03 17:13 ` 'Quirin Gylstorff' via isar-users @ 2025-09-04 8:37 ` 'Jan Kiszka' via isar-users 2025-09-04 9:43 ` 'Quirin Gylstorff' via isar-users 0 siblings, 1 reply; 7+ messages in thread From: 'Jan Kiszka' via isar-users @ 2025-09-04 8:37 UTC (permalink / raw) To: Quirin Gylstorff, isar-users On 03.09.25 19:13, Quirin Gylstorff wrote: > > > On 9/3/25 18:19, Jan Kiszka wrote: >> On 03.09.25 17:20, 'Quirin Gylstorff' via isar-users wrote: >>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>> >>> This class provides the optional functionality to strip packages >>> and files from a image. This allows the user to reduce the image >>> size. >>> >>> IMPORTANT: This is an expert feature and can lead to broken images. >>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>> --- >>> >>> The default settings will reduce the space around 40MB. It is currently >>> a RFC to collect information about the usage. >>> >>> Should we integrate by default or should the user add this on demand? >>> For a default integration I would drop the deletion: >>> - /vmlinuz* >>> - /boot >>> - /usr/include >>> - initramfs-tools >>> >> >> The approach isar-exclude-docs takes for docs cannot be used here? And >> we want that approach to stay for cleaning docs? Or what is the relation >> between the two? > > We can use isar-exclude-docs or the use the same implementation. I > didn't use it as it only removes around 3M from /usr/share/docs in my > tests from against an unmodified target. > > The second part is that isar-exclude-docs is executed during the pacakge > installation. > Which makes it impossible to remove other files(e.g. /usr/bin/apt-*). > Would be great if we could have only one mechanism in the end that is powerful enough to express all removal scenarios. Jan -- Siemens AG, Foundational Technologies Linux Expert Center -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/90ba0364-32c4-4b41-afe7-9cc3e5deb1f1%40siemens.com. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] meta/classes: Add strip-image 2025-09-04 8:37 ` 'Jan Kiszka' via isar-users @ 2025-09-04 9:43 ` 'Quirin Gylstorff' via isar-users 2025-09-05 7:30 ` Andreas Naumann 0 siblings, 1 reply; 7+ messages in thread From: 'Quirin Gylstorff' via isar-users @ 2025-09-04 9:43 UTC (permalink / raw) To: Jan Kiszka, isar-users On 9/4/25 10:37, Jan Kiszka wrote: > On 03.09.25 19:13, Quirin Gylstorff wrote: >> >> >> On 9/3/25 18:19, Jan Kiszka wrote: >>> On 03.09.25 17:20, 'Quirin Gylstorff' via isar-users wrote: >>>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>>> >>>> This class provides the optional functionality to strip packages >>>> and files from a image. This allows the user to reduce the image >>>> size. >>>> >>>> IMPORTANT: This is an expert feature and can lead to broken images. >>>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>>> --- >>>> >>>> The default settings will reduce the space around 40MB. It is currently >>>> a RFC to collect information about the usage. >>>> >>>> Should we integrate by default or should the user add this on demand? >>>> For a default integration I would drop the deletion: >>>> - /vmlinuz* >>>> - /boot >>>> - /usr/include >>>> - initramfs-tools >>>> >>> >>> The approach isar-exclude-docs takes for docs cannot be used here? And >>> we want that approach to stay for cleaning docs? Or what is the relation >>> between the two? >> >> We can use isar-exclude-docs or the use the same implementation. I >> didn't use it as it only removes around 3M from /usr/share/docs in my >> tests from against an unmodified target. >> >> The second part is that isar-exclude-docs is executed during the pacakge >> installation. >> Which makes it impossible to remove other files(e.g. /usr/bin/apt-*). >> > > Would be great if we could have only one mechanism in the end that is > powerful enough to express all removal scenarios. That would be more possible with the proposed strip-image class as it works on post rootfs installation. I could extend the class for the copyrights case of isar-exclude-docs in a v2. Quirin > > Jan > -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/a638b2eb-ca8d-47dc-ac46-2075ecfaf35d%40siemens.com. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] meta/classes: Add strip-image 2025-09-04 9:43 ` 'Quirin Gylstorff' via isar-users @ 2025-09-05 7:30 ` Andreas Naumann 2025-09-05 8:43 ` 'Jan Kiszka' via isar-users 0 siblings, 1 reply; 7+ messages in thread From: Andreas Naumann @ 2025-09-05 7:30 UTC (permalink / raw) To: isar-users Hi, Am 04.09.25 um 11:43 schrieb 'Quirin Gylstorff' via isar-users: > > > On 9/4/25 10:37, Jan Kiszka wrote: >> On 03.09.25 19:13, Quirin Gylstorff wrote: >>> >>> >>> On 9/3/25 18:19, Jan Kiszka wrote: >>>> On 03.09.25 17:20, 'Quirin Gylstorff' via isar-users wrote: >>>>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>>>> >>>>> This class provides the optional functionality to strip packages >>>>> and files from a image. This allows the user to reduce the image >>>>> size. >>>>> >>>>> IMPORTANT: This is an expert feature and can lead to broken images. >>>>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>>>> --- >>>>> >>>>> The default settings will reduce the space around 40MB. It is >>>>> currently >>>>> a RFC to collect information about the usage. >>>>> >>>>> Should we integrate by default or should the user add this on demand? >>>>> For a default integration I would drop the deletion: >>>>> - /vmlinuz* >>>>> - /boot >>>>> - /usr/include >>>>> - initramfs-tools >>>>> >>>> >>>> The approach isar-exclude-docs takes for docs cannot be used here? And >>>> we want that approach to stay for cleaning docs? Or what is the >>>> relation >>>> between the two? >>> >>> We can use isar-exclude-docs or the use the same implementation. I >>> didn't use it as it only removes around 3M from /usr/share/docs in my >>> tests from against an unmodified target. >>> >>> The second part is that isar-exclude-docs is executed during the >>> pacakge >>> installation. >>> Which makes it impossible to remove other files(e.g. /usr/bin/apt-*). >>> >> >> Would be great if we could have only one mechanism in the end that is >> powerful enough to express all removal scenarios. > > That would be more possible with the proposed strip-image class as it > works on post rootfs installation. I could extend the class for the > copyrights case of isar-exclude-docs in a v2. I can image this being a more logical flow than adding packages to remove things, which feels a bit counter-intuitive to me. However, I had a quick look and there's already a few removal functions in the rootfs.class itself. I guess this is where default removals go? Coming from Embedded, I'm used to rootfs by default having no doc, man-pages, headers and so on. But maybe Isar has a different policy? Is it stated somewhere? regards, Andreas > > Quirin >> >> Jan >> > -- Andreas Naumann emlix GmbH Headquarters: Berliner Str. 12, 37073 Goettingen, Germany Phone +49 (0)551 30664-0, e-mail info@emlix.com District Court of Goettingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/89e1fec9-810a-4c1f-8c2b-e637a96157bb%40emlix.com. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] meta/classes: Add strip-image 2025-09-05 7:30 ` Andreas Naumann @ 2025-09-05 8:43 ` 'Jan Kiszka' via isar-users 0 siblings, 0 replies; 7+ messages in thread From: 'Jan Kiszka' via isar-users @ 2025-09-05 8:43 UTC (permalink / raw) To: Andreas Naumann, isar-users On 05.09.25 09:30, Andreas Naumann wrote: > Hi, > > Am 04.09.25 um 11:43 schrieb 'Quirin Gylstorff' via isar-users: >> >> >> On 9/4/25 10:37, Jan Kiszka wrote: >>> On 03.09.25 19:13, Quirin Gylstorff wrote: >>>> >>>> >>>> On 9/3/25 18:19, Jan Kiszka wrote: >>>>> On 03.09.25 17:20, 'Quirin Gylstorff' via isar-users wrote: >>>>>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>>>>> >>>>>> This class provides the optional functionality to strip packages >>>>>> and files from a image. This allows the user to reduce the image >>>>>> size. >>>>>> >>>>>> IMPORTANT: This is an expert feature and can lead to broken images. >>>>>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com> >>>>>> --- >>>>>> >>>>>> The default settings will reduce the space around 40MB. It is >>>>>> currently >>>>>> a RFC to collect information about the usage. >>>>>> >>>>>> Should we integrate by default or should the user add this on demand? >>>>>> For a default integration I would drop the deletion: >>>>>> - /vmlinuz* >>>>>> - /boot >>>>>> - /usr/include >>>>>> - initramfs-tools >>>>>> >>>>> >>>>> The approach isar-exclude-docs takes for docs cannot be used here? And >>>>> we want that approach to stay for cleaning docs? Or what is the >>>>> relation >>>>> between the two? >>>> >>>> We can use isar-exclude-docs or the use the same implementation. I >>>> didn't use it as it only removes around 3M from /usr/share/docs in my >>>> tests from against an unmodified target. >>>> >>>> The second part is that isar-exclude-docs is executed during the >>>> pacakge >>>> installation. >>>> Which makes it impossible to remove other files(e.g. /usr/bin/apt-*). >>>> >>> >>> Would be great if we could have only one mechanism in the end that is >>> powerful enough to express all removal scenarios. >> >> That would be more possible with the proposed strip-image class as it >> works on post rootfs installation. I could extend the class for the >> copyrights case of isar-exclude-docs in a v2. > > I can image this being a more logical flow than adding packages to > remove things, which feels a bit counter-intuitive to me. > > However, I had a quick look and there's already a few removal functions > in the rootfs.class itself. I guess this is where default removals go? > > Coming from Embedded, I'm used to rootfs by default having no doc, man- > pages, headers and so on. But maybe Isar has a different policy? Is it > stated somewhere? Isar is first of all installing real Debian systems, mostly from original Debian packages. That is primarily happening for embedded scenarios, but you can also use isar to define desktop images that will later on be configured and updated by an administrator, the classic way. So, removing things for embedded, locked-down images should be some opt-in feature that you can request in your image recipe. Jan -- Siemens AG, Foundational Technologies Linux Expert Center -- You received this message because you are subscribed to the Google Groups "isar-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/isar-users/afb4f33e-4054-4b64-913f-9f5839e3a83a%40siemens.com. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-09-05 8:43 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-09-03 15:20 [RFC PATCH] meta/classes: Add strip-image 'Quirin Gylstorff' via isar-users 2025-09-03 16:19 ` 'Jan Kiszka' via isar-users 2025-09-03 17:13 ` 'Quirin Gylstorff' via isar-users 2025-09-04 8:37 ` 'Jan Kiszka' via isar-users 2025-09-04 9:43 ` 'Quirin Gylstorff' via isar-users 2025-09-05 7:30 ` Andreas Naumann 2025-09-05 8:43 ` 'Jan Kiszka' via isar-users
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox