Merry Christmas everyone
I have an application that can either work with legacy iptables (`iptables-legacy` and `ebtables-legacy`) or `nftables`. So I'm trying to specify this as a dependency in a spec file. If a user has not installed any of it (or `iptables-nft`) then `nftables` should be preferred.
I thought this would be easy with a RPM boolean dependency [1]:
Requires: (ebtables-legacy if iptables-legacy else nftables)
When installing the RPM with this expression and no `iptables-legacy` nor `nftables` already installed then `dnf` will want to install `ebtables-legacy` and `iptables-legacy`.
Only when I include `nftables` in the `dnf install` command it will ignore the legacy package dependencies.
Is there a way to express that I want `nftables` by default except a user has already `iptables-legacy` installed?
Cheers, Reto
[1]: https://rpm-software-management.github.io/rpm/manual/boolean_dependencies.ht...
On 25-12-2023 17:52, Reto Gantenbein wrote:
Merry Christmas everyone
I have an application that can either work with legacy iptables (`iptables-legacy` and `ebtables-legacy`) or `nftables`. So I'm trying to specify this as a dependency in a spec file. If a user has not installed any of it (or `iptables-nft`) then `nftables` should be preferred.
I thought this would be easy with a RPM boolean dependency [1]:
Requires: (ebtables-legacy if iptables-legacy else nftables)
When installing the RPM with this expression and no `iptables-legacy` nor `nftables` already installed then `dnf` will want to install `ebtables-legacy` and `iptables-legacy`.
Only when I include `nftables` in the `dnf install` command it will ignore the legacy package dependencies.
Is there a way to express that I want `nftables` by default except a user has already `iptables-legacy` installed?
Have you considered making it sub packages (e.g. foo-iptables and foo-nftables)? That would make it more transparent to the user and allows you to stuff the dependencies in the sub package and create weak dependencies [1].
There's probably also a way of doing it in the spec with some expression[2]. Not my strong part, but maybe you need to declare it the other way around:
Requires: (nftables unless iptables-legacy) Requires: (ebtables-legacy if iptables-legacy)
[1] https://docs.fedoraproject.org/en-US/packaging-guidelines/WeakDependencies/ [2] https://rpm-software-management.github.io/rpm/manual/boolean_dependencies.ht...
-- Sandro
Hi Sandro
Thanks for your response. I don't really like to use sub packages for this especially not with weak dependencies as I'm normally the first to disable weak dependencies. And in my case `iptables-legacy` or `nftables` are by no means optional. One of them is required otherwise the application won't start.
In the meantime I found a solution:
Requires: iptables, ebtables Requires: (nftables if iptables-nft)
I didn't fully figure out why this works as I remember having tested `iptables` by itself and it would install `iptables-legacy`. But as `iptables-nft` provides both `iptables` and `ebtables` and this expression uses a comma instead of two separate 'Requires' expressions this might make a difference.
Like this I still end up with `iptables-nft` that I actually don't need but still better than installing `iptables-legacy`.
Happy New Year! Reto
V Mon, Dec 25, 2023 at 05:52:12PM +0100, Reto Gantenbein napsal(a):
Merry Christmas everyone
I have an application that can either work with legacy iptables (`iptables-legacy` and `ebtables-legacy`) or `nftables`. So I'm trying to specify this as a dependency in a spec file. If a user has not installed any of it (or `iptables-nft`) then `nftables` should be preferred.
I thought this would be easy with a RPM boolean dependency [1]:
Requires: (ebtables-legacy if iptables-legacy else nftables)
When installing the RPM with this expression and no `iptables-legacy` nor `nftables` already installed then `dnf` will want to install `ebtables-legacy` and `iptables-legacy`.
Only when I include `nftables` in the `dnf install` command it will ignore the legacy package dependencies.
Is there a way to express that I want `nftables` by default except a user has already `iptables-legacy` installed?
It is. Add:
Suggests: nftables
Suggests remains unaffected when weak dependencies are disabled with an install_weak_deps=false option.
DNF uses Suggests as a hint to prefer a solution with the suggested package among multiple possible solutions.
Don't ask me why DNF without the hint prefers (ebtables-legacy and iptables-legacy) if nftables is not installed. What heuristic DNF/libsolv uses is a mystery for me.
-- Petr
packaging@lists.fedoraproject.org