microsoft / azurelinux

Linux OS for Azure 1P services and edge appliances
MIT License
4.28k stars 535 forks source link

toolkit does not correctly handle logical BuildRequires: #7570

Open ddstreetmicrosoft opened 8 months ago

ddstreetmicrosoft commented 8 months ago

Describe the bug A clear and concise description of what the bug is.

While rpm supports robust logical statements in dependency entries, our toolkit does not correctly support any logic statements except and. As explained in the docs: https://github.com/microsoft/CBL-Mariner/blob/3.0-dev/toolkit/docs/how_it_works/3_package_building.md#rich-dependencies

Spec files can have (a b) style requirements. Depending on the condition the following will happen:

and, or, with: the build system will record both options into the graph so that all possible requirements will be made available to pick from during package install allowing for maximum flexibility. This means that the build system requires all optional RPMs to be available to build/download even if they will not be used for a specific configuration. if: the build will record the requirement on the left side of the clause as a dependency. That means that the build system will require the package to be available to build/download even if it will not be used for a specific configuration. else, unless, without, or multiple clauses of any kind: unsupported, the build will fail with an error.

While this documentation states that or, with, and if are supported, they are not actually supported correctly, as the handling of or and if does not actually match their documented operation; instead both or and if are treated by the toolkit as being and. Additionally, the handling of if is also incorrect as it simply ignores the if condition check.   Logical dependency operators are increasingly important to rpms and the toolkit needs to correctly support them; not doing so creates significant burden to ongoing development.

ddstreetmicrosoft commented 8 months ago

FYI @christopherco @Britel @jslobodzian @reubeno @dmcilvaney @hbeberman @PawelWMS @anphel31 @nicogbg