Message ID | 20210906094510.9589-1-venkata.pyla@toshiba-tsip.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | rootfs: Add new ROOTFS_FEATURE 'slimfy' to minimize the footprint | expand |
On 06.09.21 11:45, venkata.pyla@toshiba-tsip.com wrote: > From: venkata pyla <venkata.pyla@toshiba-tsip.com> > > This Adds new ROOTFS_FEATURE 'slimify' that deletes unnecessary files > in the rootfs and contributes to minimal footprint in the rootfs and > also avoids the reproducible failures due to non-deterministic data in > the log files and temporary files. > > It deletes the following files > - /var/log/* > - /tmp/* > > To enable this feature > ROOTFS_FEATURE += slimify > > Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com> > --- > meta/classes/rootfs.bbclass | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass > index f9151c5..d01a9d1 100644 > --- a/meta/classes/rootfs.bbclass > +++ b/meta/classes/rootfs.bbclass > @@ -12,6 +12,7 @@ ROOTFS_PACKAGES ?= "" > # 'clean-package-cache' - delete package cache from rootfs > # 'generate-manifest' - generate a package manifest of the rootfs into ${ROOTFS_MANIFEST_DEPLOY_DIR} > # 'export-dpkg-status' - exports /var/lib/dpkg/status file to ${ROOTFS_DPKGSTATUS_DEPLOY_DIR} > +# 'slimify' - delete unnecessary files in rootfs like /var/log/*, /tmp/* /tmp should be emptied unconditionally. I'm also wondering if we should rather permit to preserving logs for debugging purposes and make deletion the default as well. Jan > ROOTFS_FEATURES ?= "" > > ROOTFS_APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes" > @@ -229,6 +230,12 @@ rootfs_export_dpkg_status() { > '${ROOTFS_DPKGSTATUS_DEPLOY_DIR}'/'${PF}'.dpkg_status > } > > +ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'slimify', 'rootfs_slimify', '', d)}" > +rootfs_slimify() { > + sudo rm -rf "${ROOTFSDIR}/var/log/"* > + sudo rm -rf "${ROOTFSDIR}/tmp/"* > +} > + > do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}" > python do_rootfs_postprocess() { > # Take care that its correctly mounted: >
IMHO no need to model that as a feature. Removing "temporary" files that do not belong to packages is something everybody would expect anyways. Am Mon, 6 Sep 2021 15:15:10 +0530 schrieb <venkata.pyla@toshiba-tsip.com>: > From: venkata pyla <venkata.pyla@toshiba-tsip.com> > > This Adds new ROOTFS_FEATURE 'slimify' that deletes unnecessary files > in the rootfs and contributes to minimal footprint in the rootfs and > also avoids the reproducible failures due to non-deterministic data > in the log files and temporary files. > > It deletes the following files > - /var/log/* > - /tmp/* > > To enable this feature > ROOTFS_FEATURE += slimify > > Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com> > --- > meta/classes/rootfs.bbclass | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass > index f9151c5..d01a9d1 100644 > --- a/meta/classes/rootfs.bbclass > +++ b/meta/classes/rootfs.bbclass > @@ -12,6 +12,7 @@ ROOTFS_PACKAGES ?= "" > # 'clean-package-cache' - delete package cache from rootfs > # 'generate-manifest' - generate a package manifest of the rootfs > into ${ROOTFS_MANIFEST_DEPLOY_DIR} # 'export-dpkg-status' - exports > /var/lib/dpkg/status file to ${ROOTFS_DPKGSTATUS_DEPLOY_DIR} +# > 'slimify' - delete unnecessary files in rootfs like > /var/log/*, /tmp/* ROOTFS_FEATURES ?= "" > ROOTFS_APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes" > @@ -229,6 +230,12 @@ rootfs_export_dpkg_status() { > '${ROOTFS_DPKGSTATUS_DEPLOY_DIR}'/'${PF}'.dpkg_status > } > > +ROOTFS_POSTPROCESS_COMMAND += > "${@bb.utils.contains('ROOTFS_FEATURES', 'slimify', 'rootfs_slimify', > '', d)}" +rootfs_slimify() { > + sudo rm -rf "${ROOTFSDIR}/var/log/"* This is going too far because you are removing package content i.e. dpkg -S /var/log/apt apt: /var/log/apt If packages ship directories or maybe even files we can not simply delete those. And overall the change is not going far enough. Because i.e. /var/lib and /var/cache remain as problems. Instead of listing a bunch of directories we should really go and ask the package manager which files are without owner. Henning > + sudo rm -rf "${ROOTFSDIR}/tmp/"* > +} > + > do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}" > python do_rootfs_postprocess() { > # Take care that its correctly mounted:
diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass index f9151c5..d01a9d1 100644 --- a/meta/classes/rootfs.bbclass +++ b/meta/classes/rootfs.bbclass @@ -12,6 +12,7 @@ ROOTFS_PACKAGES ?= "" # 'clean-package-cache' - delete package cache from rootfs # 'generate-manifest' - generate a package manifest of the rootfs into ${ROOTFS_MANIFEST_DEPLOY_DIR} # 'export-dpkg-status' - exports /var/lib/dpkg/status file to ${ROOTFS_DPKGSTATUS_DEPLOY_DIR} +# 'slimify' - delete unnecessary files in rootfs like /var/log/*, /tmp/* ROOTFS_FEATURES ?= "" ROOTFS_APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes" @@ -229,6 +230,12 @@ rootfs_export_dpkg_status() { '${ROOTFS_DPKGSTATUS_DEPLOY_DIR}'/'${PF}'.dpkg_status } +ROOTFS_POSTPROCESS_COMMAND += "${@bb.utils.contains('ROOTFS_FEATURES', 'slimify', 'rootfs_slimify', '', d)}" +rootfs_slimify() { + sudo rm -rf "${ROOTFSDIR}/var/log/"* + sudo rm -rf "${ROOTFSDIR}/tmp/"* +} + do_rootfs_postprocess[vardeps] = "${ROOTFS_POSTPROCESS_COMMAND}" python do_rootfs_postprocess() { # Take care that its correctly mounted: