Upgrade step to remove profile

We have one package that we identify that we don't need it's profile (collective.js.cycle2) so I need to write an upgrade step to remove the existent profile.

Looking at the code I usually have to update profile, I found that in the end it calls: portal_setup.runAllImportStepsFromProfile(profile, purge_old=False)

Is it a good practice to run portal_setup.runAllImportStepsFromProfile(profile, purge_old=True) to remove the profile? ( I didn't find anything at plone.app.upgrade.utils.py to make it).

After testing a little I saw that I shoud read more about generic setup first.. and the right way to go is to mark every resource to be removed like documentation suggest

Technically speaking, there's no such thing as "removing a profile" in Generic Setup. You can only import new profiles (or run upgrade steps), yet the imported profile may also remove configuration with remove attribute, as you have found out.

Because the "add-on" panel probably only displays add-ons with a profile, you cannot simply remove the profile, but you usually have to make the default profile empty and configure an upgrade step to clear up the old configuration. And only remove the profile registration from zcml only in some major version.

But there's also a non-obvious alternative. Add-on activation is executed through an old product called QuickInstaller. QuickInstaller records state changes for most of the profile import steps (including jsregistry and browserlayers [by uninstalling utilities]) and tries to revert those, when add-on is deactivated. That's why it could be enough to "deactivate" the product on add-on screen (or uninstall in portal_quickinstaller at ZMI). Yet, this is a bit magical and therefore an explicit "upgrade step" could be a better choice.

thank you very much for the answer @datakurre

@keul also pointed this article as reference at stackoverflow (pasting here for historical purposes)