View previous topic :: View next topic |
Author |
Message |
nagmat84 Apprentice
Joined: 27 Mar 2007 Posts: 218
|
Posted: Sun Apr 07, 2024 8:33 am Post subject: [SOLVED] Complex boolean expression for USE flags in ebuild |
|
|
I want an ebuild to depend an a (somewhat) complex boolean expression over USE flags as in Code: | (geoclue || geolocation) && zeroconf | The condition shall be true if "geoclue" or "geolocation" is set and "zeroconf" is set. I need this in two places: a) in the the RDEPEND variable and b) in pkg_postinst for a conditional log message.
However, I cannot get the syntax right and it does not seem to be documented. I tried Code: | RDEPEND="((geoclue || geolocation) && zeroconf) ? ( sys-auth/nss-mdns )
| and Code: | pkg_postinst() {
use ( (geoclue || geolocation) && zeroconf ) && elog "Enable Avahi via 'systemctl enable avahi-daemon.service'."
} | I know, the syntax above is wrong, but I hope it conveys the idea of what I try to achieve.
https://devmanual.gentoo.org/quickstart/index.html and https://devmanual.gentoo.org/ebuild-writing/index.html only contain examples for conditions on a single USE flag.
How does the correct syntax look like?
Last edited by nagmat84 on Sun Apr 07, 2024 12:56 pm; edited 1 time in total |
|
Back to top |
|
|
logrusx Veteran
Joined: 22 Feb 2018 Posts: 1584
|
Posted: Sun Apr 07, 2024 9:01 am Post subject: |
|
|
Keep brackets separated by a space by everything else, including themselves. In fact keep everything separated by at least a space in this type of expressions.
Best Regards,
Georgi |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9538 Location: beyond the rim
|
Posted: Sun Apr 07, 2024 12:37 pm Post subject: |
|
|
For dependency just convert it into two separate conditions:
Code: | RDEPEND="zeroconf? (
geoclue? ( sys-apps/nss-mdns )
geolocation? ( sys-apps/nss-mdns )
)" |
Similar in code:
Code: | if use zeroconf; then
if use geolocation || use geoclue; then
bla
fi
fi |
However in general this design looks wrong, why do you use two different flags to do the same thing? It is a recipe for maintenance issues later on. |
|
Back to top |
|
|
nagmat84 Apprentice
Joined: 27 Mar 2007 Posts: 218
|
Posted: Sun Apr 07, 2024 1:04 pm Post subject: |
|
|
Thanks that solved my problem. Quote: | However in general this design looks wrong, why do you use two different flags to do the same thing? It is a recipe for maintenance issues later on. | I know, it is unfortunate, but I haven't come up with those two different use flags for the same thing. I am just creating a meta ebuild which pulls in some packages as runtime dependencies which should actually have been pulled in by the package app-misc/geoclue itself in the first place. I try to get rid of some annoying warnings/errors in my system log, because app-misc/geoclue is installed but complains about sys-apps/nss-mdns not being installed. The package dev-qt/qtpositioning pulls in app-misc/geoclue, if geoclue is set, the package sys-apps/xdg-desktop-portal pulls in app-misc/geoclue, if geolocation is set. See here Code: | $ equery d app-misc/geoclue
* These packages depend on app-misc/geoclue:
dev-qt/qtpositioning-5.15.13 (geoclue ? app-misc/geoclue:2.0)
sys-apps/xdg-desktop-portal-1.18.2 (geolocation ? >=app-misc/geoclue-2.5.3:2.0) |
|
|
Back to top |
|
|
|