2.6. Définition de la variable $LFS

Throughout this book, the environment variable LFS will be used several times. You should ensure that this variable is always defined throughout the LFS build process. It should be set to the name of the directory where you will be building your LFS system - we will use /mnt/lfs as an example, but you may choose any directory name you want. If you are building LFS on a separate partition, this directory will be the mount point for the partition. Choose a directory location and set the variable with the following command:

export LFS=/mnt/lfs

Having this variable set is beneficial in that commands such as mkdir -v $LFS/tools can be typed literally. The shell will automatically replace « $LFS » with « /mnt/lfs » (or whatever value the variable was set to) when it processes the command line.

[Attention]

Attention

N'oubliez pas de vérifier que la variable LFS est définie à chaque fois que vous quittez et revenez dans l'environnement de travail (lorsque vous exécutez, par exemple, su en root ou un autre utilisateur). Vérifiez que la variable LFS est définie correctement avec la commande suivante :

echo $LFS

Assurez-vous que la sortie affiche le chemin du répertoire dans lequel vous construisez votre système LFS, qui est /mnt/lfs si vous avez suivi l'exemple fourni. Si la sortie indique le mauvais répertoire, utilisez la commande précédemment indiquée dans cette page pour associer la variable $LFS au bon répertoire.

[Note]

Note

One way to ensure that the LFS variable is always set is to edit the .bash_profile file in both your personal home directory and in /root/.bash_profile and enter the export command above. In addition, the shell specified in the /etc/passwd file for all users that need the LFS variable must be bash to ensure that the /root/.bash_profile file is incorporated as a part of the login process.

Another consideration is the method that is used to log into the host system. If logging in through a graphical display manager, the user's .bash_profile is not normally used when a virtual terminal is started. In this case, add the export command to the .bashrc file for the user and root. In addition, some distributions use an "if" test, and do not run the remaining .bashrc instructions for a non-interactive bash invocation. Be sure to place the export command ahead of the test for non-interactive use.