how to install chroot with debootstrap with a certain locale

If none of the more specific forums is the right place to ask

how to install chroot with debootstrap with a certain locale

Postby MagicPoulp » 2020-06-16 09:21

sudo debootstrap stable /stable-chroot http://deb.debian.org/debian/

Every time I create a chroot, I need to manually set the locale or it says my locale is unknown.
Is there a way to do that without having a to search in the long list of locales when running dpkg-reconfigure locales?
Or is there a way to do it when creating the chroot?

export LANG="en_US.UTF-8"
apt-get install locales
dpkg-reconfigure locales
MagicPoulp
 
Posts: 383
Joined: 2018-11-05 21:30

Re: how to install chroot with debootstrap with a certain lo

Postby Head_on_a_Stick » 2020-06-16 09:40

To set en_GB.UTF-8:
Code: Select all
chroot /stable-chroot /usr/bin/apt install locales
sed -i '/en_GB.UTF-8/s/^# //;/en_US.UTF-8/s/^# //' /stable-chroot/etc/locale.gen
chroot /stable-chroot /usr/sbin/locale-gen
echo -e 'LANG=en_GB.UTF-8\nLANGUAGE=en_GB.UTF-8' > /stable-chroot/etc/default/locale
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12612
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: how to install chroot with debootstrap with a certain lo

Postby MagicPoulp » 2020-06-16 09:44

Fantastic!

edited:

it does not work.
Even after rebooting, the environment is wrong:
printenv | grep LANG
MagicPoulp
 
Posts: 383
Joined: 2018-11-05 21:30

Re: how to install chroot with debootstrap with a certain lo

Postby Head_on_a_Stick » 2020-06-16 13:45

MagicPoulp wrote:it does not work.
Even after rebooting, the environment is wrong:
printenv | grep LANG

From which environment are you running that command? The locale is set by the login so unless you log in to the chroot it won't be set.

Try this:
Code: Select all
# chroot /stable-chroot /usr/bin/passwd root # set root password
# rm /stable-chroot/etc/securetty{,.bak} # allow root login
# apt install systemd-machined
# systemd-nspawn -bD /stable-chroot

Then log in as root and check the locale.

And to go back to your OP:
MagicPoulp wrote:it says my locale is unknown

*What* says your locale is unknown? What was the exact error message and which command(s) did you run to receive that output?

To repeat my request from your other thread: please explain exactly what it is you are trying to do here. What is your overall aim and why do you think that setting the locale in a chroot system will solve that?
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12612
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: how to install chroot with debootstrap with a certain lo

Postby MagicPoulp » 2020-06-16 14:41

what I want to do is to get rid of the errors messages , just after creating the chroot, and adding the default locale, every apt command would start by saying the locale is unknown (I do not have easy access to the error now but my LANG is still not set properly). WHich makes sense since there is locale isnalled for the exported LANG=sv_SE.UTF-8. But I never wanted my chroot to have sv_SE.UTF-8.


printenv | grep LANG
is run from the chroot started with
sudo chroot /stable-chroot/ /bin/bash
and LANG is not set properly to my defualt locale.
MagicPoulp
 
Posts: 383
Joined: 2018-11-05 21:30

Re: how to install chroot with debootstrap with a certain lo

Postby Head_on_a_Stick » 2020-06-16 14:48

MagicPoulp wrote:printenv | grep LANG
is run from the chroot started with
sudo chroot /stable-chroot/ /bin/bash
and LANG is not set properly to my defualt locale.

Try
Code: Select all
LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8 sudo chroot /stable-chroot/ /bin/bash

But I think you'll find that APT now has the correct locale even without the variables being explicitly set before the chroot command.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12612
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: how to install chroot with debootstrap with a certain lo

Postby MagicPoulp » 2020-06-17 04:29

even without the variables being explicitly set ...


I tried and I can certify that the variables are required. How can I configure the shell so that variables are not required?

Code: Select all
LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8 sudo chroot /stable-chroot/ /bin/bash
[sudo] password for thierry:
root@debian-thierry:/# cd downloads/repo/
root@debian-thierry:/downloads/repo# cd openjdk8/
root@debian-thierry:/downloads/repo/openjdk8# bzr status
modified:
  debian/control
root@debian-thierry:/downloads/repo/openjdk8# exit
thierry@debian-thierry:~$  sudo chroot /stable-chroot/ /bin/bash
root@debian-thierry:/# cd downloads/repo/openjdk8
root@debian-thierry:/downloads/repo/openjdk8# bzr status
bzr: warning: unsupported locale setting
  bzr could not set the application locale.
  Although this should be no problem for bzr itself, it might
  cause problems with some plugins. To investigate the issue,
  look at the output of the locale(1p) tool.
modified:
  debian/control
Last edited by MagicPoulp on 2020-06-17 06:06, edited 1 time in total.
MagicPoulp
 
Posts: 383
Joined: 2018-11-05 21:30

Re: how to install chroot with debootstrap with a certain lo

Postby MagicPoulp » 2020-06-17 04:33

and apt still returns this without the extra variables for the chroot command:

Code: Select all
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
   LANGUAGE = (unset),
   LC_ALL = (unset),
   LANG = "sv_SE.UTF-8"
MagicPoulp
 
Posts: 383
Joined: 2018-11-05 21:30

Re: how to install chroot with debootstrap with a certain lo

Postby Head_on_a_Stick » 2020-06-17 08:09

MagicPoulp wrote:I can certify that the variables are required

Well you must have made a mistake when entering my suggested commands, did you see the locales being generated and does /etc/default/locale in the chroot contain the correct LANG & LANGUAGE variables?

I did test before posting, this is from my Alpine system (which doesn't use locales):
Code: Select all
$ echo $LANG
C.UTF-8
~$ echo $LANGUAGE

~$ doas chroot /mnt/stable-chroot /bin/bash
root@alpine:/# echo $LANG

root@alpine:/# apt update
Hit:1 https://deb.debian.org/debian stable InRelease
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
root@alpine:/#

MagicPoulp wrote:How can I configure the shell so that variables are not required?

Use an alias to launch the chroot with the variables set.
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12612
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: how to install chroot with debootstrap with a certain lo

Postby MagicPoulp » 2020-06-17 09:13

Here is the exact thing I did (exact copy paste from a file to the shell) and yet the local.gen has the content it should with en_US.


Code: Select all
sudo debootstrap stable /stable-chroot http://deb.debian.org/debian/

sudo chroot /stable-chroot /usr/bin/apt install locales
sudo sed -i '/en_US.UTF-8/s/^# //;/en_US.UTF-8/s/^# //' /stable-chroot/etc/locale.gen
sudo chroot /stable-chroot /usr/sbin/locale-gen
sudo bash -c "echo -e 'LANG=en_US.UTF-8\nLANGUAGE=en_US.UTF-8' > /stable-chroot/etc/default/locale"

cd /stable-chroot/
sudo mount -t proc proc proc/
sudo mount --rbind /sys sys/
sudo mount --rbind /dev dev/
sudo chroot /stable-chroot/ /bin/bash
LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 sudo chroot /stable-chroot/ /bin/bash



Edit:
My problem disappears with the following:

sudo bash -c "echo 'LANG=en_US.UTF-8' >> /stable-chroot/etc/profile"
sudo bash -c "echo 'LANGUAGE=en_US.UTF-8' >> /stable-chroot/etc/profile"
sudo bash -c "echo 'LC_ALL=en_US.UTF-8' >> /stable-chroot/etc/profile"
sudo chroot /stable-chroot/ /bin/bash --login
MagicPoulp
 
Posts: 383
Joined: 2018-11-05 21:30

Re: how to install chroot with debootstrap with a certain lo

Postby pcalvert » 2020-06-17 18:07

You may want to take a look at this:
https://grml.org/grml-debootstrap/

It's a wrapper around debootstrap that allows you do a lot of things more easily.

Phil
“Property is the fruit of labor; property is desirable; it is a positive good
in the world. That some should be rich shows that others may become
rich, and hence is just encouragement to industry and enterprise.”
— Abraham Lincoln
pcalvert
 
Posts: 1903
Joined: 2006-04-21 11:19
Location: Sol Sector

Re: how to install chroot with debootstrap with a certain lo

Postby stevepusser » 2020-06-18 03:56

If you just want to use the chroots for building stuff, why not pbuilder or sbuild?
MX Linux packager and developer
User avatar
stevepusser
 
Posts: 12061
Joined: 2009-10-06 05:53

Re: how to install chroot with debootstrap with a certain lo

Postby MagicPoulp » 2020-06-18 06:30

Because based on the docs around, it seems to require more knowledge and commands than a basic chroot.

See how long the page is:
https://wiki.debian.org/sbuild

or how long that command is:
BY the way the debuild options -us -uc -b seem to be hidden, etc

Code: Select all
sbuild  --arch=amd64 -d buster --debbuildopt=-J10 --force-orig-source -s -A \
--extra-repository="deb [trusted=yes] http://www.mirbsd.org/~tg/Debs/ buster wtf" \
--extra-repository="<some other repo you might want to tack onto Buster for the build>"
MagicPoulp
 
Posts: 383
Joined: 2018-11-05 21:30


Return to General Questions

Who is online

Users browsing this forum: No registered users and 19 guests

fashionable