Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/, app-shells/bash/files/
Date: Tue, 28 Feb 2023 03:20:37
Message-Id: 1677554340.f70b4736f5aa8521c18c1ef39e5d3dcf6d592544.sam@gentoo
1 commit: f70b4736f5aa8521c18c1ef39e5d3dcf6d592544
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Tue Feb 28 03:19:00 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Tue Feb 28 03:19:00 2023 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f70b4736
7
8 app-shells/bash: backport clang 16 configure fix to 5.1
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 app-shells/bash/bash-5.1_p16-r3.ebuild | 315 +++++++++++++++++++++
13 .../files/bash-5.1_p16-configure-clang16.patch | 37 +++
14 2 files changed, 352 insertions(+)
15
16 diff --git a/app-shells/bash/bash-5.1_p16-r3.ebuild b/app-shells/bash/bash-5.1_p16-r3.ebuild
17 new file mode 100644
18 index 000000000000..9ff113498a62
19 --- /dev/null
20 +++ b/app-shells/bash/bash-5.1_p16-r3.ebuild
21 @@ -0,0 +1,315 @@
22 +# Copyright 1999-2023 Gentoo Authors
23 +# Distributed under the terms of the GNU General Public License v2
24 +
25 +EAPI=7
26 +
27 +VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/chetramey.asc
28 +inherit flag-o-matic toolchain-funcs prefix verify-sig
29 +
30 +# Uncomment if we have a patchset
31 +GENTOO_PATCH_DEV="sam"
32 +GENTOO_PATCH_VER="${PV}"
33 +
34 +# Official patchlevel
35 +# See ftp://ftp.cwru.edu/pub/bash/bash-5.1-patches/
36 +PLEVEL="${PV##*_p}"
37 +MY_PV="${PV/_p*}"
38 +MY_PV="${MY_PV/_/-}"
39 +MY_P="${PN}-${MY_PV}"
40 +MY_PATCHES=()
41 +
42 +is_release() {
43 + case ${PV} in
44 + *_alpha*|*_beta*|*_rc*)
45 + return 1
46 + ;;
47 + *)
48 + return 0
49 + ;;
50 + esac
51 +}
52 +
53 +[[ ${PV} != *_p* ]] && PLEVEL=0
54 +
55 +# The version of readline this bash normally ships with.
56 +READLINE_VER="8.1"
57 +
58 +DESCRIPTION="The standard GNU Bourne again shell"
59 +HOMEPAGE="https://tiswww.case.edu/php/chet/bash/bashtop.html"
60 +
61 +if is_release ; then
62 + SRC_URI="mirror://gnu/bash/${MY_P}.tar.gz"
63 + SRC_URI+=" verify-sig? ( mirror://gnu/bash/${MY_P}.tar.gz.sig )"
64 +
65 + if [[ ${PLEVEL} -gt 0 ]] ; then
66 + # bash-5.1 -> bash51
67 + my_p=${PN}$(ver_rs 1-2 '' $(ver_cut 1-2))
68 +
69 + patch_url=
70 + my_patch_index=
71 +
72 + for ((my_patch_index=1; my_patch_index <= ${PLEVEL} ; my_patch_index++)) ; do
73 + for url in mirror://gnu/${pn} ftp://ftp.cwru.edu/pub/bash ; do
74 + patch_url=$(printf "${url}/${PN}-$(ver_cut 1-2)-patches/${my_p}-%03d" ${my_patch_index})
75 + SRC_URI+=" ${patch_url}"
76 + SRC_URI+=" verify-sig? ( ${patch_url}.sig )"
77 +
78 + done
79 +
80 + MY_PATCHES+=( "${DISTDIR}"/$(printf ${my_p}-%03d ${my_patch_index}) )
81 + done
82 +
83 + unset my_pn patch_url my_patch_index
84 + fi
85 +else
86 + SRC_URI="ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"
87 + SRC_URI+=" verify-sig? ( ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz.sig )"
88 +fi
89 +
90 +if [[ -n ${GENTOO_PATCH_VER} ]] ; then
91 + SRC_URI+=" https://dev.gentoo.org/~${GENTOO_PATCH_DEV}/distfiles/${CATEGORY}/${PN}/${PN}-${GENTOO_PATCH_VER}-patches.tar.xz"
92 +fi
93 +
94 +LICENSE="GPL-3"
95 +SLOT="0"
96 +[[ "${PV}" == *_rc* ]] || \
97 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
98 +IUSE="afs bashlogger examples mem-scramble +net nls plugins +readline"
99 +
100 +DEPEND="
101 + >=sys-libs/ncurses-5.2-r2:0=
102 + nls? ( virtual/libintl )
103 + readline? ( >=sys-libs/readline-${READLINE_VER}:0= )
104 +"
105 +RDEPEND="
106 + ${DEPEND}
107 +"
108 +# We only need yacc when the .y files get patched (bash42-005, bash51-011)
109 +BDEPEND="app-alternatives/yacc
110 + verify-sig? ( sec-keys/openpgp-keys-chetramey )"
111 +
112 +S="${WORKDIR}/${MY_P}"
113 +
114 +PATCHES=(
115 + # Patches from Chet sent to bashbug ml
116 + "${WORKDIR}"/${PN}-${GENTOO_PATCH_VER}-patches/${PN}-5.0-syslog-history-extern.patch
117 +
118 + "${FILESDIR}"/${PN}-5.1_p16-configure-clang16.patch
119 +)
120 +
121 +pkg_setup() {
122 + # bug #7332
123 + if is-flag -malign-double ; then
124 + eerror "Detected bad CFLAGS '-malign-double'. Do not use this"
125 + eerror "as it breaks LFS (struct stat64) on x86."
126 + die "remove -malign-double from your CFLAGS mr ricer"
127 + fi
128 +
129 + if use bashlogger ; then
130 + ewarn "The logging patch should ONLY be used in restricted (i.e. honeypot) envs."
131 + ewarn "This will log ALL output you enter into the shell, you have been warned."
132 + fi
133 +}
134 +
135 +src_unpack() {
136 + if [[ ${PV} == 9999 ]] ; then
137 + git-r3_src_unpack
138 + else
139 + if use verify-sig ; then
140 + verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.gz{,.sig}
141 +
142 + local patch
143 + for patch in "${MY_PATCHES[@]}" ; do
144 + verify-sig_verify_detached ${patch}{,.sig}
145 + done
146 + fi
147 +
148 + unpack ${MY_P}.tar.gz
149 +
150 + if [[ -n ${GENTOO_PATCH_VER} ]] ; then
151 + unpack ${PN}-${GENTOO_PATCH_VER}-patches.tar.xz
152 + fi
153 + fi
154 +}
155 +
156 +src_prepare() {
157 + # Include official patches
158 + [[ ${PLEVEL} -gt 0 ]] && eapply -p0 "${MY_PATCHES[@]}"
159 +
160 + # Clean out local libs so we know we use system ones w/releases.
161 + if is_release ; then
162 + rm -rf lib/{readline,termcap}/* || die
163 + touch lib/{readline,termcap}/Makefile.in || die # for config.status
164 + sed -ri -e 's:\$[{(](RL|HIST)_LIBSRC[)}]/[[:alpha:]_-]*\.h::g' Makefile.in || die
165 + fi
166 +
167 + # Prefixify hardcoded path names. No-op for non-prefix.
168 + hprefixify pathnames.h.in
169 +
170 + # Avoid regenerating docs after patches, bug #407985
171 + sed -i -r '/^(HS|RL)USER/s:=.*:=:' doc/Makefile.in || die
172 + touch -r . doc/* || die
173 +
174 + eapply -p0 "${PATCHES[@]}"
175 + eapply_user
176 +}
177 +
178 +src_configure() {
179 + local myconf=(
180 + --disable-profiling
181 +
182 + # Force linking with system curses ... the bundled termcap lib
183 + # sucks bad compared to ncurses. For the most part, ncurses
184 + # is here because readline needs it. But bash itself calls
185 + # ncurses in one or two small places :(.
186 + --with-curses
187 +
188 + $(use_enable mem-scramble)
189 + $(use_enable net net-redirections)
190 + $(use_enable readline)
191 + $(use_enable readline bang-history)
192 + $(use_enable readline history)
193 + $(use_with afs)
194 + $(use_with mem-scramble bash-malloc)
195 + )
196 +
197 + # For descriptions of these, see config-top.h
198 + # bashrc/#26952 bash_logout/#90488 ssh/#24762 mktemp/#574426
199 + append-cppflags \
200 + -DDEFAULT_PATH_VALUE=\'\""${EPREFIX}"/usr/local/sbin:"${EPREFIX}"/usr/local/bin:"${EPREFIX}"/usr/sbin:"${EPREFIX}"/usr/bin:"${EPREFIX}"/sbin:"${EPREFIX}"/bin\"\' \
201 + -DSTANDARD_UTILS_PATH=\'\""${EPREFIX}"/bin:"${EPREFIX}"/usr/bin:"${EPREFIX}"/sbin:"${EPREFIX}"/usr/sbin\"\' \
202 + -DSYS_BASHRC=\'\""${EPREFIX}"/etc/bash/bashrc\"\' \
203 + -DSYS_BASH_LOGOUT=\'\""${EPREFIX}"/etc/bash/bash_logout\"\' \
204 + -DNON_INTERACTIVE_LOGIN_SHELLS \
205 + -DSSH_SOURCE_BASHRC \
206 + $(use bashlogger && echo -DSYSLOG_HISTORY)
207 +
208 + # Don't even think about building this statically without
209 + # reading bug #7714 first. If you still build it statically,
210 + # don't come crying to us with bugs ;).
211 + #use static && export LDFLAGS="${LDFLAGS} -static"
212 + use nls || myconf+=( --disable-nls )
213 +
214 + # Historically, we always used the builtin readline, but since
215 + # our handling of SONAME upgrades has gotten much more stable
216 + # in the PM (and the readline ebuild itself preserves the old
217 + # libs during upgrades), linking against the system copy should
218 + # be safe.
219 + # Exact cached version here doesn't really matter as long as it
220 + # is at least what's in the DEPEND up above.
221 + export ac_cv_rl_version=${READLINE_VER%%_*}
222 +
223 + if is_release ; then
224 + # Use system readline only with released versions.
225 + myconf+=( --with-installed-readline=. )
226 + fi
227 +
228 + if use plugins ; then
229 + append-ldflags -Wl,-rpath,"${EPREFIX}"/usr/$(get_libdir)/bash
230 + else
231 + # Disable the plugins logic by hand since bash doesn't
232 + # provide a way of doing it.
233 + export ac_cv_func_dl{close,open,sym}=no \
234 + ac_cv_lib_dl_dlopen=no ac_cv_header_dlfcn_h=no
235 +
236 + sed -i \
237 + -e '/LOCAL_LDFLAGS=/s:-rdynamic::' \
238 + configure || die
239 + fi
240 +
241 + # bug #444070
242 + tc-export AR
243 +
244 + econf "${myconf[@]}"
245 +}
246 +
247 +src_compile() {
248 + emake
249 +
250 + if use plugins ; then
251 + emake -C examples/loadables all others
252 + fi
253 +}
254 +
255 +src_install() {
256 + local d f
257 +
258 + default
259 +
260 + dodir /bin
261 + mv "${ED}"/usr/bin/bash "${ED}"/bin/ || die
262 + dosym bash /bin/rbash
263 +
264 + insinto /etc/bash
265 + doins "${FILESDIR}"/bash_logout
266 + doins "$(prefixify_ro "${FILESDIR}"/bashrc)"
267 +
268 + keepdir /etc/bash/bashrc.d
269 +
270 + insinto /etc/skel
271 + for f in bash{_logout,_profile,rc} ; do
272 + newins "${FILESDIR}"/dot-${f} .${f}
273 + done
274 +
275 + local sed_args=(
276 + -e "s:#${USERLAND}#@::"
277 + -e '/#@/d'
278 + )
279 +
280 + if ! use readline ; then
281 + # bug #432338
282 + sed_args+=(
283 + -e '/^shopt -s histappend/s:^:#:'
284 + -e 's:use_color=true:use_color=false:'
285 + )
286 + fi
287 +
288 + sed -i \
289 + "${sed_args[@]}" \
290 + "${ED}"/etc/skel/.bashrc \
291 + "${ED}"/etc/bash/bashrc || die
292 +
293 + if use plugins ; then
294 + exeinto /usr/$(get_libdir)/bash
295 + doexe $(echo examples/loadables/*.o | sed 's:\.o::g')
296 +
297 + insinto /usr/include/bash-plugins
298 + doins *.h builtins/*.h include/*.h lib/{glob/glob.h,tilde/tilde.h}
299 + fi
300 +
301 + if use examples ; then
302 + for d in examples/{functions,misc,scripts,startup-files} ; do
303 + exeinto /usr/share/doc/${PF}/${d}
304 + docinto ${d}
305 + for f in ${d}/* ; do
306 + if [[ ${f##*/} != PERMISSION ]] && [[ ${f##*/} != *README ]] ; then
307 + doexe ${f}
308 + else
309 + dodoc ${f}
310 + fi
311 + done
312 + done
313 + fi
314 +
315 + # Install bash_builtins.1 and rbash.1
316 + emake -C doc DESTDIR="${D}" install_builtins
317 + sed 's:bash\.1:man1/&:' doc/rbash.1 > "${T}"/rbash.1 || die
318 + doman "${T}"/rbash.1
319 +
320 + newdoc CWRU/changelog ChangeLog
321 + dosym bash.info /usr/share/info/bashref.info
322 +}
323 +
324 +pkg_preinst() {
325 + if [[ -e ${EROOT}/etc/bashrc ]] && [[ ! -d ${EROOT}/etc/bash ]] ; then
326 + mkdir -p "${EROOT}"/etc/bash
327 + mv -f "${EROOT}"/etc/bashrc "${EROOT}"/etc/bash/
328 + fi
329 +}
330 +
331 +pkg_postinst() {
332 + # If /bin/sh does not exist, provide it
333 + if [[ ! -e ${EROOT}/bin/sh ]] ; then
334 + ln -sf bash "${EROOT}"/bin/sh
335 + fi
336 +}
337
338 diff --git a/app-shells/bash/files/bash-5.1_p16-configure-clang16.patch b/app-shells/bash/files/bash-5.1_p16-configure-clang16.patch
339 new file mode 100644
340 index 000000000000..8d77fbd968a7
341 --- /dev/null
342 +++ b/app-shells/bash/files/bash-5.1_p16-configure-clang16.patch
343 @@ -0,0 +1,37 @@
344 +https://lists.gnu.org/archive/html/bug-bash/2023-02/msg00000.html)
345 +
346 +From 2cdf8b42885189b3cf7c47096b01f104e520546a Mon Sep 17 00:00:00 2001
347 +From: Sam James <sam@g.o>
348 +Date: Thu, 2 Feb 2023 05:43:37 +0000
349 +Subject: [PATCH] aclocal.m4: fix -Wimplicit-function-declaration in dup2 check
350 +
351 +dup2 requires a <unistd.h> include. Fixes the following when diffing config.log
352 + when testing with a stricter compiler:
353 +```
354 +-warning: call to undeclared function 'dup2'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
355 ++error: call to undeclared function 'dup2'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
356 +```
357 +--- aclocal.m4
358 ++++ aclocal.m4
359 +@@ -284,6 +284,9 @@ AC_CACHE_VAL(bash_cv_dup2_broken,
360 + #include <sys/types.h>
361 + #include <fcntl.h>
362 + #include <stdlib.h>
363 ++#ifdef HAVE_UNISTD_H
364 ++#include <unistd.h>
365 ++#endif
366 + int
367 + main()
368 + {
369 +--- configure
370 ++++ configure
371 +@@ -16990,6 +16990,9 @@ else
372 + #include <sys/types.h>
373 + #include <fcntl.h>
374 + #include <stdlib.h>
375 ++#ifdef HAVE_UNISTD_H
376 ++#include <unistd.h>
377 ++#endif
378 + int
379 + main()
380 + {