Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How are kernel environment variables used?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20485

PostPosted: Sat Jun 22, 2024 5:39 am    Post subject: How are kernel environment variables used? Reply with quote

After setting them, I expected this to work:
Code:
$ make -C /usr/src/linux oldconfig
$ make -C /usr/src/linux modules_install
$ make -C /usr/src/linux install
Output and install locations are not under /usr/src/linux.
INSTALL_MOD_PATH, INSTALL_PATH and O are set in the environment and "printenv <varname>" shows the expected output.

Instead of my expected usage, I have to do this, which seems much less useful:
Code:
$ make -C /usr/src/linux O=$O oldconfig
$ INSTALL_MOD_PATH=$INSTALL_MOD_PATH make -C /usr/src/linux O=$O modules_install
$ INSTALL_PATH=$INSTALL_PATH make -C /usr/src/linux O=$O install
Also, INSTALLKERNEL doesn't seem to work at all as this seemed to have no affect:
Code:
$ INSTALLKERNEL=$INSTALLKERNEL INSTALL_PATH=$INSTALL_PATH make -C /usr/src/linux O=$O install
$HOME/bin/installkernel does work, but is less flexible and seemingly means the variable doesn't work at all.

The above not working and working behavior seems counter to the point of having an environment variable, so how are they intended to be used?

As an aside, both the Handbook and Kernel Configuration show using root, which may contribute to why so many use root.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2179

PostPosted: Sat Jun 22, 2024 10:14 am    Post subject: Reply with quote

I ended up writing a script to handle this, as documented in a wiki page, which might be helpful.
_________________
Greybeard
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22673

PostPosted: Sat Jun 22, 2024 2:49 pm    Post subject: Reply with quote

Setting INSTALL_PATH and INSTALL_MOD_PATH in the environment has always worked for me. I use KBUILD_OUTPUT, not O to influence the output directory though. As I read the Makefile, there is special logic to respect O only if it is assigned on the command line:
Makefile:
# Do we want to change the working directory?
ifeq ("$(origin O)", "command line")
  KBUILD_OUTPUT := $(O)
endif
I cannot say why that was done, because it dates to the beginning of the git history. If I were to guess, I would guess that O is such a simple name that someone was worried users would have an environment variable named O for some other purpose, and get bad results. The name KBUILD_OUTPUT is sufficiently distinctive that anyone who has that set almost certainly is doing it to influence the kernel build.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20485

PostPosted: Sat Jun 22, 2024 3:35 pm    Post subject: Reply with quote

@Goverp,

Thanks, I may eventually make a script too. I suspect that won't be a problem. For when a step fails though, it seems like having the manual method would be helpful.

@Hu,

Thanks, I'll try some more stuff. I originally used KBUILD_OUTPUT, but that didn't work so I switched to O (several years ago by now).

I don't recall if manually using export <varname> ever worked, but wanting to automate it, I switched to creating an environment variable script that sets the variables, then exports them. Both echo and printenv work with those variables, so that seems like it should work.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22673

PostPosted: Sat Jun 22, 2024 4:01 pm    Post subject: Reply with quote

I set all of $KBUILD_OUTPUT, $INSTALL_PATH, and $INSTALL_MOD_PATH via a helper script that then starts a subshell with those in its environment. This has worked reliably for me for a long time.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20485

PostPosted: Mon Jun 24, 2024 1:26 am    Post subject: Reply with quote

Well, using KBUILD_OUTPUT worked for 'menuconfig.' I was going to wait until the next stable version to update, but who knows when that will happen, so I'll probably try this week.

Interesting that O doesn't work (and seemingly INSTALLKERNEL).
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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