Build a package that distinguishes upgrade and removal

I'm working in a team where we build a custom OpenWrt package that is installed manually by the user and not included in a firmware image.

Everything works great so far, the package can be installed, upgraded and removed.

The issue we are having concerns the upgrading and removal of packages.
The application that comes with the package, creates persistent files on the OpenWrt system. These files must not be deleted during a package upgrade but should be deleted when the package is removed. Can this be realised with the package management?

Right now we just leave the files and don't remove them at all as a workaround because we can't find a way to distinguish between a removal or upgrade of a package.

1 Like

postrm in initscript should be the solution.


Thanks for your reply!

I'm not sure how this can be achieved. postrm and prerm are both executed when the package is removed or upgraded.