Re: Mandatory LC_ALL=C.UTF-8 during package building
- To: debian-devel@lists.debian.org
- Cc: Niels Thykier <niels@thykier.net>
- Subject: Re: Mandatory LC_ALL=C.UTF-8 during package building
- From: Guillem Jover <guillem@debian.org>
- Date: Tue, 2 Jul 2024 03:47:29 +0200
- Message-id: <[🔎] ZoNcMeThoRq2RUHK@thunder.hadrons.org>
- Mail-followup-to: debian-devel@lists.debian.org, Niels Thykier <niels@thykier.net>
- In-reply-to: <CADsTwjJTUVEWHpwicZyncc=w0xp3DhfGOjq-rpB5HQuxRLydaA@mail.gmail.com>
- References: <20240606093233.GA115312@psionic12.psi5.com> <171766849730.675231.5191585859517099359@localhost> <f39143c4-d318-4352-bb2e-ae27c1ba8603@bayindir.org> <ZmHIW0o72giqIuFb@remnant.pseudorandom.co.uk> <ZmL9zgsOl3v30b7v@thunder.hadrons.org> <ZmML2ADuj8Q4jSqW@layer-acht.org> <CADsTwjJTUVEWHpwicZyncc=w0xp3DhfGOjq-rpB5HQuxRLydaA@mail.gmail.com>
Hi!
On Fri, 2024-06-07 at 15:40:07 +0200, Alexandre Detiste wrote:
> Maybe a compromise would be to at least mandate some UTF-8 locale.
Ah, good thinking! That would actually seem acceptable. I've prepared
the attached preliminary patch (missing better commit message, etc),
as a PoC for how this could look like. If there's consensus about
something like this, I'd be happy to merge into a future dpkg release.
Although I'm not sure though whether this would be enough to make it
possible to remove the hardcoding of LC_ALL=C.UTF-8 usage in debhelper,
which seems counter to l10n work, or perhaps to switch to a subset of
the locale settings. Niels?
Thanks,
Guillem
From 94c2540fe290ffaa70680d21725e3541642ab2f2 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@debian.org>
Date: Tue, 2 Jul 2024 03:34:35 +0200
Subject: [PATCH] dpkg-buildpackage: Require an UTF-8 (or ASCII) locale when
building packages
Proposed-by: Alexandre Detiste <alexandre.detiste@gmail.com>
---
scripts/dpkg-buildpackage.pl | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index df2edded9..3f02f81ca 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -27,6 +27,7 @@ use File::Temp qw(tempdir);
use File::Basename;
use File::Copy;
use File::Glob qw(bsd_glob GLOB_TILDE GLOB_NOCHECK);
+use I18N::Langinfo qw(langinfo CODESET);
use POSIX qw(:sys_wait_h);
use Dpkg ();
@@ -589,6 +590,19 @@ if ($signsource && build_has_none(BUILD_SOURCE)) {
if ($sanitize_env) {
run_vendor_hook('sanitize-environment');
}
+my %allow_codeset = map { $_ => 1 } qw(
+ UTF-8
+ ANSI_X3.4-1968
+ ANSI_X3.4-1986
+ ISO646-US
+ ASCII
+ US-ASCII
+);
+
+my $codeset = langinfo(CODESET);
+if (not exists $allow_codeset{$codeset}) {
+ error(g_('requires a locale with a UTF-8 (or ASCII) codeset'));
+}
my $build_driver = Dpkg::BuildDriver->new(
ctrl => $ctrl,
--
2.45.2
Reply to: