diff mbox series

[v2,1/2] package/postgresql/postgresql.service: set locale for initdb to C

Message ID 20231102184154.46185-1-adam.duskett@amarulasolutions.com
State Rejected, archived
Headers show
Series [v2,1/2] package/postgresql/postgresql.service: set locale for initdb to C | expand

Commit Message

Adam Duskett Nov. 2, 2023, 6:41 p.m. UTC
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(+)

Comments

Peter Seiderer Nov. 5, 2023, 10:07 a.m. UTC | #1
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
Yann E. MORIN Dec. 18, 2023, 5:22 p.m. UTC | #2
Adam, Peter, All,

On 2023-11-02 12:41 -0600, Adam Duskett spake thusly:
> From: Peter Seiderer <ps.report@gmx.net>

So, this patch is "From Peter", but...

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

... the first SoB is by Adam, and there is no SoB be Peter.

In this case, I think I understand that Adam took Peter's patch, and
totally rewrote it with an alternate solution. In such a case, the
customs is to change the authorship to the new author, and keep a
Co-developed-by tag to keep credits to the first author.

So, if you can just reply to this mail stating I got things right, I can
fix authorship and tags when applying. If I got things wrong, then
please resubmit with proper tags and/or authorship.

Also, it does not make much sense that the submitter of a patch adds
their own Tested-By tag, as it is actually expected that the submitter
did test what they sent...

Thanks! :-)

Regards,
Yann E. MORIN.

> ---
> 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
> -- 
> 2.41.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Adam Duskett Dec. 18, 2023, 5:28 p.m. UTC | #3
Yann;

I didn't add Peter as the patch is completely different than what he sent
along with a more
comprehensive explanation as to what is happening. If you want to add Peter
as a
co-author that is more than fine by me.

Adam Duskett

Senior Embedded Systems Developer

M. +1208-515-8102

adam.duskett@amarulasolutions.com
Yann E. MORIN Dec. 18, 2023, 5:39 p.m. UTC | #4
Adam, All,

[Please, do not top-post]

On 2023-12-18 10:28 -0700, Adam Duskett spake thusly:
> I didn't add Peter as the patch is completely different than what he sent
> along with a more
> comprehensive explanation as to what is happening.

Then you should also have dropped him as the author; note how the first
line of the patch was still:

    From: Peter Seiderer <ps.report@gmx.net>

... which git uses as the author of the patch.

> If you want to add Peter
> as a
> co-author that is more than fine by me.

It is not about what I want, it is about keeping auhtorship and SoB in
sync and coherent with who actually did what.

So if I understand correctly: you are the author, so you have your SoB,
and Peter is a co-dev for credits, right: Yes/No ? ;-)

If yes, then can I fix the authorship and add the Co-developed-by tag
for Peter: Yes/No?

If no to either, can you respin a fixed-up patch, please?

Regards,
Yann E. MORIN.

> Adam Duskett
> 
> Senior Embedded Systems Developer
> 
> M. +1208-515-8102
> 
> adam.duskett@amarulasolutions.com
> 
> __________________________________
> 
> 
> Amarula Solutions BV
> 
> Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
> 
> T. +31 (0)85 111 9170
> info@amarulasolutions.com
> 
> www.amarulasolutions.com
> 
> 
> 
> On Mon, Dec 18, 2023 at 10:22 AM Yann E. MORIN <yann.morin.1998@free.fr>
> wrote:
> 
> > Adam, Peter, All,
> >
> > On 2023-11-02 12:41 -0600, Adam Duskett spake thusly:
> > > From: Peter Seiderer <ps.report@gmx.net>
> >
> > So, this patch is "From Peter", but...
> >
> > > 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>
> >
> > ... the first SoB is by Adam, and there is no SoB be Peter.
> >
> > In this case, I think I understand that Adam took Peter's patch, and
> > totally rewrote it with an alternate solution. In such a case, the
> > customs is to change the authorship to the new author, and keep a
> > Co-developed-by tag to keep credits to the first author.
> >
> > So, if you can just reply to this mail stating I got things right, I can
> > fix authorship and tags when applying. If I got things wrong, then
> > please resubmit with proper tags and/or authorship.
> >
> > Also, it does not make much sense that the submitter of a patch adds
> > their own Tested-By tag, as it is actually expected that the submitter
> > did test what they sent...
> >
> > Thanks! :-)
> >
> > Regards,
> > Yann E. MORIN.
> >
> > > ---
> > > 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
> > > --
> > > 2.41.0
> > >
> > > _______________________________________________
> > > buildroot mailing list
> > > buildroot@buildroot.org
> > > https://lists.buildroot.org/mailman/listinfo/buildroot
> >
> > --
> >
> > .-----------------.--------------------.------------------.--------------------.
> > |  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
> > conspiracy: |
> > | +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
> >      |
> > | +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is
> > no  |
> > | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
> >  conspiracy.  |
> >
> > '------------------------------^-------^------------------^--------------------'
> >

> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Adam Duskett Dec. 18, 2023, 5:44 p.m. UTC | #5
Adam Duskett

Senior Embedded Systems Developer

M. +1208-515-8102

adam.duskett@amarulasolutions.com
Adam Duskett Dec. 18, 2023, 10:09 p.m. UTC | #6
Sorry, Gmail defaulted to HTML.

> On Mon, Dec 18, 2023 at 10:39 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> >
> > Adam, All,
> >
> > [Please, do not top-post]
> >
OK
> > On 2023-12-18 10:28 -0700, Adam Duskett spake thusly:
> > > I didn't add Peter as the patch is completely different than what he sent
> > > along with a more
> > > comprehensive explanation as to what is happening.
> >
> > Then you should also have dropped him as the author; note how the first
> > line of the patch was still:
> >
> >     From: Peter Seiderer <ps.report@gmx.net>
> >
> > ... which git uses as the author of the patch.
> >
> > > If you want to add Peter
> > > as a
> > > co-author that is more than fine by me.
> >
> > It is not about what I want, it is about keeping auhtorship and SoB in
> > sync and coherent with who actually did what.
> >
> > So if I understand correctly: you are the author, so you have your SoB,
> > and Peter is a co-dev for credits, right: Yes/No ? ;-)
Yes
> >
> > If yes, then can I fix the authorship and add the Co-developed-by tag
> > for Peter: Yes/No?
> >
> > If no to either, can you respin a fixed-up patch, please?
> >
> Adam
> > Regards,
> > Yann E. MORIN.
> >
> > > Adam Duskett
> > >
> > > Senior Embedded Systems Developer
> > >
> > > M. +1208-515-8102
> > >
> > > adam.duskett@amarulasolutions.com
> > >
> > > __________________________________
> > >
> > >
> > > Amarula Solutions BV
> > >
> > > Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
> > >
> > > T. +31 (0)85 111 9170
> > > info@amarulasolutions.com
> > >
> > > www.amarulasolutions.com
> > >
> > >
> > >
> > > On Mon, Dec 18, 2023 at 10:22 AM Yann E. MORIN <yann.morin.1998@free.fr>
> > > wrote:
> > >
> > > > Adam, Peter, All,
> > > >
> > > > On 2023-11-02 12:41 -0600, Adam Duskett spake thusly:
> > > > > From: Peter Seiderer <ps.report@gmx.net>
> > > >
> > > > So, this patch is "From Peter", but...
> > > >
> > > > > 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>
> > > >
> > > > ... the first SoB is by Adam, and there is no SoB be Peter.
> > > >
> > > > In this case, I think I understand that Adam took Peter's patch, and
> > > > totally rewrote it with an alternate solution. In such a case, the
> > > > customs is to change the authorship to the new author, and keep a
> > > > Co-developed-by tag to keep credits to the first author.
> > > >
> > > > So, if you can just reply to this mail stating I got things right, I can
> > > > fix authorship and tags when applying. If I got things wrong, then
> > > > please resubmit with proper tags and/or authorship.
> > > >
> > > > Also, it does not make much sense that the submitter of a patch adds
> > > > their own Tested-By tag, as it is actually expected that the submitter
> > > > did test what they sent...
> > > >
> > > > Thanks! :-)
> > > >
> > > > Regards,
> > > > Yann E. MORIN.
> > > >
> > > > > ---
> > > > > 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
> > > > > --
> > > > > 2.41.0
> > > > >
> > > > > _______________________________________________
> > > > > buildroot mailing list
> > > > > buildroot@buildroot.org
> > > > > https://lists.buildroot.org/mailman/listinfo/buildroot
> > > >
> > > > --
> > > >
> > > > .-----------------.--------------------.------------------.--------------------.
> > > > |  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
> > > > conspiracy: |
> > > > | +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
> > > >      |
> > > > | +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is
> > > > no  |
> > > > | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
> > > >  conspiracy.  |
> > > >
> > > > '------------------------------^-------^------------------^--------------------'
> > > >
> >
> > > _______________________________________________
> > > buildroot mailing list
> > > buildroot@buildroot.org
> > > https://lists.buildroot.org/mailman/listinfo/buildroot
> >
> >
> > --
> > .-----------------.--------------------.------------------.--------------------.
> > |  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
> > | +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
> > | +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
> > | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
> > '------------------------------^-------^------------------^--------------------'
Adam Duskett Dec. 24, 2023, 10:10 p.m. UTC | #7
I will mark this series as rejected, as it's not Flutter-related and
Amarula does not currently use PGSQL.

On Mon, Dec 18, 2023 at 3:10 PM Adam Duskett
<adam.duskett@amarulasolutions.com> wrote:
>
> Sorry, Gmail defaulted to HTML.
>
> > On Mon, Dec 18, 2023 at 10:39 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > >
> > > Adam, All,
> > >
> > > [Please, do not top-post]
> > >
> OK
> > > On 2023-12-18 10:28 -0700, Adam Duskett spake thusly:
> > > > I didn't add Peter as the patch is completely different than what he sent
> > > > along with a more
> > > > comprehensive explanation as to what is happening.
> > >
> > > Then you should also have dropped him as the author; note how the first
> > > line of the patch was still:
> > >
> > >     From: Peter Seiderer <ps.report@gmx.net>
> > >
> > > ... which git uses as the author of the patch.
> > >
> > > > If you want to add Peter
> > > > as a
> > > > co-author that is more than fine by me.
> > >
> > > It is not about what I want, it is about keeping auhtorship and SoB in
> > > sync and coherent with who actually did what.
> > >
> > > So if I understand correctly: you are the author, so you have your SoB,
> > > and Peter is a co-dev for credits, right: Yes/No ? ;-)
> Yes
> > >
> > > If yes, then can I fix the authorship and add the Co-developed-by tag
> > > for Peter: Yes/No?
> > >
> > > If no to either, can you respin a fixed-up patch, please?
> > >
> > Adam
> > > Regards,
> > > Yann E. MORIN.
> > >
> > > > Adam Duskett
> > > >
> > > > Senior Embedded Systems Developer
> > > >
> > > > M. +1208-515-8102
> > > >
> > > > adam.duskett@amarulasolutions.com
> > > >
> > > > __________________________________
> > > >
> > > >
> > > > Amarula Solutions BV
> > > >
> > > > Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
> > > >
> > > > T. +31 (0)85 111 9170
> > > > info@amarulasolutions.com
> > > >
> > > > www.amarulasolutions.com
> > > >
> > > >
> > > >
> > > > On Mon, Dec 18, 2023 at 10:22 AM Yann E. MORIN <yann.morin.1998@free.fr>
> > > > wrote:
> > > >
> > > > > Adam, Peter, All,
> > > > >
> > > > > On 2023-11-02 12:41 -0600, Adam Duskett spake thusly:
> > > > > > From: Peter Seiderer <ps.report@gmx.net>
> > > > >
> > > > > So, this patch is "From Peter", but...
> > > > >
> > > > > > 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>
> > > > >
> > > > > ... the first SoB is by Adam, and there is no SoB be Peter.
> > > > >
> > > > > In this case, I think I understand that Adam took Peter's patch, and
> > > > > totally rewrote it with an alternate solution. In such a case, the
> > > > > customs is to change the authorship to the new author, and keep a
> > > > > Co-developed-by tag to keep credits to the first author.
> > > > >
> > > > > So, if you can just reply to this mail stating I got things right, I can
> > > > > fix authorship and tags when applying. If I got things wrong, then
> > > > > please resubmit with proper tags and/or authorship.
> > > > >
> > > > > Also, it does not make much sense that the submitter of a patch adds
> > > > > their own Tested-By tag, as it is actually expected that the submitter
> > > > > did test what they sent...
> > > > >
> > > > > Thanks! :-)
> > > > >
> > > > > Regards,
> > > > > Yann E. MORIN.
> > > > >
> > > > > > ---
> > > > > > 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
> > > > > > --
> > > > > > 2.41.0
> > > > > >
> > > > > > _______________________________________________
> > > > > > buildroot mailing list
> > > > > > buildroot@buildroot.org
> > > > > > https://lists.buildroot.org/mailman/listinfo/buildroot
> > > > >
> > > > > --
> > > > >
> > > > > .-----------------.--------------------.------------------.--------------------.
> > > > > |  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
> > > > > conspiracy: |
> > > > > | +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
> > > > >      |
> > > > > | +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is
> > > > > no  |
> > > > > | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
> > > > >  conspiracy.  |
> > > > >
> > > > > '------------------------------^-------^------------------^--------------------'
> > > > >
> > >
> > > > _______________________________________________
> > > > buildroot mailing list
> > > > buildroot@buildroot.org
> > > > https://lists.buildroot.org/mailman/listinfo/buildroot
> > >
> > >
> > > --
> > > .-----------------.--------------------.------------------.--------------------.
> > > |  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
> > > | +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
> > > | +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
> > > | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
> > > '------------------------------^-------^------------------^--------------------'
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

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