I cannot find definite information about how a debian package should behave whilst being removed. Should it remove the data? E.g. for mysql I read data is kept which sounds logical to me (using purge will remove all stuff).
But here I found the text:
The difference between remove and purge is that while remove only deletes data and executables, purge also deletes all configuration files in addition.
So, what is true?
Update As I want to package one for ElasticSearch I need to know what is expected.
Neither purge or remove will delete the mysql datadir.. see example
I think the "data" it is referring to is any nonexecutable resources shipped in the package, e.g. things found in /usr/share. Are you specifically concerned about mysql, or another package?
If data is valuable to you you should be backing it up anyway.
As I want to package one for ElasticSearch I need to know what is expected.
If I understand you correctly, you are in the process of packaging ElasticSearch as .deb for distribution.
If that is the case, and you are building a .deb package for public distribution I recommend you 1) fully read the relevant sections on packaging in the Debian Developer's Reference and ask on the appropriate Debian mailing-list (probably Debian-Developer).
Generally speaking,
remove
will just remove the binaries and libraries associated with a package whilepurge
will remove the binaries, libraries, documentation, and configuration files. It is considered bad form for your package to nuke the user's data without at least informing them first.I really suggest you check with an experienced Debian Maintainer before deciding how to proceed - especially if you want to submit this package to Debian repositories.
Another word of device: As a long-time Debian user, almost nothing annoys me more than a 3rd party distributing their software as a .deb that does follow standard Debian conventions. If you want to keep your users, please ensure that your package is well maintained and meets the guidelines as laid out by the Debian team.