app-shells/bash: Fixed "docinto" usage
[gentoo.git] / app-shells / bash / bash-4.4_p23-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit eutils flag-o-matic toolchain-funcs multilib prefix
7
8 # Official patchlevel
9 # See ftp://ftp.cwru.edu/pub/bash/bash-4.4-patches/
10 PLEVEL=${PV##*_p}
11 MY_PV=${PV/_p*}
12 MY_PV=${MY_PV/_/-}
13 MY_P=${PN}-${MY_PV}
14 is_release() {
15         case ${PV} in
16         *_alpha*|*_beta*|*_rc*) return 1 ;;
17         *) return 0 ;;
18         esac
19 }
20 [[ ${PV} != *_p* ]] && PLEVEL=0
21 patches() {
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}/}"
28         else
29                 local u
30                 for u in ftp://ftp.cwru.edu/pub/bash mirror://gnu/${pn} ; do
31                         printf "${u}/${pn}-${pv}-patches/%s " "$@"
32                 done
33         fi
34 }
35
36 # The version of readline this bash normally ships with.
37 READLINE_VER="7.0"
38
39 DESCRIPTION="The standard GNU Bourne again shell"
40 HOMEPAGE="http://tiswww.case.edu/php/chet/bash/bashtop.html"
41 if is_release ; then
42         SRC_URI="mirror://gnu/bash/${MY_P}.tar.gz $(patches)"
43 else
44         SRC_URI="ftp://ftp.cwru.edu/pub/bash/${MY_P}.tar.gz"
45 fi
46
47 LICENSE="GPL-3"
48 SLOT="0"
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"
51
52 DEPEND="
53         >=sys-libs/ncurses-5.2-r2:0=
54         readline? ( >=sys-libs/readline-${READLINE_VER}:0= )
55         nls? ( virtual/libintl )
56 "
57 RDEPEND="
58         ${DEPEND}
59 "
60 # we only need yacc when the .y files get patched (bash42-005)
61 #DEPEND+=" virtual/yacc"
62
63 S="${WORKDIR}/${MY_P}"
64
65 pkg_setup() {
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"
70         fi
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."
74         fi
75 }
76
77 src_unpack() {
78         unpack ${MY_P}.tar.gz
79 }
80
81 src_prepare() {
82         # Include official patches
83         [[ ${PLEVEL} -gt 0 ]] && eapply -p0 $(patches -s)
84
85         eapply "${FILESDIR}/${PN}-4.4-jobs_overflow.patch" #644720
86         eapply "${FILESDIR}/${PN}-4.4-set-SHOBJ_STATUS.patch" #644720
87
88         # Clean out local libs so we know we use system ones w/releases.
89         if is_release ; then
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
93         fi
94
95         # Prefixify hardcoded path names. No-op for non-prefix.
96         hprefixify pathnames.h.in
97
98         # Avoid regenerating docs after patches #407985
99         sed -i -r '/^(HS|RL)USER/s:=.*:=:' doc/Makefile.in || die
100         touch -r . doc/*
101
102         eapply_user
103 }
104
105 src_configure() {
106         local myconf=(
107                 --disable-profiling
108                 --with-curses
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)
114                 $(use_with afs)
115                 $(use_with mem-scramble bash-malloc)
116         )
117
118         # For descriptions of these, see config-top.h
119         # bashrc/#26952 bash_logout/#90488 ssh/#24762 mktemp/#574426
120         append-cppflags \
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)
128
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 )
134
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
139         # be safe.
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%%_*}
143
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 :(.
148
149         if is_release ; then
150                 # Use system readline only with released versions.
151                 myconf+=( --with-installed-readline=. )
152         fi
153
154         if use plugins; then
155                 append-ldflags -Wl,-rpath,/usr/$(get_libdir)/bash
156         else
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
161                 sed -i \
162                         -e '/LOCAL_LDFLAGS=/s:-rdynamic::' \
163                         configure || die
164         fi
165         tc-export AR #444070
166         econf "${myconf[@]}"
167 }
168
169 src_compile() {
170         emake
171
172         if use plugins ; then
173                 emake -C examples/loadables all others
174         fi
175 }
176
177 src_install() {
178         local d f
179
180         default
181
182         dodir /bin
183         mv "${ED%/}"/usr/bin/bash "${ED%/}"/bin/ || die
184         dosym bash /bin/rbash
185
186         insinto /etc/bash
187         doins "${FILESDIR}"/bash_logout
188         doins "$(prefixify_ro "${FILESDIR}"/bashrc)"
189         keepdir /etc/bash/bashrc.d
190         insinto /etc/skel
191         for f in bash{_logout,_profile,rc} ; do
192                 newins "${FILESDIR}"/dot-${f} .${f}
193         done
194
195         local sed_args=(
196                 -e "s:#${USERLAND}#@::"
197                 -e '/#@/d'
198         )
199         if ! use readline ; then
200                 sed_args+=( #432338
201                         -e '/^shopt -s histappend/s:^:#:'
202                         -e 's:use_color=true:use_color=false:'
203                 )
204         fi
205         sed -i \
206                 "${sed_args[@]}" \
207                 "${ED%/}"/etc/skel/.bashrc \
208                 "${ED%/}"/etc/bash/bashrc || die
209
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}
215         fi
216
217         if use examples ; then
218                 for d in examples/{functions,misc,scripts,startup-files} ; do
219                         exeinto /usr/share/doc/${PF}/${d}
220                         docinto ${d}
221                         for f in ${d}/* ; do
222                                 if [[ ${f##*/} != PERMISSION ]] && [[ ${f##*/} != *README ]] ; then
223                                         doexe ${f}
224                                 else
225                                         dodoc ${f}
226                                 fi
227                         done
228                 done
229         fi
230
231         doman doc/*.1
232         newdoc CWRU/changelog ChangeLog
233         dosym bash.info /usr/share/info/bashref.info
234 }
235
236 pkg_preinst() {
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/
240         fi
241
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
249         fi
250 }
251
252 pkg_postinst() {
253         # If /bin/sh does not exist, provide it
254         if [[ ! -e ${EROOT}/bin/sh ]] ; then
255                 ln -sf bash "${EROOT}"/bin/sh
256         fi
257 }