Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: bin/, /
Date: Wed, 30 Nov 2022 01:22:45
Message-Id: 1669771355.69cac73ba0a7bcf2e2cff88c60d389895a550623.sam@gentoo
1 commit: 69cac73ba0a7bcf2e2cff88c60d389895a550623
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 30 01:09:12 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 30 01:22:35 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=69cac73b
7
8 ebuild.sh: disable patsub_replacement in Bash 5.2
9
10 patsub_replacement is a new option in bash-5.2 that is also default-on
11 in that release. The default value is not gated by BASH_COMPAT (see bug #881383),
12 hence we need to disable it for older Bashes to avoid behaviour changes in ebuilds
13 and eclasses.
14
15 Thanks to Kerin for both raising this & being persistent with trying
16 to get Bash 5.2 to be suitable for use in Gentoo.
17
18 Bug: https://bugs.gentoo.org/881383
19 Thanks-to: Kerin Millar <kfm <AT> plushkava.net>
20 Signed-off-by: Sam James <sam <AT> gentoo.org>
21
22 NEWS | 5 +++++
23 bin/ebuild.sh | 14 ++++++++++++++
24 2 files changed, 19 insertions(+)
25
26 diff --git a/NEWS b/NEWS
27 index 9284ff81d..1aa8f3e24 100644
28 --- a/NEWS
29 +++ b/NEWS
30 @@ -17,6 +17,11 @@ Features:
31 scratch using a crossdev environment under /usr/${CHOST}.
32
33 Bug fixes:
34 +* ebuild: Handle Bash 5.2's change in behavior which enables the shopt
35 + 'patsub_replacement' by default. This is needed to avoid breaking existing
36 + working ebuilds. Future EAPIs will need to adjust the logic
37 + added by this change. See bug #881383.
38 +
39 * sync: Clobber repositories using sync-type=git to match rsync behavior. This
40 helps with issues where git-synced repositories can become confused
41 if the remote is a CDN and then starts to diverge, preventing further
42
43 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
44 index c1fbcf75a..dc8d205f9 100755
45 --- a/bin/ebuild.sh
46 +++ b/bin/ebuild.sh
47 @@ -18,6 +18,7 @@ source "${PORTAGE_BIN_PATH}/isolated-functions.sh" || exit 1
48 # used instead.
49 __check_bash_version() {
50 # Figure out which min version of bash we require.
51 + # Adjust patsub_replacement logic below on new EAPI!
52 local maj min
53 if ___eapi_bash_3_2 ; then
54 maj=3 min=2
55 @@ -50,6 +51,19 @@ __check_bash_version() {
56 if ___eapi_bash_3_2 && [[ ${BASH_VERSINFO[0]} -gt 3 ]] ; then
57 shopt -s compat32
58 fi
59 +
60 + # patsub_replacement is a new option in bash-5.2 that is also default-on
61 + # in that release. The default value is not gated by BASH_COMPAT (see bug #881383),
62 + # hence we need to disable it for older Bashes to avoid behaviour changes in ebuilds
63 + # and eclasses.
64 + #
65 + # New EAPI note: a newer EAPI (after 8) may well adopt Bash 5.2 as its minimum version.
66 + # If it does, this logic will need to be adjusted to only disable patsub_replacement
67 + # for < ${new_api}!
68 + if (( BASH_VERSINFO[0] >= 6 || ( BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 2 ) )) ; then
69 + shopt -u patsub_replacement
70 + fi
71 +
72 }
73 __check_bash_version