Some software has dependencies that are not strictly required for core operation, but add functionality. It would be helpful if there was a way to represent this in APKs, notify the user of these during installation, and allow the user to install them as well when the -i flag is provided.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
this is a can of worms. Should the optional dependencies be added to /etc/apk/world, or should there be a flag for each package that optional deps were enabled?
If an optional dependency also has optional dependencies, should those also be installed when you say "yes, i want optional dependencies"?
If an update of a package removes an optional dependency, should apk keep or remove the installed optional dependency which no longer is an optional dep?
I think "I want them all" or "No optionals please" is doable. But allowing them per-package is tricky as observed.
Similar feature was suggested in MR !7 and there was also some discussion on this. We are currently doing major rewrite of apk and this would need to wait at least until it's done.
What I would personally expect for optional dependencies:
optional dependencies aren't added to world, but treated as normal dependencies once they are installed. So if the package that caused them to be installed gets removed or stops listing it in their optional dependencies, it would get uninstalled
in the same way it would also install new optional dependencies if the package with those dependencies lists new ones. Thus, a package should probably have a flag indicating if for that specific package optional dependencies are enabled
optional dependencies can be uninstalled at any point, without touching the package that caused it to be installed. Since it's optional, it should be safe to uninstall without making the program that caused it to be installed unusable, it would just lack that specific functionality
optional dependencies can specify optional dependencies themselves, and with -i would ask the user for every package if they want the optional dependencies installed as well. Without -i it's either "I want them all" or "No optionals please"
Currently in postmarketOS we have a _pmb_recommends variable we can specify in packages, which causes our external pmbootstrap tool to add those packages to world, but otherwise not modify any package to depend on them. This is useful to e.g. set default installed applications, but still have the user be able to uninstall them if they want too.
However, this means that when the package that had the variable set e.g. removes one of those packages from that variable or adds new ones, this change won't be reflected on the system of the user. For us having proper "optional dependencies" in apk-tools itself would thus be really useful.