| Summary: | [libsolv] Replacing a package runs the installation scripts in an unexpected order | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Yocto Project Subprojects] opkg | Reporter: | Paul Spangler <paul.spangler> | ||||
| Component: | opkg | Assignee: | Alejandro del Castillo <alejandro.delcastillo> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | Undecided | ||||||
| Version: | 0.3.4 | ||||||
| Target Milestone: | 0.3.6 | ||||||
| Hardware: | x86 | ||||||
| OS: | x86_64 | ||||||
| Whiteboard: | |||||||
| OS type for building Yocto: | --- | Type of Regression: | --- | ||||
| Verified: | Documentation change: | Don't know | |||||
| Attachments: |
|
||||||
this is not a problem with the internal solver (a is installed, and b replaces/conflicts/provides a): adelcast@delcastillo2 ~/git/opkg/tests $ opkg -o /tmp/opkg --force-postinstall install b Removing a (1.0) from root... prerm a postrm a Installing b (1.0) on root. Downloading file:/tmp/opk/b_1.0_all.opk. preinst b Configuring b. postinst b I believe this is a bug with the default ordering give by libsolv, when transaction_order is being called. I opened a bug report to libsolv to get this addressed [1] As a workaround, we could alter the ordering manually, making sure we do the removal operations before the install/upgrade ones. [1] https://github.com/openSUSE/libsolv/issues/194 Digging deeper, this is not a libsolv issue, but an issue with opkg. The operation described in this ticket is best described as an upgrade, instead of as a erase/install pair. An upgrade allows config data to be migrated, which is not possible if you first remove a package, then install it's replacement. The flags SOLVER_TRANSACTION_SHOW_OBSOLETES && SOLVER_TRANSACTION_OBSOLETE_IS_UPGRADE tells libsolv to represent this operation as an upgrade, which is what we want. However, to be able to use this flags, opkg upgrade operation needs to support the case where you are upgrading from packages with different names. The work to get this implemented sounds substantial, I'll try to get it in for 0.3.5, but might need to be defered to 0.3.6. fixed on commit b3f0f7cf02c6f9eb4eaf985a806aec9333164cf5 |
Created attachment 3721 [details] Example reproduction packages When two packages have a Provides, Conflicts, and Replaces for the same virtual package, installing either one will automatically remove (replace) the other. However, opkg runs the installation scripts of the two packages in an unexpected order. Specifically, it runs the preinst of the replacing package prior to running the prerm of the replaced package. See the attached packages that don't install any files but replace one another. Expectation ----------- Either run the scripts like an upgrade (prerm of the old, preinst of the new, replace files, postrm of the old, postinst of the new) or completely remove the replaced package first. apt appears to do the latter: $ apt-get -v apt 1.2.19 (amd64) $ sudo apt-get install --allow-unauthenticated -o Acquire::ForceHash=md5sum test-package-2 The following packages will be REMOVED: test-package-1:x64 The following NEW packages will be installed: test-package-2:x64 0 upgraded, 1 newly installed, 1 to remove and 1 not upgraded. Need to get 838 B of archives. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Get:1 ... test-package-2 1.0.0-1 [838 B] Fetched 838 B in 0s (56.5 kB/s) (Reading database ... 319302 files and directories currently installed.) Removing test-package-1:x64 (1.0.0-1) ... Running prerm script from /var/lib/dpkg/info/test-package-1.prerm Running postrm script from /var/lib/dpkg/info/test-package-1.postrm (Reading database ... 319304 files and directories currently installed.) Preparing to unpack .../test-package-2_1.0.0-1_x64.ipk ... Running preinst script from /var/lib/dpkg/tmp.ci/preinst Unpacking test-package-2:x64 (1.0.0-1) ... Setting up test-package-2:x64 (1.0.0-1) ... Running postinst script from /var/lib/dpkg/info/test-package-2.postinst Actual Result ------------- # opkg -v opkg version 0.3.4 (libsolv 0.6.24) # opkg install test-package-2 Installing test-package-2 (1.0.0) on root Running preinst script from /tmp/opkg-jJumYW/test-package-2-JoBT1z/preinst Removing test-package-1 (1.0.0) from root... Running prerm script from ///var/lib/opkg/info/test-package-1.prerm Running postrm script from ///var/lib/opkg/info/test-package-1.postrm Configuring test-package-2. Running postinst script from ///var/lib/opkg/info/test-package-2.postinst