I am afraid doing remove operation in ROOTFS_POSTPROCESS_COMMAND could not 
satisfy this case


The background is in order to save spaces in embedded device, user do not 
install

package dnf which introduces python3, and use rpm to manage package on target


In oe-core, the dnf, rpm and pkg database are introduced by package-management 
of IMAGE_FEATURES,

if package-management in IMAGE_FEATURES, we could remove unused pkg data in

ROOTFS_POSTPROCESS_COMMAND as you suggested, but we could not uninstall

dnf and all related depend(such as python3) gracefully;

if package-management not in IMAGE_FEATURES, the pkg data will be removed

before ROOTFS_POSTPROCESS_COMMAND, that's why this commit are trying to resolve


The root cause maybe dnf is too heavy for disk sensitive device


//Hongxu

________________________________
From: Alexander Kanavin <alex.kana...@gmail.com>
Sent: Wednesday, January 19, 2022 6:15 PM
To: Jia, Hongxu <hongxu....@windriver.com>
Cc: OE-core <openembedded-core@lists.openembedded.org>; Yang, Liezhi 
<liezhi.y...@windriver.com>
Subject: Re: [OE-core] [PATCH] package_manager/rpm: conditional remove package 
manager database


[Please note: This e-mail is from an EXTERNAL e-mail address]

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<mailto: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<mailto:hongxu....@windriver.com>>
---
 
meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__http://__init__.py__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv$>
 | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git 
a/meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__http://__init__.py__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv$>
 
b/meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__http://__init__.py__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv$>
index b392581069..dce5912329 100644
--- 
a/meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__http://__init__.py__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv$>
+++ 
b/meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__http://__init__.py__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv$>
@@ -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 (#160748): 
https://lists.openembedded.org/g/openembedded-core/message/160748
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