Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

how to install chroot with debootstrap with a certain locale

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

how to install chroot with debootstrap with a certain locale

#1 Post by MagicPoulp »

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

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

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

#2 Post by Head_on_a_Stick »

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
deadbang

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

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

#3 Post by MagicPoulp »

Fantastic!

edited:

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

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

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

#4 Post by Head_on_a_Stick »

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?
deadbang

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

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

#5 Post by MagicPoulp »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

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

#6 Post by Head_on_a_Stick »

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.
deadbang

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

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

#7 Post by MagicPoulp »

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: 431
Joined: 2018-11-05 21:30

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

#8 Post by MagicPoulp »

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"

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 133 times

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

#9 Post by Head_on_a_Stick »

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.
deadbang

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

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

#10 Post by MagicPoulp »

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

pcalvert
Posts: 1939
Joined: 2006-04-21 11:19
Location: Sol Sector
Has thanked: 1 time
Been thanked: 2 times

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

#11 Post by pcalvert »

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
Freespoke is a new search engine that respects user privacy and does not engage in censorship.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

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

#12 Post by stevepusser »

If you just want to use the chroots for building stuff, why not pbuilder or sbuild?
MX Linux packager and developer

MagicPoulp
Posts: 431
Joined: 2018-11-05 21:30

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

#13 Post by MagicPoulp »

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>"

Post Reply