artix-linux / artools

Development and build tools for Artix
12 stars 5 forks source link

Locale not being read inside chroot with buildpkg #24

Closed cromerc closed 7 years ago

cromerc commented 7 years ago

buildpkg is failing on the new version of udisks2 due to an incorrect locale setting.

I just chrooted into the copy chroot and root chroot and ran:

[artix /]# echo $LANG
C

It is showing C, however when I open /etc/locale.conf it has this: LANG=en_US.UTF-8

I was able to get udisks2 to compile by modifying the PKGBUILD and adding export LANG=en_US.UTF-8 https://github.com/artix-linux/world/commit/85a04322c18cf387f117097d449d8213d948803e

It also builds just fine with standard makepkg outside of the chroot since my LANG is set correctly.

This is the error:

Traceback (most recent call last):
  File "/usr/bin/gtkdoc-mkdb", line 61, in <module>
    mkdb.Run(options)
  File "/usr/share/gtk-doc/python/gtkdoc/mkdb.py", line 254, in Run
    doctype_header = GetDocbookHeader(main_sgml_file)
  File "/usr/share/gtk-doc/python/gtkdoc/mkdb.py", line 2383, in GetDocbookHeader
    for line in INPUT:
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]

And here is some information on the solution: https://stackoverflow.com/questions/10561923/unicodedecodeerror-ascii-codec-cant-decode-byte-0xef-in-position-1

By having LANG set with UTF8 it fixes these build errors.

udeved commented 7 years ago

I have done some tests.

In mkchrootpkg, /etc/profile is explicitly sourced in the script that gets written to the chroot copy before makepkg starts. https://github.com/artix-linux/artools/blob/master/bin/mkchrootpkg.in#L208

The chroots are sanely created with export LANG=C

When /etc/profile gets sourced, for whatever reason, the LANG environment variable is not set and defaults to 'C'. It definitely sources /etc/profile.d/*, printing locale after sourcing shows the other vars are set from /etc/profile.d/locale.sh.

Could there be systemd localectl be setting the LANG instead of explicitly exporting it in chrootbuild script that gets written in the chroot copy?

==> Making package: polkit 0.113+29+g3272a98-10 (Mon Aug 14 08:41:26 CEST 2017)
==> Retrieving sources...
  -> Updating polkit git repo...
Fetching origin
  -> Found 99-cromnix.rules
  -> Found polkit-0.114-elogind.patch
==> Validating source files with sha256sums...
    polkit ... Skipped
    99-cromnix.rules ... Passed
    polkit-0.114-elogind.patch ... Passed
LANG=C
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES=C
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

#!/bin/bash
_chrootbuild () 
{ 
    . /etc/profile;
    locale;
    sudo -iu builduser bash -c 'cd /startdir; makepkg "$@"' -bash "$@"
}
_chrootbuild "$@" || exit