View previous topic :: View next topic |
Author |
Message |
CaptainBlood Advocate
Joined: 24 Jan 2010 Posts: 3638
|
Posted: Wed Jan 01, 2020 8:42 pm Post subject: Boot time SMT related /etc/portage/env/MAKEOPTS [Solved] |
|
|
I'd like to set only once a couple of variables, that would be visible to any user, early somewhere in the boot process but not through .bashrc.
export doesn't seem to work in /etc/local.d/*.start shell scripts.
It seems to be only dedicated to process execution. Maybe I'm missing something there...
Any idea?
Thks 4 ur attention.
Last edited by CaptainBlood on Fri Jan 03, 2020 8:14 pm; edited 4 times in total |
|
Back to top |
|
|
gentoo_ram Guru
Joined: 25 Oct 2007 Posts: 475 Location: San Diego, California USA
|
Posted: Wed Jan 01, 2020 8:51 pm Post subject: |
|
|
You're going to need to state your use case a little better. Environment variables are by definition per-process. There is no such thing as a variable visible "to any user". The closest equivalent would be to set variables in a system-wide rc file such as /etc/profile in the case of bash. The /etc/profile script on my machine executes scripts in /etc/profile.d/*.sh So you'd want to add a file in that directory to set the variable for any shell that logs in. |
|
Back to top |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2727
|
Posted: Wed Jan 01, 2020 9:00 pm Post subject: |
|
|
Wouldn't /etc/env.d/ work? I just have a 99local in there for this (syntax is just var=value, no need for export keyword, Edit: use env-update afterward to generate /etc/profile.env). |
|
Back to top |
|
|
CaptainBlood Advocate
Joined: 24 Jan 2010 Posts: 3638
|
Posted: Fri Jan 03, 2020 2:11 pm Post subject: |
|
|
gentoo_ram wrote: | You're going to need to state your use case a little better. |
Ok my use case is as follow:
I boot with optional SMT activation on a dual core CPU
As a result MAKEOPTS emerge option as static is very uncomfortable in some case.
On the oher side, MAKEOPTS can be set per package in /etc/portage/*env.
Having a couple of variables set only once, i.e. at boot time, which would be referred in etc/portage/env files, such as all_threads_but_one.conf which would refer to such a variable alternatively set to "-j2 -l2" when SMT is activated and "-j1 -l1" when it's not.
As far as I can see, there's not need to set such variables on the fly.
Please note that environment testing AND variable setting are both required in the process.
Thks 4 ur attention. |
|
Back to top |
|
|
CaptainBlood Advocate
Joined: 24 Jan 2010 Posts: 3638
|
Posted: Fri Jan 03, 2020 4:51 pm Post subject: |
|
|
Finally did it as: Code: | cat /etc/local.d/02-cpu-ht-cores.start
#!/bin/bash
myPath=/sys/devices/system/cpu/smt/active
if [[ -e $myPath ]] && [[ 1 -eq $(grep 1 $myPath) ]]; then
core_all=4
core_plus=5
core_but=3
core_half=2
else
core_all=2
core_plus=3
core_but=1
core_half=1
fi
myPath=/etc/portage/env
echo MAKEOPTS=\"-j$core_all -l$core_all\">$myPath/makeopts-all.conf
echo MAKEOPTS=\"-j$core_plus -l$core_plus\">$myPath/makeopts-plus.conf
echo MAKEOPTS=\"-j$core_but -l$core_but\">$myPath/makeopts-but.conf
echo MAKEOPTS=\"-j$core_half -l$core_half\">$myPath/makeopts-half.conf
| Ugly perhaps, but working good enough here.
Thks 4 ur attention |
|
Back to top |
|
|
|