commit:     83bbfec25159aa015c43b7bc7e14f1aa81a11a42
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Aug 19 00:04:25 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 19 00:46:48 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=83bbfec2

sys-apps/locale-gen: add 3.2-r1 and 3.3-r1 and revise 9999 per bug #961743

Upon locale-gen-3.0 being introduced, the ebuild lost the ability to
prefixify the locale-gen script in src_prepare(). Address this issue so
that the shebang is properly adjusted for Gentoo Prefix environments.

I eschewed the use of the prefix eclass because I consider its
implementation to be substandard. I also eschewed the use of sed(1)
because it encourages pattern injection and seldom returns a useful exit
status. Instead, perl is used to replace the shebang. I could think of
no reason not to, given that dev-lang/perl is already a requirement.

Reported-by: Nick Bowler <nbowler <AT> draconx.ca>
Fixes: ecc3beb504587ee532156b4f3f1c82edfd6bf87f
Closes: https://bugs.gentoo.org/961743
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../{locale-gen-3.2.ebuild => locale-gen-3.2-r1.ebuild}    | 14 ++++++++++++++
 .../{locale-gen-3.3.ebuild => locale-gen-3.3-r1.ebuild}    | 14 ++++++++++++++
 sys-apps/locale-gen/locale-gen-9999.ebuild                 | 10 ++++++++++
 3 files changed, 38 insertions(+)

diff --git a/sys-apps/locale-gen/locale-gen-3.2.ebuild 
b/sys-apps/locale-gen/locale-gen-3.2-r1.ebuild
similarity index 71%
rename from sys-apps/locale-gen/locale-gen-3.2.ebuild
rename to sys-apps/locale-gen/locale-gen-3.2-r1.ebuild
index 45a38c7dfc25..832a9c0ffdf1 100644
--- a/sys-apps/locale-gen/locale-gen-3.2.ebuild
+++ b/sys-apps/locale-gen/locale-gen-3.2-r1.ebuild
@@ -18,11 +18,25 @@ fi
 LICENSE="GPL-2"
 SLOT="0"
 
+# In-place editing became safer in v5.28.
+BDEPEND="
+       >=dev-lang/perl-5.28
+"
 RDEPEND="
        >=dev-lang/perl-5.36
        !<sys-libs/glibc-2.37-r3
 "
 
+src_prepare() {
+       # EPREFIX is readonly.
+       local -x MY_EPREFIX=${EPREFIX}
+
+       eapply_user
+
+       perl -pi -e '$f //= ($. == 1 && s/^#!\K\//$ENV{MY_EPREFIX}\//); END { 
exit !$f }' "${PN}" \
+       || die "Failed to prefixify ${PN}"
+}
+
 src_install() {
        dosbin locale-gen
        doman *.[0-8]

diff --git a/sys-apps/locale-gen/locale-gen-3.3.ebuild 
b/sys-apps/locale-gen/locale-gen-3.3-r1.ebuild
similarity index 71%
rename from sys-apps/locale-gen/locale-gen-3.3.ebuild
rename to sys-apps/locale-gen/locale-gen-3.3-r1.ebuild
index 45a38c7dfc25..832a9c0ffdf1 100644
--- a/sys-apps/locale-gen/locale-gen-3.3.ebuild
+++ b/sys-apps/locale-gen/locale-gen-3.3-r1.ebuild
@@ -18,11 +18,25 @@ fi
 LICENSE="GPL-2"
 SLOT="0"
 
+# In-place editing became safer in v5.28.
+BDEPEND="
+       >=dev-lang/perl-5.28
+"
 RDEPEND="
        >=dev-lang/perl-5.36
        !<sys-libs/glibc-2.37-r3
 "
 
+src_prepare() {
+       # EPREFIX is readonly.
+       local -x MY_EPREFIX=${EPREFIX}
+
+       eapply_user
+
+       perl -pi -e '$f //= ($. == 1 && s/^#!\K\//$ENV{MY_EPREFIX}\//); END { 
exit !$f }' "${PN}" \
+       || die "Failed to prefixify ${PN}"
+}
+
 src_install() {
        dosbin locale-gen
        doman *.[0-8]

diff --git a/sys-apps/locale-gen/locale-gen-9999.ebuild 
b/sys-apps/locale-gen/locale-gen-9999.ebuild
index b676a0c54f01..b3bcb3b41b7a 100644
--- a/sys-apps/locale-gen/locale-gen-9999.ebuild
+++ b/sys-apps/locale-gen/locale-gen-9999.ebuild
@@ -27,6 +27,16 @@ RDEPEND="
        !<sys-libs/glibc-2.37-r3
 "
 
+src_prepare() {
+       # EPREFIX is readonly.
+       local -x MY_EPREFIX=${EPREFIX}
+
+       eapply_user
+
+       perl -pi -e '$f //= ($. == 1 && s/^#!\K\//$ENV{MY_EPREFIX}\//); END { 
exit !$f }' "${PN}" \
+       || die "Failed to prefixify ${PN}"
+}
+
 src_install() {
        dosbin locale-gen
        doman *.[0-8]

Reply via email to