Bug 10446 - opkg upgrade script execute order
Summary: opkg upgrade script execute order
Status: RESOLVED NOTABUG
Alias: None
Product: opkg
Classification: Yocto Project Subprojects
Component: opkg (show other bugs)
Version: 0.3.3
Hardware: Other Multiple
: Undecided normal
Target Milestone: ---
Assignee: Alejandro del Castillo
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-10-17 16:12 UTC by betacentauri
Modified: 2016-10-24 17:22 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
Upgrade State Diagram (106.01 KB, image/jpeg)
2016-10-24 17:15 UTC, Alejandro del Castillo
no flags Details
Remove State Diagram (40.53 KB, image/jpeg)
2016-10-24 17:16 UTC, Alejandro del Castillo
no flags Details
Install State Diagram (46.93 KB, image/jpeg)
2016-10-24 17:16 UTC, Alejandro del Castillo
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description betacentauri 2016-10-17 16:12:02 UTC
In case of an upgrade does opkg execute the scripts in this order:
prerm (old pkg)
preinst (new pkg)
postrm (old pkg)
postinst (new pkg)

See here:
http://git.yoctoproject.org/cgit/cgit.cgi/opkg/tree/libopkg/opkg_install.c#n886

Is this order correct?
At least at the moment it doesn't work for avahi-daemon package. preinst generates user and group and postrm script deletes them afterwards.

See also this bugs for details:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=10299#c4
https://bugzilla.yoctoproject.org/show_bug.cgi?id=10442

But even if users are not deleted in postrm script, shouldn't be postrm executed before preinst script?
Comment 1 Alejandro del Castillo 2016-10-24 17:15:47 UTC
Created attachment 3488 [details]
Upgrade State Diagram
Comment 2 Alejandro del Castillo 2016-10-24 17:16:12 UTC
Created attachment 3489 [details]
Remove State Diagram
Comment 3 Alejandro del Castillo 2016-10-24 17:16:29 UTC
Created attachment 3490 [details]
Install State Diagram
Comment 4 Alejandro del Castillo 2016-10-24 17:22:57 UTC
The maintainer scripts execution order of opkg is the same one used by dpkg [1]. I attached the state diagrams used by opkg remove/install/upgrade operations, which is basically a simplified version of the dpkg states.

The thing lacking on opkg is the failover states used in dpkg. On dpkg, if a "prerm upgrade" operation fails, then the new package prerm is called with 'failed-upgrade', which let's you potentially recover.

However, none of those states are currently used by OE, so dpkg and opkg should fail in the same manner (not too familiar with rpm to know if that's the case there too). The caveat is that the dpkg backend completely disables prerm && postrm scripts during upgrades.  

So, in summary, I think opkg behavior is correct. For OE, we could either go with the nuclear option or make the scripts more robust (preferred).


[1] https://wiki.debian.org/MaintainerScripts