1eb8dc403SDave CobbleySUMMARY = "An sh-compatible command language interpreter"
2eb8dc403SDave CobbleyHOMEPAGE = "http://tiswww.case.edu/php/chet/bash/bashtop.html"
395ac1b8dSAndrew GeisslerDESCRIPTION = "Bash is the GNU Project's Bourne Again SHell, a complete implementation of the IEEE POSIX and Open Group shell specification with interactive command line editing, job control on architectures that support it, csh-like features such as history substitution and brace expansion, and a slew of other features."
4eb8dc403SDave CobbleySECTION = "base/shell"
5eb8dc403SDave Cobbley
6eb8dc403SDave CobbleyDEPENDS = "ncurses bison-native virtual/libiconv"
7eb8dc403SDave Cobbley
8eb8dc403SDave Cobbleyinherit autotools gettext texinfo update-alternatives ptest
9eb8dc403SDave Cobbley
10d1e89497SAndrew GeisslerEXTRA_AUTORECONF += "--exclude=autoheader"
11d5ae7d90SBrad BishopEXTRA_OECONF = "--enable-job-control --without-bash-malloc bash_cv_wexitstatus_offset=8"
12eb8dc403SDave Cobbley
13eb8dc403SDave Cobbley# If NON_INTERACTIVE_LOGIN_SHELLS is defined, all login shells read the
14eb8dc403SDave Cobbley# startup files, even if they are not interactive.
15eb8dc403SDave Cobbley# This is what other major distros do. And this is what we wanted. See bug#5359 and bug#7137.
16eb8dc403SDave CobbleyCFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
17eb8dc403SDave Cobbley
18d1e89497SAndrew Geissler# This can vary depending upon the host
19d1e89497SAndrew GeisslerCFLAGS += "-DHEREDOC_PIPESIZE=65536"
20d1e89497SAndrew Geissler
21d1e89497SAndrew Geissler# Disable bracketed paste mode by default (enabled by default in bash 5.1). It
22d1e89497SAndrew Geissler# causes a lot of garbage in non-interactive shells
23d1e89497SAndrew GeisslerCFLAGS += "-DBRACKETED_PASTE_DEFAULT=0"
24d1e89497SAndrew Geissler
25213cb269SPatrick WilliamsALTERNATIVE:${PN} = "bash sh"
26eb8dc403SDave CobbleyALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
27eb8dc403SDave CobbleyALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
28eb8dc403SDave CobbleyALTERNATIVE_LINK_NAME[sh] = "${base_bindir}/sh"
29eb8dc403SDave CobbleyALTERNATIVE_TARGET[sh] = "${base_bindir}/bash.${BPN}"
30eb8dc403SDave CobbleyALTERNATIVE_PRIORITY = "100"
31eb8dc403SDave Cobbley
32213cb269SPatrick WilliamsRDEPENDS:${PN} += "base-files"
33213cb269SPatrick WilliamsRDEPENDS:${PN}:class-nativesdk = ""
34213cb269SPatrick WilliamsRDEPENDS:${PN}-ptest += "make coreutils perl sed shadow util-linux-setpriv"
35eb8dc403SDave Cobbley
36213cb269SPatrick WilliamsRDEPENDS:${PN}-ptest:append:libc-glibc = " \
3715ae2509SBrad Bishop	glibc-gconv-big5hkscs \
3815ae2509SBrad Bishop	glibc-gconv-iso8859-1 \
3915ae2509SBrad Bishop	glibc-utils \
4015ae2509SBrad Bishop	locale-base-de-de \
4115ae2509SBrad Bishop	locale-base-en-us \
4215ae2509SBrad Bishop	locale-base-fr-fr \
4315ae2509SBrad Bishop	locale-base-fr-fr.iso-8859-1 \
4415ae2509SBrad Bishop	locale-base-zh-hk.big5-hkscs \
4515ae2509SBrad Bishop	"
46eb8dc403SDave Cobbley
47eb8dc403SDave CobbleyCACHED_CONFIGUREVARS += "headersdir=${includedir}/${PN}"
48eb8dc403SDave Cobbley
49213cb269SPatrick Williamsdo_configure:prepend () {
50d1e89497SAndrew Geissler    if [ ! -e ${S}/acinclude.m4 ]; then
51d1e89497SAndrew Geissler       cat ${S}/aclocal.m4 > ${S}/acinclude.m4
52d1e89497SAndrew Geissler    fi
53d1e89497SAndrew Geissler}
54d1e89497SAndrew Geissler
55213cb269SPatrick Williamsdo_compile:prepend() {
56c8f47128SBrad Bishop    # Remove any leftover .build files. This ensures that bash always has the
57c8f47128SBrad Bishop    # same version number and keeps builds reproducible
58c8f47128SBrad Bishop    rm -f ${B}/.build
59c8f47128SBrad Bishop}
60c8f47128SBrad Bishop
61eb8dc403SDave Cobbleydo_compile_ptest () {
62eb8dc403SDave Cobbley	oe_runmake buildtest
63eb8dc403SDave Cobbley}
64eb8dc403SDave Cobbley
655199d831SAndrew Geisslerdo_install:prepend () {
665199d831SAndrew Geissler	# Ensure determinism as this counter increases for each make call
675199d831SAndrew Geissler	rm -f ${B}/.build
685199d831SAndrew Geissler}
695199d831SAndrew Geissler
70213cb269SPatrick Williamsdo_install:append () {
71eb8dc403SDave Cobbley	# Move /usr/bin/bash to /bin/bash, if need
72eb8dc403SDave Cobbley	if [ "${base_bindir}" != "${bindir}" ]; then
73eb8dc403SDave Cobbley		mkdir -p ${D}${base_bindir}
74eb8dc403SDave Cobbley		mv ${D}${bindir}/bash ${D}${base_bindir}
75eb8dc403SDave Cobbley	fi
76eb8dc403SDave Cobbley}
77213cb269SPatrick Williamsdo_install:append:class-target () {
78eb8dc403SDave Cobbley	# Clean buildhost references in bashbug
79eb8dc403SDave Cobbley	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
80eb8dc403SDave Cobbley		-e "s,-I${WORKDIR}/\S* ,,g" \
81eb8dc403SDave Cobbley		-e 's|${DEBUG_PREFIX_MAP}||g' \
82eb8dc403SDave Cobbley		${D}${bindir}/bashbug
83eb8dc403SDave Cobbley
84eb8dc403SDave Cobbley	# Clean buildhost references in bash.pc
85eb8dc403SDave Cobbley	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
86eb8dc403SDave Cobbley	     ${D}${libdir}/pkgconfig/bash.pc
87eb8dc403SDave Cobbley
88eb8dc403SDave Cobbley	# Clean buildhost references in Makefile.inc
89eb8dc403SDave Cobbley	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
90eb8dc403SDave Cobbley		-e 's|${DEBUG_PREFIX_MAP}||g' \
91eb8dc403SDave Cobbley		-e 's:${HOSTTOOLS_DIR}/::g' \
92eb8dc403SDave Cobbley		-e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
93eb8dc403SDave Cobbley		${D}${libdir}/bash/Makefile.inc
94eb8dc403SDave Cobbley}
95eb8dc403SDave Cobbley
96eb8dc403SDave Cobbleydo_install_ptest () {
97eb8dc403SDave Cobbley	make INSTALL_TEST_DIR=${D}${PTEST_PATH}/tests install-test
98eb8dc403SDave Cobbley	cp ${B}/Makefile ${D}${PTEST_PATH}
99c926e17cSAndrew Geissler	cp ${B}/config.h ${D}${PTEST_PATH}
100c926e17cSAndrew Geissler	cp ${B}/version.h ${D}${PTEST_PATH}
101c926e17cSAndrew Geissler	cp ${S}/y.tab.[ch] ${D}${PTEST_PATH}
10215ae2509SBrad Bishop	install -D ${WORKDIR}/run-bash-ptests ${D}${PTEST_PATH}/run-bash-ptests
103eb8dc403SDave Cobbley        sed -i -e 's/^Makefile/_Makefile/' -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
104eb8dc403SDave Cobbley	    -e 's|${DEBUG_PREFIX_MAP}||g' \
105eb8dc403SDave Cobbley	    -e "s,${S},,g" -e "s,${B},,g" -e "s,${STAGING_DIR_NATIVE},,g" \
106eb8dc403SDave Cobbley	    -e 's:${HOSTTOOLS_DIR}/::g' \
10715ae2509SBrad Bishop	    -e 's:${UNINATIVE_LOADER}:${base_bindir}/false:g' \
108eb8dc403SDave Cobbley	     ${D}${PTEST_PATH}/Makefile
109eb8dc403SDave Cobbley}
11015ae2509SBrad Bishop# The uninative loader is different on i386 & x86_64 hosts. Since it is only
11115ae2509SBrad Bishop# being replaced with /bin/false anyway, it doesn't need to be part of the task
11215ae2509SBrad Bishop# hash
11315ae2509SBrad Bishopdo_install_ptest[vardepsexclude] += "UNINATIVE_LOADER"
114eb8dc403SDave Cobbley
115213cb269SPatrick Williamspkg_postinst:${PN} () {
116eb8dc403SDave Cobbley	grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
117eb8dc403SDave Cobbley}
118eb8dc403SDave Cobbley
119213cb269SPatrick Williamspkg_postrm:${PN} () {
120eb8dc403SDave Cobbley	printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
121eb8dc403SDave Cobbley}
122eb8dc403SDave Cobbley
123eb8dc403SDave CobbleyPACKAGES += "${PN}-bashbug"
124213cb269SPatrick WilliamsFILES:${PN} = "${bindir}/bash ${base_bindir}/bash.bash"
125213cb269SPatrick WilliamsFILES:${PN}-bashbug = "${bindir}/bashbug"
126eb8dc403SDave Cobbley
127eb8dc403SDave CobbleyPACKAGE_BEFORE_PN += "${PN}-loadable"
128213cb269SPatrick WilliamsRDEPENDS:${PN}-loadable += "${PN}"
129213cb269SPatrick WilliamsFILES:${PN}-loadable += "${libdir}/bash/*"
130eb8dc403SDave Cobbley
131*73bd93f1SPatrick Williams# Limit the RPROVIDES here to class target so that if usrmerge is enabled for nativesdk, it does not
132*73bd93f1SPatrick Williams# include host system paths in /bin/
133*73bd93f1SPatrick WilliamsRPROVIDES:${PN}:append:class-target = " ${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/bash', '', d)}"
134