Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
arch-chroot and source /etc/profile
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
st834
n00b
n00b


Joined: 23 Jun 2022
Posts: 74

PostPosted: Sun May 12, 2024 9:04 am    Post subject: arch-chroot and source /etc/profile Reply with quote

I found in the documentation https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Base , that commands
Code:
root #mount --types proc /proc /mnt/gentoo/proc
root #mount --rbind /sys /mnt/gentoo/sys
root #mount --make-rslave /mnt/gentoo/sys
root #mount --rbind /dev /mnt/gentoo/dev
root #mount --make-rslave /mnt/gentoo/dev
root #mount --bind /run /mnt/gentoo/run
root #mount --make-slave /mnt/gentoo/run

can be replaced by calling
Code:
arch-chroot /mnt/gentoo
.

Quote:
Tip
If using Gentoo's install media, this step can be replaced with simply: arch-chroot /mnt/gentoo.
.

After call arch-chroot the system enters a new environment, i.e. an additional command

Code:
chroot /mnt/gento /bin/bash
is called.

Question: Does it (arch-chroot) also call source /etc/profile? Unfortunately I could not find any information about this (only short description on https://packages.gentoo.org/packages/sys-apps/arch-chroot : "Wraps the chroot command while ensuring that important filesystems are mounted").

Thanks a lot
Back to top
View user's profile Send private message
Leonardo.b
Guru
Guru


Joined: 10 Oct 2020
Posts: 302

PostPosted: Sun May 12, 2024 10:50 am    Post subject: Reply with quote

Hello st834.

Code:
source file

... this is the same thing as ".", but using bash notation.

If you run:
Code:
. file

the commands in specified file are read and executed by the current shell.
For example:
Code:
$ VAR=0
$ cat file
VAR=1
$ . file
$ echo $VAR
1


It is very useful to write down defaults enviroment variables (like EDITOR), and aliases (like colorful ls in place of ls) in a file, and source it every time.
This is what /etc/profile does.

When you invoke the shell like:
Code:
bash -l

profile files are automatically sourced.
Otherwise you must manually source them.

I didn't read the arch-chroot script, but you can source /etc/profile file again, it shouldn't matter if you do it several times.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21789

PostPosted: Sun May 12, 2024 3:00 pm    Post subject: Reply with quote

As I read the script, it starts a shell for you, and does not execute any commands in that shell on your behalf. Therefore, the answer appears to be that it does not source /etc/profile for you. However, it is possible that the dotfiles present in the chroot might cause the shell to do that on its own. As mentioned above, rerunning it is harmless, so if in doubt, source it.
Back to top
View user's profile Send private message
st834
n00b
n00b


Joined: 23 Jun 2022
Posts: 74

PostPosted: Sun May 12, 2024 7:45 pm    Post subject: Reply with quote

thank you so much for your replies and for your attention to this post. I understand and will upload the profiles manually again. One last question: is there a command to see if a profile is loaded or not?

Thanks
Back to top
View user's profile Send private message
Leonardo.b
Guru
Guru


Joined: 10 Oct 2020
Posts: 302

PostPosted: Tue May 14, 2024 5:59 pm    Post subject: Reply with quote

No, there isn't. There is nothing special in profile file, shell doesn't keep track of them.

You may guess if it's loaded or not from the environment, though.
Code:
env
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing 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