Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 312939 - pkg_config() of dev-db/postgresql-server handles locale very badly
Summary: pkg_config() of dev-db/postgresql-server handles locale very badly
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: PgSQL Bugs
URL:
Whiteboard:
Keywords: Inclusion
Depends on:
Blocks:
 
Reported: 2010-04-03 10:05 UTC by Sok Ann Yap
Modified: 2010-06-04 14:22 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
remove artificial intelligence from pkg_config() (postgresql-server-initdb-locale.diff,3.62 KB, patch)
2010-04-10 00:00 UTC, Sok Ann Yap
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sok Ann Yap 2010-04-03 10:05:30 UTC
On systems where /etc/env.d/02locale consists of one-liner like this:

LANG=en_US.UTF-8

the pkg_config() function of dev-db/postgresql-server doesn't work.

I have no idea why the ebuild want to go through the trouble of file parsing to get the locale. From my experience, initdb would have picked up the system's locale automatically anyway.

People who want to set a specific locale would have run initdb manaully, while people who don't care about locale also have to run initdb manually now because the ebuild was trying to be too smart.

Reproducible: Always
Comment 1 Aaron W. Swenson gentoo-dev 2010-04-03 12:26:13 UTC
(In reply to comment #0)
> On systems where /etc/env.d/02locale consists of one-liner like this:
> 
> LANG=en_US.UTF-8
> 
> the pkg_config() function of dev-db/postgresql-server doesn't work.
> 
> I have no idea why the ebuild want to go through the trouble of file parsing to
> get the locale. From my experience, initdb would have picked up the system's
> locale automatically anyway.
> 
> People who want to set a specific locale would have run initdb manaully, while
> people who don't care about locale also have to run initdb manually now because
> the ebuild was trying to be too smart.
> 
> Reproducible: Always
> 

Please see bug 233572 as to why the ebuild behaves in the manner it does. Also, for the proposed update to the init and conf, please see bug 311047.

New official documentation is currently being worked on to cover this behavior.
Comment 2 Sok Ann Yap 2010-04-03 17:18:57 UTC
Regarding bug 233572, I strongly disagree that having to change /etc/env.d/02locale just for postgresql is "the Gentoo way". The original way of allowing locale (and other options) to be set through PG_INITDB_OPTS environment variable is much cleaner, because this is a setting used by initdb only.

Unfortunately, instead of properly fixing bug 233572 to take in the environment variable, you and the maintainer went and put in an over-engineered solution that has no use case. The original fix from Vincent would have been perfect.

Anyway, if you think the current ebuild is fine, that's fine for me. I can just rename the locale file to be /etc/env.d/01locale, so that it is safe from being misused by misbehaving ebuild(s).

BTW, if you think initdb is having problem selecting a reasonable default locale and encoding (which actually work fine for me), shouldn't you file a bug upstream instead? I thought that's how Gentoo supposed to work.
Comment 3 Aaron W. Swenson gentoo-dev 2010-04-03 21:15:06 UTC
The ebuild does not misuse 02locale file. The ebuild merely sources (reads) 02locale, but only if PG_INITDB_OPTS is not set in the respective conf, which is sourced first. There are occasions when a user will localize their system after emerging PostgreSQL, and in those cases initdb won't pick up the changes. THis has more to do with the way Gentoo handles things than upstream.

The ebuild does utilize the solution from Vincent. It sources the conf file for the PG_INITDB_OPTS variable. The ebuild goes a step further to make sure that PG_INITDB_OPTS is set properly for the locale and encoding.
Comment 4 Sok Ann Yap 2010-04-04 14:18:00 UTC
> The ebuild does not misuse 02locale file.

If the ebuild does not misuse the locale file, then why won't it work on a system with one-liner /etc/env.d/02locale like this:

LANG=en_US.UTF-8

Each and every part of the system is fine with this /etc/env.d/02locale, except pkg_config() in postgresql ebuild.

> There are occasions when a user will localize their system after emerging PostgreSQL, and in those cases initdb won't pick up the changes. THis has more to do with the way Gentoo handles things than upstream.

OK, now we are getting into something. I suppose you mean environment.bz2 may contain old locale? If that's the case, then the simplest solution is to make pkg_config() to "eval `locale`", and then just hand off the locale handling to initdb, which will inherit the locale from the environment.

What you did with the ebuild was essentially shifting that "inherit the locale from the environment" functionality from initdb into the ebuild itself. Obviously, initdb can do this job better because it has gone through hundreds of revisions.
Comment 5 Sok Ann Yap 2010-04-04 14:36:24 UTC
Ah, eval `locale` doesn't work if the ebuild already inherits from environment.bz2. Unsetting all locale-related environment variables, and then sourcing from /etc/env.d/02locale (or /etc/profile.env) should be sufficient for initdb to work though.
Comment 6 Aaron W. Swenson gentoo-dev 2010-04-04 16:17:47 UTC
(In reply to comment #5)
> Ah, eval `locale` doesn't work if the ebuild already inherits from
> environment.bz2. Unsetting all locale-related environment variables, and then
> sourcing from /etc/env.d/02locale (or /etc/profile.env) should be sufficient
> for initdb to work though.
> 

Yes, but there isn't a one to one relationship here. LANG doesn't correlate to anything that initdb can set. So, you'd just end up with C or POSIX for all of the various LC settings.
Comment 7 Sok Ann Yap 2010-04-05 02:22:47 UTC
> LANG doesn't correlate to anything that initdb can set. So, you'd just end up with C or POSIX for all of the various LC settings

Wrong. If only LANG is set and none of the LC_* is set, initdb can pick up the locale from LANG without any problem, whereas the half-baked function in the ebuild can't.
Comment 8 Panagiotis Christopoulos (RETIRED) gentoo-dev 2010-04-09 14:27:00 UTC
I'll assign the bug to the proper maintainers, but can the reporter please, simply, write a conclusion about this report? Do you propose something? Do you just complain about the current ebuilds behaviour? What exactly do you suggest here?
Comment 9 Sok Ann Yap 2010-04-09 23:57:32 UTC
Comment 4 has a suggestion that doesn't work. Comment 5 has one that should work. My complaint could be harsh, but I did suggest the fix if you read through the comments.

Comment 10 Sok Ann Yap 2010-04-10 00:00:14 UTC
Created attachment 227187 [details, diff]
remove artificial intelligence from pkg_config()
Comment 11 Aaron W. Swenson gentoo-dev 2010-04-10 20:10:20 UTC
Thank you for submitting your suggestion. It is a bit more elegant than the script in there at the moment, so I'll give it a go and see how it works out.
Comment 12 Patrick Lauer gentoo-dev 2010-06-04 14:22:38 UTC
Done.