devsk wrote:So, the best is:
Code: Select all
grep ">>> emerge" /var/log/emerge.log | awk 'END{print $1$7}'
it executes in 6ms on my system, compared to 14ms for your one-liner and 25ms for awk-only one liner. These will be much slower on bigger emerge.log files and slower systems than mine. Remember, emerge.log only grows, so optimize as much as you can...

Thanks a lot for your help on this, excellent!
PPS: How do you account for people who have /var/log/portage disabled i.e. logging disabled because /etc/make.conf doesn't have /var/log/portage or directory /var/log/portage is not even present, in your original code (I mean in the current code before you move to one of these emerge.log thingies)?
The script checks if PORT_LOGDIR is set in /etc/make.conf
If it isn't set the script prints some text recommending the user to:
A. enable the PORTLOG variable in /etc/make.conf
or
B. use the bash_helper or php_helper scripts submitted by other users to avoid unnecessary indexing.
I have just removed this check from the new version as it becomes obsolete when we use /var/log/emerge.log to determine if indexing is needed
Hey, you seem pretty creative with your solutions, maybe you (or someone else) can point me in the right direction with two other issues that still bug me:
1. cfg-update checks if a GUI is available before it spawns the GUI tool:
Currently the script checks if the DISPLAY variable is set, by calling "echo $DISPLAY"
If it is not empty, it will assume that X is running and it's possible to spawn a GUI tool like xxdiff.
I figured that X can be running without having a local display, so it's not good enough to simply
check if there's a process running with X as it's name... that's why I check the DISPLAY variable.
Maybe there's a better method?
2. cfg-update creates an alias for the emerge command in /root/.bashrc which calls a wrapperscript
that first runs "cfg-update --index" and then continues with the actual emerge command.
This isn't a nice way to ensure that the index stays up to date...
I have considered cronjobs, looked for a "pre-emerge hook" in portage but have not found
a good alternative for running "cfg-update --index" right before an emerge command.
Maybe you have some ideas?