Skip to contentSkip to conversation

package_manager/rpm: conditional remove package manager database

PATCH In review Hongxu Jia 3 participants 6 messages Jan 19, 2022 – Jan 20, 2022

lore
Share & tools
lore

Hongxu Jia

author
#0 lore raw

PATCH 1/1 package_manager/rpm: conditional remove package manager database

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

---
 meta/lib/oe/package_manager/rpm/__init__.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/lib/oe/package_manager/rpm/__init__.py +7 -2
index b392581069..dce5912329 100644
@@ -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):
Signature · 1 line
2.27.0
#1 lore raw

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

Quoted 83 lines · hongxu

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

---
 meta/lib/oe/package_manager/rpm/__init__.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/lib/oe/package_manager/rpm/__init__.py +0 -1
index b392581069..dce5912329 100644
@@ -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')):
meta/lib/oe/package_manager/rpm/__init__.py +4 -2
@@ -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 (#160688):
https://lists.openembedded.org/g/openembedded-core/message/160688
Mute This Topic: https://lists.openembedded.org/mt/88527238/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

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 <[email protected]>
Sent: Wednesday, January 19, 2022 6:15 PM
To: Jia, Hongxu <[email protected]>
Cc: OE-core <[email protected]>; Yang, Liezhi <[email protected]>
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 <[email protected]<mailto:[email protected]>> 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

---
 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(-)
meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__http://__init__.py__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv$> +7 -2
index b392581069..dce5912329 100644
@@ -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 (#160688): https://lists.openembedded.org/g/openembedded-core/message/160688<https://urldefense.com/v3/__https://lists.openembedded.org/g/openembedded-core/message/160688__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvQbTscth$>
Mute This Topic: https://lists.openembedded.org/mt/88527238/1686489<https://urldefense.com/v3/__https://lists.openembedded.org/mt/88527238/1686489__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvcAr3fEL$>
Group Owner: [email protected]<mailto:openembedded-core%[email protected]>
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub<https://urldefense.com/v3/__https://lists.openembedded.org/g/openembedded-core/unsub__;!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvd7bfWZw$> [[email protected]<mailto:[email protected]>]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

Hi,

We do exactly that in our images, keep rpm but avoid dnf. We do it by adding this to the image recipes (via in inc file).

ROOTFS_PKGMANAGE_remove = "dnf" ROOTFS_POSTUNINSTALL_COMMAND += "spx_wipe_dnf_data ; "

spx_wipe_dnf_data() {
bbnote "Removing all dnf runtime data"
for d in /var/lib/dnf /var/cache/dnf; do
[ -d ${IMAGE_ROOTFS}$d ] || continue dirsize=du -ks ${IMAGE_ROOTFS}/$d | awk '{ print $1 }' bbnote "Removing $d with $dirsize KiB"
rm -rf ${IMAGE_ROOTFS}$d/*
done
}

I hope this helps

--
Diego Santa Cruz, PhD
Technology Architect
spinetix.com

From: [email protected] <[email protected]> On Behalf Of hongxu via lists.openembedded.org
Sent: 20 January 2022 03:54
To: Alexander Kanavin <[email protected]>
Cc: OE-core <[email protected]>; Yang, Liezhi <[email protected]>
Subject: Re: [OE-core] [PATCH] package_manager/rpm: conditional remove package manager database

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 <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 19, 2022 6:15 PM
To: Jia, Hongxu <[email protected]<mailto:[email protected]>>
Cc: OE-core <[email protected]<mailto:[email protected]>>; Yang, Liezhi <[email protected]<mailto:[email protected]>>
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 <[email protected]<mailto:[email protected]>> 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

---
 meta/lib/oe/package_manager/rpm/__init__.py<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__http%3A%2F%2F__init__.py__%3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv%24&data=04%7C01%7Cdiego.santacruz%40spinetix.com%7Ccfe2bf45c56e4efe23b608d9dbc02521%7C5f4034faed2d4840a93facb1e9633b93%7C0%7C0%7C637782440578878242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=i0%2B51iSlYuayK9kClXpEUxk%2FhpzlSMHHkNLpa7%2BDSWc%3D&reserved=0> | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/lib/oe/package_manager/rpm/__init__.py<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Furldefense.com%2Fv3%2F__http%3A%2F%2F__init__.py__%3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv%24&data=04%7C01%7Cdiego.santacruz%40spinetix.com%7Ccfe2bf45c56e4efe23b608d9dbc02521%7C5f4034faed2d4840a93facb1e9633b93%7C0%7C0%7C637782440578878242%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=i0%2B51iSlYuayK9kClXpEUxk%2FhpzlSMHHkNLpa7%2BDSWc%3D&reserved=0> +7 -2
index b392581069..dce5912329 100644
@@ -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

#4 lore raw

On 1/20/22 14:34, Diego Santa Cruz wrote:
[Please note: This e-mail is from an EXTERNAL e-mail address] Hi,

We do exactly that in our images, keep rpm but avoid dnf. We do it by adding this to the image recipes (via in inc file).

ROOTFS_PKGMANAGE_remove = "dnf" ROOTFS_POSTUNINSTALL_COMMAND += "spx_wipe_dnf_data ; "

spx_wipe_dnf_data() {
bbnote "Removing all dnf runtime data"
for d in /var/lib/dnf /var/cache/dnf; do
[ -d ${IMAGE_ROOTFS}$d ] || continue dirsize=du -ks ${IMAGE_ROOTFS}/$d | awk '{ print $1 }' bbnote "Removing $d with $dirsize KiB"
rm -rf ${IMAGE_ROOTFS}$d/*
done
}

Yes, it helps, thank you very much

//Hongxu
I hope this helps

--
Diego Santa Cruz, PhD
Technology Architect spinetix.com<https://urldefense.com/v3/__http://spinetix.com__;!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxd2SHbwc$>

From: [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]> On Behalf Of hongxu via lists.openembedded.org<https://urldefense.com/v3/__http://lists.openembedded.org__;!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8CxZKo62pc$>
Sent: 20 January 2022 03:54
To: Alexander Kanavin <[email protected]><mailto:[email protected]>
Cc: OE-core <[email protected]><mailto:[email protected]>; Yang, Liezhi <[email protected]><mailto:[email protected]>
Subject: Re: [OE-core] [PATCH] package_manager/rpm: conditional remove package manager database

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 <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 19, 2022 6:15 PM
To: Jia, Hongxu <[email protected]<mailto:[email protected]>>
Cc: OE-core <[email protected]<mailto:[email protected]>>; Yang, Liezhi <[email protected]<mailto:[email protected]>>
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 <[email protected]<mailto:[email protected]>> 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

---
 meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$> | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$> +7 -2
index b392581069..dce5912329 100644
@@ -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

#5 lore raw

I think we could address this properly by adding a 'package-database' image feature?

Alex

Quoted 215 lines · Hongxu

On 1/20/22 14:34, Diego Santa Cruz wrote:

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

Hi,

We do exactly that in our images, keep rpm but avoid dnf. We do it by adding this to the image recipes (via in inc file).

ROOTFS_PKGMANAGE_remove = "dnf"

ROOTFS_POSTUNINSTALL_COMMAND += "spx_wipe_dnf_data ; "

spx_wipe_dnf_data() {

bbnote "Removing all dnf runtime data"

for d in /var/lib/dnf /var/cache/dnf; do

[ -d ${IMAGE_ROOTFS}$d ] || continue

dirsize=du -ks ${IMAGE_ROOTFS}/$d | awk '{ print $1 }'

bbnote "Removing $d with $dirsize KiB"

rm -rf ${IMAGE_ROOTFS}$d/*

done

}

Yes, it helps, thank you very much

//Hongxu

I hope this helps

--

*Diego Santa Cruz, PhD *Technology Architect
spinetix.com
<https://urldefense.com/v3/__http://spinetix.com__;!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxd2SHbwc$>

*From:* [email protected] <[email protected]> <[email protected]> *On Behalf Of *hongxu via lists.openembedded.org
<https://urldefense.com/v3/__http://lists.openembedded.org__;!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8CxZKo62pc$>
*Sent:* 20 January 2022 03:54
*To:* Alexander Kanavin <[email protected]> <[email protected]> *Cc:* OE-core <[email protected]> <[email protected]>; Yang, Liezhi <[email protected]> <[email protected]> *Subject:* Re: [OE-core] [PATCH] package_manager/rpm: conditional remove package manager database

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 <[email protected]>
*Sent:* Wednesday, January 19, 2022 6:15 PM
*To:* Jia, Hongxu <[email protected]>
*Cc:* OE-core <[email protected]>; Yang, Liezhi < [email protected]>
*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 <[email protected]> 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

---
meta/lib/oe/package_manager/rpm/__init__.py
<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$>
| 9 +++++++--

 1 file changed, 7 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$>
b/meta/lib/oe/package_manager/rpm/__init__.py
<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$>
index b392581069..dce5912329 100644
--- a/meta/lib/oe/package_manager/rpm/__init__.py
<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$>
+++ b/meta/lib/oe/package_manager/rpm/__init__.py
<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$>

(quoted diff) +0 -1
@@ -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')):
meta/lib/oe/package_manager/rpm/__init__.py<https://urldefense.com/v3/__https://eur02.safelinks.protection.outlook.com/?url=https*3A*2F*2Furldefense.com*2Fv3*2F__http*3A*2F*2F__init__.py__*3B!!AjveYdw8EvQ!JHTMzGi0-aiMoNjIt7Jb186B-p8VNKpv_Yrm-v87Li0GFTZf07eaSBP1gIDKvdp1Putv*24&data=04*7C01*7Cdiego.santacruz*40spinetix.com*7Ccfe2bf45c56e4efe23b608d9dbc02521*7C5f4034faed2d4840a93facb1e9633b93*7C0*7C0*7C637782440578878242*7CUnknown*7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0*3D*7C3000&sdata=i0*2B51iSlYuayK9kClXpEUxk*2FhpzlSMHHkNLpa7*2BDSWc*3D&reserved=0__;JSUlJSUlJSUlJSUlJSUlJSUlJSUlJSUlJSU!!AjveYdw8EvQ!P_Qo8UNa9oH3Xr8z3HrU_xtzKsKiL3G0BxR5ApZ1zjZT1dhR0-6zDAqCXf8Cxamel_UX$> +4 -2
@@ -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