Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Boot time SMT related /etc/portage/env/MAKEOPTS [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3638

PostPosted: Wed Jan 01, 2020 8:42 pm    Post subject: Boot time SMT related /etc/portage/env/MAKEOPTS [Solved] Reply with quote

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
View user's profile Send private message
gentoo_ram
Guru
Guru


Joined: 25 Oct 2007
Posts: 475
Location: San Diego, California USA

PostPosted: Wed Jan 01, 2020 8:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2727

PostPosted: Wed Jan 01, 2020 9:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3638

PostPosted: Fri Jan 03, 2020 2:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
CaptainBlood
Advocate
Advocate


Joined: 24 Jan 2010
Posts: 3638

PostPosted: Fri Jan 03, 2020 4:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum