Bug 10461

Summary: Uninstall leaks common directories if packages removed out-of-order
Product: [Yocto Project Subprojects] opkg Reporter: Gabe Jones <gabe.jones>
Component: opkgAssignee: Alex Stewart <alex.stewart>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided CC: alex.stewart
Version: 0.3.3   
Target Milestone: next-minor   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
Packages used in the reproducing case none

Description Gabe Jones 2016-10-19 19:06:55 UTC
Created attachment 3482 [details]
Packages used in the reproducing case

What steps will reproduce the problem?

opkg install test-package-1_1.0_core2-64.ipk
opkg install test-package-2_1.0_core2-64.ipk
opkg remove test-package-1
opkg remove test-package-2
find /tmp/commondir/


What is the expected output? What do you see instead?

Expect /tmp/commondir to be removed.  It remains.

What version of the product are you using?

0.3.3
Comment 1 Alejandro del Castillo 2017-04-27 20:47:29 UTC
Looking at the .list files (/var/lib/opkg/lists):

test-package-1.list

/
/tmp
/tmp/commondir
/tmp/commondir/package1
/tmp/commondir/package1/dummy

test-package-2.list

/tmp/commondir/package2
/tmp/commondir/package2/dummy

Opkg is only tracking the new files/directories that a package is installing, not the files/directories that the package payload contains. Comparing with dpkg .lists:

test-package-1.list

/.
/tmp
/tmp/commondir
/tmp/commondir/package1
/tmp/commondir/package1/dummy

test-package-2.list

/.
/tmp
/tmp/commondir
/tmp/commondir/package2
/tmp/commondir/package2/dummy

Opkg keeps the files/directories ownership in a hash (opkg_config->file_hash), which helps detect conflicts, but doesn't make any distinction between files/directories. Seems like opkg needs to write to the .list file the info from data.tar.gz, not from opkg_config->file_hash. This change is substantial, so I am re-targeting the fix for a later version.
Comment 2 Alex Stewart 2022-09-09 21:12:17 UTC
Resolved by Shruthi Ravichandran's patch [1].

[1] https://groups.google.com/g/opkg-devel/c/tUlw8yW9tVU