Apologies, but please no. This adds complexity, isn't possible to disable
and is difficult to understand. You can simply remove the unneeded files
from ROOTFS_POSTPROCESS_COMMAND in your image class.

Alex

On Wed, 19 Jan 2022 at 04:07, hongxu <hongxu....@windriver.com> wrote:

> In order to save spaces in target rootfs, the user wants to remove dnf and
> keep rpm, in this situation, we should remove dnf database only
>
> If rpm was installed, keep rpm database, after applying this commit:
>
> Edit conf/local.conf
> ...
> IMAGE_FEATURES:remove = "package-management"
> IMAGE_INSTALL:append= " rpm"
> ...
>
> Build image and boot, run rpm -qa on target:
> Without this commit
> ...
> root@intel-x86-64:~# rpm -qa | wc -l
> 0
> ...
>
> Apply this commit
> ...
> root@intel-x86-64:~# rpm -qa | wc -l
> 1865
> ...
>
> With this commit, the rpm -qa works as expected.
>
> It does not make sense to keep dnf and remove rpm, so this commit
> does not consider the scenario
>
> Signed-off-by: Hongxu Jia <hongxu....@windriver.com>
> ---
>  meta/lib/oe/package_manager/rpm/__init__.py | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/meta/lib/oe/package_manager/rpm/__init__.py
> b/meta/lib/oe/package_manager/rpm/__init__.py
> index b392581069..dce5912329 100644
> --- a/meta/lib/oe/package_manager/rpm/__init__.py
> +++ b/meta/lib/oe/package_manager/rpm/__init__.py
> @@ -80,7 +80,9 @@ class RpmPM(PackageManager):
>          self.saved_packaging_data =
> self.d.expand('${T}/saved_packaging_data/%s' % self.task_name)
>          if not os.path.exists(self.d.expand('${T}/saved_packaging_data')):
>              bb.utils.mkdirhier(self.d.expand('${T}/saved_packaging_data'))
> -        self.packaging_data_dirs = ['etc/rpm', 'etc/rpmrc', 'etc/dnf',
> 'var/lib/rpm', 'var/lib/dnf', 'var/cache/dnf']
> +        self.packaging_data_rpm_dirs = ['etc/rpm', 'etc/rpmrc',
> 'var/lib/rpm']
> +        self.packaging_data_dnf_dirs = ['etc/dnf', 'var/lib/dnf',
> 'var/cache/dnf']
> +        self.packaging_data_dirs = self.packaging_data_rpm_dirs +
> self.packaging_data_dnf_dirs
>          self.solution_manifest = self.d.expand('${T}/saved/%s_solution' %
>                                                 self.task_name)
>          if not os.path.exists(self.d.expand('${T}/saved')):
> @@ -237,8 +239,11 @@ class RpmPM(PackageManager):
>          self._invoke_dnf(["autoremove"])
>
>      def remove_packaging_data(self):
> +        remove_packaging_data_dirs = self.packaging_data_dnf_dirs
> +        if "rpm" not in self.list_installed():
> +            remove_packaging_data_dirs += self.packaging_data_rpm_dirs
>          self._invoke_dnf(["clean", "all"])
> -        for dir in self.packaging_data_dirs:
> +        for dir in remove_packaging_data_dirs:
>              bb.utils.remove(oe.path.join(self.target_rootfs, dir), True)
>
>      def backup_packaging_data(self):
> --
> 2.27.0
>
>
> 
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#160691): 
https://lists.openembedded.org/g/openembedded-core/message/160691
Mute This Topic: https://lists.openembedded.org/mt/88527238/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to