Closed pchome closed 7 years ago
Adding even more functions is probably not sane. You can use arbitrary bash code anyway. Although it is not documented, you can just call the internal implementation of *FLAGS+= as long you do not use wildcards:
"use perl && FlagAddAllFlags -ffat-lto-objects"
Thanks, it seems .net-misc/dhcp *FLAGS-="$(use server && echo -n '-flto*')"
works fine
edit: No it's don't work :)
Quoting must be done rather tricky. There are two eval's executed: One for the whole line, and one for the part after FLAGS-=
The following should work:
```net-misc/dhcp 'FLAGS-="$(use server && echo "-flto")"' Since eix -vle dhcp shows that all dhcp ebuilds are at least EAPI 5 you should also be able to use
net-misc/dhcp 'FLAGS-="$(usex server "-flto*")"'```
The following should work
Yes, but
use server
dies if package have no server
use flag (accidentally detected while all commands w/ different flags started executing during emerge process :) )So final try for now is net-misc/dhcp "has server ${IUSE//+} && use server && FlagSubAllFlags -flto*"
.
noticed all $(...) executed at once
This happened in your example because of the missing outer quote: The outer eval (for the whole line) is executed unconditionally for every line, because it is used for splitting the line. The inner eval, however, applies only if the package matches.
use server
dies if package have noserver
use flag
Of course; so does usex. But if you quote as in my example, the "use" or "usex" will be executed only for the corresponding package.
Note: When writing this reply, I realize that it might be more efficient if the outer eval is not executed unconditionally. Maybe in a future release I will change this behavior. No matter whether I will make this change or not: Quoting twice is necessary, because in the "matching" case there are 2 eval's.
The change announced in the previous note is now in the new release. This could make your previous code work by accident. However, I would strongly recommend to use the correct (two-level) quoting.
Tanks, noted.
But to prevent breakage in case use flag removed for package (this happens sometimes) I still need to check IUSE.
So between this two variants:
net-misc/dhcp '*FLAGS-="$(has server ${IUSE//+} && use server && echo "-flto*")"'
and
net-misc/dhcp "has server ${IUSE//+} && use server && FlagSubAllFlags -flto*"
I prefer last one.
The last one only works, because the curent implementation makes "set -f" active during the eval: Otherwise, -flto* might be extended if it matches a file in the current directory. If some of "has" or "use" should mess with the -f flag, it will break.
IIRC, checking IUSE is against pms: It was intentionally removed from pms to avoid that global functions like eclasses (or /etc/portage/bashrc) do tests like this. Some pms fanatics might suggest a patch to portage which will unset IUSE (I am surprised that it still works...).
Edit: In EAPI 6 in_iuse was provided as a substitute which, however, can be used only in certain phases. So, you can probably do (untested!):
>=net-misc/dhcp-4.3.6 'in_iuse server && use server && FlagSubAllFlags "-flto*"'
untested
Tested while playing with first variant a while ago ;) along with use_if_iuse (or so) and they not initialized/available.
not initialized/available
They are available only since EAPI=6. That's why i have put the minimum version requirement on dhcp.
This should be useful for
lto-overlay
users when LTO disabled for whole package but problem caused by USE-flag. Example (https://github.com/InBetweenNames/gentooLTO/blob/ce11e856b832274930d7fca10895f0533a14e891/sys-config/ltoize/files/package.cflags/ltoworkarounds.conf):Maybe something like
app-editors/vim[perl] *FLAGS+=-ffat-lto-objects
orapp-editors/vim FOR_USE=perl *FLAGS+=-ffat-lto-objects
?