EDIT: updated this question with latest information...
I'm having issues running back-to-back "features:uninstall" commands for dependent features. OSGi responds back with "State change in progress...", but by accepting other requests, we run into issues.
Strangely, this results in successful feature uninstalls, but unsuccessful bundle uninstalls. We are addressing this by trying to order uninstall requests appropriately and adding a delay between steps, but I'm hoping for a more robust solution.
As suggested, I also tried adding "osgi:refresh" in between steps...same behavior. Is there another way to detect that "Refresh Packages" is still running to delay subsequent requests, etc?
Here are the details...
karaf@root> features:uninstall PolicyUtil
karaf@root> features:uninstall Policy1
karaf@root> features:uninstall Policy2
State change in progress for bundle "file:/policy2.jar" by thread "Refresh Packages".
karaf@root> features:uninstall Policy3
State change in progress for bundle "file:/policy3.jar" by thread "Refresh Packages".
karaf@root> features:uninstall Policy4
karaf@root> features:uninstall Enabler1
State change in progress for bundle "file:/enabler1.jar" by thread "Refresh Packages".
karaf@root> features:uninstall Enabler2
State change in progress for bundle "file:/enabler2.jar" by thread "Refresh Packages".
afterwards...we end up with features uninstalled (correct), but some bundles still installed (incorrect)
osgi:list
[ 277] [Installed ] [ ] [ ] [ 60] Policy2
[ 278] [Installed ] [ ] [ ] [ 60] Policy3
[ 280] [Installed ] [ ] [ ] [ 60] Enabler1
[ 281] [Installed ] [ ] [ ] [ 60] Enabler2
features:list
[uninstalled] [1.0 ] PolicyUtil repo-0
[uninstalled] [1.0 ] Policy1 repo-0
[uninstalled] [1.0 ] Policy2 repo-0
[uninstalled] [1.0 ] Policy3 repo-0
[uninstalled] [1.0 ] Enabler1 repo-0
[uninstalled] [1.0 ] Enabler2 repo-0