All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Seiderer <ps.report@gmx.net>
To: Adam Duskett <adam.duskett@amarulasolutions.com>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v2 1/2] package/postgresql/postgresql.service: set locale for initdb to C
Date: Sun, 5 Nov 2023 11:07:11 +0100	[thread overview]
Message-ID: <20231105110711.310c9104@gmx.net> (raw)
In-Reply-To: <20231102184154.46185-1-adam.duskett@amarulasolutions.com>

Hello *,

On Thu,  2 Nov 2023 12:41:53 -0600, Adam Duskett <adam.duskett@amarulasolutions.com> wrote:

> From: Peter Seiderer <ps.report@gmx.net>
>
> Systemd creates a /etc/locale.conf file with LANG="C.UTF-8". On boot, systemd
> reads /etc/locale.conf and sets the LANG environment variable,
> (see the locale_context_load_conf method in local-setup.c.)
>
> When initdb.c is called, a check for the LANG environment variable is called,
> and if it is set to something other than "C" initdb attempts to load the
> corresponding LC_CTYPE file in /usr/lib/locale/. IE: If LANG is set to C.UTF-8,
> then initdb.c attempts to load /usr/lib/locale/C.UTF-8/LC_CTYPE. However, these
> files do not exist on a Buildroot system, and as such, initdb throws the
> following error on startup:
>
> ```
> initdb: error: invalid locale settings; check LANG and LC_* environment variables
> pg_ctl: database system initialization failed
> ```
>
> To fix this issue, add "Environment=LANG=C" to the package provided
> postgresql.service file to force Postgresql to use the C locale.
>
> Tested-by: Adam Duskett <adam.duskett@amarulasolutions.com>
> Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
> ---
> v1 -> v2:
>   - Get to the root cause of the problem and provide a better explination of
>     what is happening.
>
>   - Use Environment=LANG=C isntead of -o --locale=C
>
>  package/postgresql/postgresql.service | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/package/postgresql/postgresql.service b/package/postgresql/postgresql.service
> index 539eea8964..c470c7181e 100644
> --- a/package/postgresql/postgresql.service
> +++ b/package/postgresql/postgresql.service
> @@ -16,6 +16,10 @@ StandardOutput=syslog
>  StandardError=syslog
>  SyslogIdentifier=postgres
>
> +# Overwrite the LANG variable to prevent systemd from passing the LANG
> +# environment variable set in /etc/locale.conf.
> +Environment=LANG=C
> +
>  ExecStartPre=/bin/sh -c "if [ ! -f /var/lib/pgsql/PG_VERSION ]; then /usr/bin/pg_ctl initdb -D /var/lib/pgsql; fi"
>  ExecStart=/usr/bin/postgres -D /var/lib/pgsql
>  ExecReload=/usr/bin/kill -HUP $MAINPID

And for the record the links to the original patch series/review comments:

	https://patchwork.ozlabs.org/project/buildroot/patch/20200920150659.7562-1-ps.report@gmx.net/
	https://patchwork.ozlabs.org/project/buildroot/patch/20200920150659.7562-2-ps.report@gmx.net/
	https://patchwork.ozlabs.org/project/buildroot/patch/20200920150659.7562-3-ps.report@gmx.net/

Regards,
Peter

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2023-11-05 10:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 18:41 [Buildroot] [PATCH v2 1/2] package/postgresql/postgresql.service: set locale for initdb to C Adam Duskett
2023-11-02 18:41 ` [Buildroot] [PATCH v2 2/2] support/testing/tests/package/test_postgresql.py: new test Adam Duskett
2023-12-18 17:31   ` Yann E. MORIN
2023-12-18 17:41     ` Adam Duskett
2023-12-18 18:10       ` Adam Duskett
2023-12-18 20:44       ` Yann E. MORIN
2023-12-18 21:40         ` Adam Duskett
2023-11-05 10:07 ` Peter Seiderer [this message]
2023-12-18 17:22 ` [Buildroot] [PATCH v2 1/2] package/postgresql/postgresql.service: set locale for initdb to C Yann E. MORIN
2023-12-18 17:28   ` Adam Duskett
2023-12-18 17:39     ` Yann E. MORIN
2023-12-18 17:44       ` Adam Duskett
2023-12-18 22:09         ` Adam Duskett
2023-12-24 22:10           ` Adam Duskett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231105110711.310c9104@gmx.net \
    --to=ps.report@gmx.net \
    --cc=adam.duskett@amarulasolutions.com \
    --cc=buildroot@buildroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.