1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils flag-o-matic toolchain-funcs multilib prefix
9 # See ftp://ftp.cwru.edu/pub/bash/bash-4.4-patches/
16 *_alpha*|*_beta*|*_rc*) return 1 ;;
20 [[ ${PV} != *_p* ]] && PLEVEL=0
22 local opt=$1 plevel=${2:-${PLEVEL}} pn=${3:-${PN}} pv=${4:-${MY_PV}}
23 [[ ${plevel} -eq 0 ]] && return 1
24 eval set -- {1..${plevel}}
25 set -- $(printf "${pn}${pv/\.}-%03d " "$@")
26 if [[ ${opt} == -s ]] ; then
27 echo "${@/#/${DISTDIR}/}"
30 for u in ftp://ftp.cwru.edu/pub/bash mirror://gnu/${pn} ; do
31 printf "${u}/${pn}-${pv}-patches/%s " "$@"
36 # The version of readline this bash normally ships with.
39 DESCRIPTION="The standard GNU Bourne again shell"
40 HOMEPAGE="http://tiswww.case.edu/php/chet/bash/bashtop.html"
42 SRC_URI="mirror://gnu/bash/${MY_P}.tar.gz $(patches)"
44 SRC_URI="ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"
49 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
50 IUSE="afs bashlogger examples mem-scramble +net nls plugins +readline"
53 >=sys-libs/ncurses-5.2-r2:0=
54 readline? ( >=sys-libs/readline-${READLINE_VER}:0= )
55 nls? ( virtual/libintl )
60 # we only need yacc when the .y files get patched (bash42-005)
61 #DEPEND+=" virtual/yacc"
63 S="${WORKDIR}/${MY_P}"
66 if is-flag -malign-double ; then #7332
67 eerror "Detected bad CFLAGS '-malign-double'. Do not use this"
68 eerror "as it breaks LFS (struct stat64) on x86."
69 die "remove -malign-double from your CFLAGS mr ricer"
71 if use bashlogger ; then
72 ewarn "The logging patch should ONLY be used in restricted (i.e. honeypot) envs."
73 ewarn "This will log ALL output you enter into the shell, you have been warned."
82 # Include official patches
83 [[ ${PLEVEL} -gt 0 ]] && eapply -p0 $(patches -s)
85 eapply "${FILESDIR}/${PN}-4.4-jobs_overflow.patch" #644720
86 eapply "${FILESDIR}/${PN}-4.4-set-SHOBJ_STATUS.patch" #644720
88 # Clean out local libs so we know we use system ones w/releases.
90 rm -rf lib/{readline,termcap}/*
91 touch lib/{readline,termcap}/Makefile.in # for config.status
92 sed -ri -e 's:\$[(](RL|HIST)_LIBSRC[)]/[[:alpha:]]*.h::g' Makefile.in || die
95 # Prefixify hardcoded path names. No-op for non-prefix.
96 hprefixify pathnames.h.in
98 # Avoid regenerating docs after patches #407985
99 sed -i -r '/^(HS|RL)USER/s:=.*:=:' doc/Makefile.in || die
109 $(use_enable mem-scramble)
110 $(use_enable net net-redirections)
111 $(use_enable readline)
112 $(use_enable readline bang-history)
113 $(use_enable readline history)
115 $(use_with mem-scramble bash-malloc)
118 # For descriptions of these, see config-top.h
119 # bashrc/#26952 bash_logout/#90488 ssh/#24762 mktemp/#574426
121 -DDEFAULT_PATH_VALUE=\'\"${EPREFIX}/usr/local/sbin:${EPREFIX}/usr/local/bin:${EPREFIX}/usr/sbin:${EPREFIX}/usr/bin:${EPREFIX}/sbin:${EPREFIX}/bin\"\' \
122 -DSTANDARD_UTILS_PATH=\'\"${EPREFIX}/bin:${EPREFIX}/usr/bin:${EPREFIX}/sbin:${EPREFIX}/usr/sbin\"\' \
123 -DSYS_BASHRC=\'\"${EPREFIX}/etc/bash/bashrc\"\' \
124 -DSYS_BASH_LOGOUT=\'\"${EPREFIX}/etc/bash/bash_logout\"\' \
125 -DNON_INTERACTIVE_LOGIN_SHELLS \
126 -DSSH_SOURCE_BASHRC \
127 $(use bashlogger && echo -DSYSLOG_HISTORY)
129 # Don't even think about building this statically without
130 # reading Bug 7714 first. If you still build it statically,
131 # don't come crying to us with bugs ;).
132 #use static && export LDFLAGS="${LDFLAGS} -static"
133 use nls || myconf+=( --disable-nls )
135 # Historically, we always used the builtin readline, but since
136 # our handling of SONAME upgrades has gotten much more stable
137 # in the PM (and the readline ebuild itself preserves the old
138 # libs during upgrades), linking against the system copy should
140 # Exact cached version here doesn't really matter as long as it
141 # is at least what's in the DEPEND up above.
142 export ac_cv_rl_version=${READLINE_VER%%_*}
144 # Force linking with system curses ... the bundled termcap lib
145 # sucks bad compared to ncurses. For the most part, ncurses
146 # is here because readline needs it. But bash itself calls
147 # ncurses in one or two small places :(.
150 # Use system readline only with released versions.
151 myconf+=( --with-installed-readline=. )
155 append-ldflags -Wl,-rpath,/usr/$(get_libdir)/bash
157 # Disable the plugins logic by hand since bash doesn't
158 # provide a way of doing it.
159 export ac_cv_func_dl{close,open,sym}=no \
160 ac_cv_lib_dl_dlopen=no ac_cv_header_dlfcn_h=no
162 -e '/LOCAL_LDFLAGS=/s:-rdynamic::' \
172 if use plugins ; then
173 emake -C examples/loadables all others
183 mv "${ED%/}"/usr/bin/bash "${ED%/}"/bin/ || die
184 dosym bash /bin/rbash
187 doins "${FILESDIR}"/bash_logout
188 doins "$(prefixify_ro "${FILESDIR}"/bashrc)"
189 keepdir /etc/bash/bashrc.d
191 for f in bash{_logout,_profile,rc} ; do
192 newins "${FILESDIR}"/dot-${f} .${f}
196 -e "s:#${USERLAND}#@::"
199 if ! use readline ; then
201 -e '/^shopt -s histappend/s:^:#:'
202 -e 's:use_color=true:use_color=false:'
207 "${ED%/}"/etc/skel/.bashrc \
208 "${ED%/}"/etc/bash/bashrc || die
210 if use plugins ; then
211 exeinto /usr/$(get_libdir)/bash
212 doexe $(echo examples/loadables/*.o | sed 's:\.o::g')
213 insinto /usr/include/bash-plugins
214 doins *.h builtins/*.h include/*.h lib/{glob/glob.h,tilde/tilde.h}
217 if use examples ; then
218 for d in examples/{functions,misc,scripts,startup-files} ; do
219 exeinto /usr/share/doc/${PF}/${d}
222 if [[ ${f##*/} != PERMISSION ]] && [[ ${f##*/} != *README ]] ; then
232 newdoc CWRU/changelog ChangeLog
233 dosym bash.info /usr/share/info/bashref.info
237 if [[ -e ${EROOT}/etc/bashrc ]] && [[ ! -d ${EROOT}/etc/bash ]] ; then
238 mkdir -p "${EROOT}"/etc/bash
239 mv -f "${EROOT}"/etc/bashrc "${EROOT}"/etc/bash/
242 if [[ -L ${EROOT}/bin/sh ]] ; then
243 # rewrite the symlink to ensure that its mtime changes. having /bin/sh
244 # missing even temporarily causes a fatal error with paludis.
245 local target=$(readlink "${EROOT}"/bin/sh)
246 local tmp=$(emktemp "${EROOT}"/bin)
247 ln -sf "${target}" "${tmp}"
248 mv -f "${tmp}" "${EROOT}"/bin/sh
253 # If /bin/sh does not exist, provide it
254 if [[ ! -e ${EROOT}/bin/sh ]] ; then
255 ln -sf bash "${EROOT}"/bin/sh