Suggestions for change in setting up "lfs" user
Ag. D. Hatzimanikas
a.hatzim at gmail.com
Wed Jan 30 23:56:18 PST 2008
On Wed, Jan 30, at 04:35 armencho at gmail.com wrote:
> Chapter 4.3 - 4.4: Is there any particular crucial reason why the bash
> startup scripts for lfs user have to be created and subsequently sourced
> ("source ~/.bash_profile" instruction) by user after having logged in? It is
> not a big deal with the book, but is a problem if the host has persistent
> storage (hard disk) and/or the build is automated and allows interrupting,
> in which there can be cases where the startup scripts will be sourced twice.
> I am writing such an automation script for LFS and need to circumvent this
> problem. I have looked into 'jhalfs' project but it has come to a point
> where it is too complicated to really learn from what I need to know..
What we really care is a clean/safe environment, so that we can be independent
from the host system (using the new tools) as soon as possible.
What I do and if I remember Jhalfs is doing something similar, is to run
a command like:
su - $user -c "source ~/.bashrc&& cd $script_tools_dir && ./master"
where user=lfs and $script_tools_dir is the directory with the scripts.
As you can see, after sourcing the ~/.bashrc (where I setup the environment),
I then give control to a master script, which is then responsible to run the
rest of the build in the chapter05 (and exit in errors!).
You have to double check the environment with `env', so to be sure
that you have avoided any influence of the host system.
One such crucial variable is the $PATH, so pay attention what the book says about
the `set +h` option in ~/.bashrc.
And similarly when chroot'ing in chapter06,
chroot $LFS /tools/bin/env -i HOME=/root TERM="$TERM" \
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h \
-c 'source /tmp/envars &&cd $script_chroot_dir &&./master'
More information about the lfs-support