chroot-env: add locales, refactor environment

This commit is contained in:
Nikolay Amiantov
2015-03-09 17:29:43 +03:00
parent e3ab3df26e
commit 3e395b71da
3 changed files with 16 additions and 9 deletions
@@ -62,7 +62,7 @@ let
chosenGcc chosenGcc
bashInteractive coreutils less shadow su bashInteractive coreutils less shadow su
gawk diffutils findutils gnused gnugrep gawk diffutils findutils gnused gnugrep
gnutar gzip bzip2 xz gnutar gzip bzip2 xz glibcLocales
]; ];
# Compose a global profile for the chroot environment # Compose a global profile for the chroot environment
@@ -72,6 +72,9 @@ let
mkdir -p $out/etc mkdir -p $out/etc
cat >> $out/etc/profile << "EOF" cat >> $out/etc/profile << "EOF"
export PS1='${name}-chrootenv:\u@\h:\w\$ ' export PS1='${name}-chrootenv:\u@\h:\w\$ '
export LOCALE_ARCHIVE='/usr/lib${if is64Bit then "64" else ""}/locale/locale-archive'
export LD_LIBRARY_PATH=/run/opengl-driver/lib:/run/opengl-driver-32/lib:/lib:/lib32:/lib64
export PATH='/bin:/sbin'
${profile} ${profile}
EOF EOF
''; '';
@@ -3,4 +3,10 @@
chrootenvDest=/run/chrootenv/@name@ chrootenvDest=/run/chrootenv/@name@
# Enter the LFS chroot environment # Enter the LFS chroot environment
sudo chroot --userspec "$USER:${GROUPS[0]}" --groups "${GROUPS[0]}" $chrootenvDest /usr/bin/env -i PS1="$PS1" TERM="$TERM" DISPLAY="$DISPLAY" HOME="$HOME" PATH="/bin:/sbin" XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" /bin/bash --login sudo chroot --userspec "$USER:${GROUPS[0]}" --groups "${GROUPS[0]}" $chrootenvDest /usr/bin/env -i \
TERM="$TERM" \
DISPLAY="$DISPLAY" \
HOME="$HOME" \
XDG_RUNTIME_DIR="$XDG_RUNTIME_DIR" \
LANG="$LANG" \
/bin/bash --login
@@ -116,13 +116,11 @@ if $cpid == 0
link_swdir.call swdir, Pathname.new('') link_swdir.call swdir, Pathname.new('')
# New environment # New environment
oldenv = ENV.to_h ENV.replace({ 'TERM' => ENV['TERM'],
ENV.replace({ 'PS1' => oldenv['PS1'], 'DISPLAY' => ENV['DISPLAY'],
'TERM' => oldenv['TERM'], 'HOME' => ENV['HOME'],
'DISPLAY' => oldenv['DISPLAY'], 'XDG_RUNTIME_DIR' => ENV['XDG_RUNTIME_DIR'],
'HOME' => oldenv['HOME'], 'LANG' => ENV['LANG'],
'PATH' => '/bin:/sbin',
'XDG_RUNTIME_DIR' => oldenv['XDG_RUNTIME_DIR'],
}) })
# Finally, exec! # Finally, exec!