1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit 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 ~s390 ~sh sparc x86 ~ppc-aix ~x64-cygwin ~amd64-fbsd ~x86-fbsd ~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 )
59 !<sys-apps/portage-2.1.6.7_p1
61 # we only need yacc when the .y files get patched (bash42-005)
62 #DEPEND+=" virtual/yacc"
64 S="${WORKDIR}/${MY_P}"
67 if is-flag -malign-double ; then #7332
68 eerror "Detected bad CFLAGS '-malign-double'. Do not use this"
69 eerror "as it breaks LFS (struct stat64) on x86."
70 die "remove -malign-double from your CFLAGS mr ricer"
72 if use bashlogger ; then
73 ewarn "The logging patch should ONLY be used in restricted (i.e. honeypot) envs."
74 ewarn "This will log ALL output you enter into the shell, you have been warned."
83 # Include official patches
84 [[ ${PLEVEL} -gt 0 ]] && eapply -p0 $(patches -s)
86 eapply "${FILESDIR}/${PN}-4.4-jobs_overflow.patch" #644720
87 eapply "${FILESDIR}/${PN}-4.4-set-SHOBJ_STATUS.patch" #644720
89 # Clean out local libs so we know we use system ones w/releases.
91 rm -rf lib/{readline,termcap}/*
92 touch lib/{readline,termcap}/Makefile.in # for config.status
93 sed -ri -e 's:\$[(](RL|HIST)_LIBSRC[)]/[[:alpha:]]*.h::g' Makefile.in || die
96 # Prefixify hardcoded path names. No-op for non-prefix.
97 hprefixify pathnames.h.in
99 # Avoid regenerating docs after patches #407985
100 sed -i -r '/^(HS|RL)USER/s:=.*:=:' doc/Makefile.in || die
109 --docdir='$(datarootdir)'/doc/${PF}
110 --htmldir='$(docdir)/html'
112 $(use_enable mem-scramble)
113 $(use_enable net net-redirections)
114 $(use_enable readline)
115 $(use_enable readline bang-history)
116 $(use_enable readline history)
118 $(use_with mem-scramble bash-malloc)
121 # For descriptions of these, see config-top.h
122 # bashrc/#26952 bash_logout/#90488 ssh/#24762 mktemp/#574426
124 -DDEFAULT_PATH_VALUE=\'\"${EPREFIX}/usr/local/sbin:${EPREFIX}/usr/local/bin:${EPREFIX}/usr/sbin:${EPREFIX}/usr/bin:${EPREFIX}/sbin:${EPREFIX}/bin\"\' \
125 -DSTANDARD_UTILS_PATH=\'\"${EPREFIX}/bin:${EPREFIX}/usr/bin:${EPREFIX}/sbin:${EPREFIX}/usr/sbin\"\' \
126 -DSYS_BASHRC=\'\"${EPREFIX}/etc/bash/bashrc\"\' \
127 -DSYS_BASH_LOGOUT=\'\"${EPREFIX}/etc/bash/bash_logout\"\' \
128 -DNON_INTERACTIVE_LOGIN_SHELLS \
129 -DSSH_SOURCE_BASHRC \
130 $(use bashlogger && echo -DSYSLOG_HISTORY)
132 # Don't even think about building this statically without
133 # reading Bug 7714 first. If you still build it statically,
134 # don't come crying to us with bugs ;).
135 #use static && export LDFLAGS="${LDFLAGS} -static"
136 use nls || myconf+=( --disable-nls )
138 # Historically, we always used the builtin readline, but since
139 # our handling of SONAME upgrades has gotten much more stable
140 # in the PM (and the readline ebuild itself preserves the old
141 # libs during upgrades), linking against the system copy should
143 # Exact cached version here doesn't really matter as long as it
144 # is at least what's in the DEPEND up above.
145 export ac_cv_rl_version=${READLINE_VER%%_*}
147 # Force linking with system curses ... the bundled termcap lib
148 # sucks bad compared to ncurses. For the most part, ncurses
149 # is here because readline needs it. But bash itself calls
150 # ncurses in one or two small places :(.
153 # Use system readline only with released versions.
154 myconf+=( --with-installed-readline=. )
158 append-ldflags -Wl,-rpath,/usr/$(get_libdir)/bash
160 # Disable the plugins logic by hand since bash doesn't
161 # provide a way of doing it.
162 export ac_cv_func_dl{close,open,sym}=no \
163 ac_cv_lib_dl_dlopen=no ac_cv_header_dlfcn_h=no
165 -e '/LOCAL_LDFLAGS=/s:-rdynamic::' \
175 if use plugins ; then
176 emake -C examples/loadables all others
186 mv "${ED%/}"/usr/bin/bash "${ED%/}"/bin/ || die
187 dosym bash /bin/rbash
190 doins "${FILESDIR}"/bash_logout
191 doins "$(prefixify_ro "${FILESDIR}"/bashrc)"
192 keepdir /etc/bash/bashrc.d
194 for f in bash{_logout,_profile,rc} ; do
195 newins "${FILESDIR}"/dot-${f} .${f}
199 -e "s:#${USERLAND}#@::"
202 if ! use readline ; then
204 -e '/^shopt -s histappend/s:^:#:'
205 -e 's:use_color=true:use_color=false:'
210 "${ED%/}"/etc/skel/.bashrc \
211 "${ED%/}"/etc/bash/bashrc || die
213 if use plugins ; then
214 exeinto /usr/$(get_libdir)/bash
215 doexe $(echo examples/loadables/*.o | sed 's:\.o::g')
216 insinto /usr/include/bash-plugins
217 doins *.h builtins/*.h include/*.h lib/{glob/glob.h,tilde/tilde.h}
220 if use examples ; then
221 for d in examples/{functions,misc,scripts,startup-files} ; do
222 exeinto /usr/share/doc/${PF}/${d}
223 insinto /usr/share/doc/${PF}/${d}
225 if [[ ${f##*/} != PERMISSION ]] && [[ ${f##*/} != *README ]] ; then
235 newdoc CWRU/changelog ChangeLog
236 dosym bash.info /usr/share/info/bashref.info
240 if [[ -e ${EROOT}/etc/bashrc ]] && [[ ! -d ${EROOT}/etc/bash ]] ; then
241 mkdir -p "${EROOT}"/etc/bash
242 mv -f "${EROOT}"/etc/bashrc "${EROOT}"/etc/bash/
245 if [[ -L ${EROOT}/bin/sh ]] ; then
246 # rewrite the symlink to ensure that its mtime changes. having /bin/sh
247 # missing even temporarily causes a fatal error with paludis.
248 local target=$(readlink "${EROOT}"/bin/sh)
249 local tmp=$(emktemp "${EROOT}"/bin)
250 ln -sf "${target}" "${tmp}"
251 mv -f "${tmp}" "${EROOT}"/bin/sh
256 # If /bin/sh does not exist, provide it
257 if [[ ! -e ${EROOT}/bin/sh ]] ; then
258 ln -sf bash "${EROOT}"/bin/sh