1eb8dc403SDave CobbleySUMMARY = "An sh-compatible command language interpreter"
2eb8dc403SDave CobbleyHOMEPAGE = "http://tiswww.case.edu/php/chet/bash/bashtop.html"
3eb8dc403SDave CobbleySECTION = "base/shell"
4eb8dc403SDave Cobbley
5eb8dc403SDave CobbleyDEPENDS = "ncurses bison-native virtual/libiconv"
6eb8dc403SDave Cobbley
7eb8dc403SDave Cobbleyinherit autotools gettext texinfo update-alternatives ptest
8eb8dc403SDave Cobbley
9eb8dc403SDave CobbleyEXTRA_AUTORECONF += "--exclude=autoheader --exclude=aclocal"
10d5ae7d90SBrad BishopEXTRA_OECONF = "--enable-job-control --without-bash-malloc bash_cv_wexitstatus_offset=8"
11eb8dc403SDave Cobbley
12eb8dc403SDave Cobbley# If NON_INTERACTIVE_LOGIN_SHELLS is defined, all login shells read the
13eb8dc403SDave Cobbley# startup files, even if they are not interactive.
14eb8dc403SDave Cobbley# This is what other major distros do. And this is what we wanted. See bug#5359 and bug#7137.
15eb8dc403SDave CobbleyCFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
16eb8dc403SDave Cobbley
17eb8dc403SDave CobbleyALTERNATIVE_${PN} = "bash sh"
18eb8dc403SDave CobbleyALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
19eb8dc403SDave CobbleyALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
20eb8dc403SDave CobbleyALTERNATIVE_LINK_NAME[sh] = "${base_bindir}/sh"
21eb8dc403SDave CobbleyALTERNATIVE_TARGET[sh] = "${base_bindir}/bash.${BPN}"
22eb8dc403SDave CobbleyALTERNATIVE_PRIORITY = "100"
23eb8dc403SDave Cobbley
24eb8dc403SDave CobbleyRDEPENDS_${PN} += "base-files"
25eb8dc403SDave CobbleyRDEPENDS_${PN}_class-nativesdk = ""
26*15ae2509SBrad BishopRDEPENDS_${PN}-ptest += "make coreutils perl sed shadow util-linux-setpriv"
27eb8dc403SDave Cobbley
28eb8dc403SDave CobbleyDEPENDS_append_libc-glibc = " virtual/libc-locale"
29*15ae2509SBrad BishopRDEPENDS_${PN}-ptest_append_libc-glibc = " \
30*15ae2509SBrad Bishop	glibc-gconv-big5hkscs \
31*15ae2509SBrad Bishop	glibc-gconv-iso8859-1 \
32*15ae2509SBrad Bishop	glibc-utils \
33*15ae2509SBrad Bishop	locale-base-de-de \
34*15ae2509SBrad Bishop	locale-base-en-us \
35*15ae2509SBrad Bishop	locale-base-fr-fr \
36*15ae2509SBrad Bishop	locale-base-fr-fr.iso-8859-1 \
37*15ae2509SBrad Bishop	locale-base-zh-hk.big5-hkscs \
38*15ae2509SBrad Bishop	"
39eb8dc403SDave Cobbley
40eb8dc403SDave CobbleyCACHED_CONFIGUREVARS += "headersdir=${includedir}/${PN}"
41eb8dc403SDave Cobbley
42eb8dc403SDave Cobbleydo_compile_ptest () {
43eb8dc403SDave Cobbley	oe_runmake buildtest
44eb8dc403SDave Cobbley}
45eb8dc403SDave Cobbley
46eb8dc403SDave Cobbleydo_install_append () {
47eb8dc403SDave Cobbley	# Move /usr/bin/bash to /bin/bash, if need
48eb8dc403SDave Cobbley	if [ "${base_bindir}" != "${bindir}" ]; then
49eb8dc403SDave Cobbley		mkdir -p ${D}${base_bindir}
50eb8dc403SDave Cobbley		mv ${D}${bindir}/bash ${D}${base_bindir}
51eb8dc403SDave Cobbley	fi
52eb8dc403SDave Cobbley}
53eb8dc403SDave Cobbleydo_install_append_class-target () {
54eb8dc403SDave Cobbley	# Clean buildhost references in bashbug
55eb8dc403SDave Cobbley	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
56eb8dc403SDave Cobbley		-e "s,-I${WORKDIR}/\S* ,,g" \
57eb8dc403SDave Cobbley		-e 's|${DEBUG_PREFIX_MAP}||g' \
58eb8dc403SDave Cobbley		${D}${bindir}/bashbug
59eb8dc403SDave Cobbley
60eb8dc403SDave Cobbley	# Clean buildhost references in bash.pc
61eb8dc403SDave Cobbley	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
62eb8dc403SDave Cobbley	     ${D}${libdir}/pkgconfig/bash.pc
63eb8dc403SDave Cobbley
64eb8dc403SDave Cobbley	# Clean buildhost references in Makefile.inc
65eb8dc403SDave Cobbley	sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
66eb8dc403SDave Cobbley		-e 's|${DEBUG_PREFIX_MAP}||g' \
67eb8dc403SDave Cobbley		-e 's:${HOSTTOOLS_DIR}/::g' \
68eb8dc403SDave Cobbley		-e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
69eb8dc403SDave Cobbley		${D}${libdir}/bash/Makefile.inc
70eb8dc403SDave Cobbley}
71eb8dc403SDave Cobbley
72eb8dc403SDave Cobbleydo_install_ptest () {
73eb8dc403SDave Cobbley	make INSTALL_TEST_DIR=${D}${PTEST_PATH}/tests install-test
74eb8dc403SDave Cobbley	cp ${B}/Makefile ${D}${PTEST_PATH}
75*15ae2509SBrad Bishop	install -D ${WORKDIR}/run-bash-ptests ${D}${PTEST_PATH}/run-bash-ptests
76eb8dc403SDave Cobbley        sed -i -e 's/^Makefile/_Makefile/' -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
77eb8dc403SDave Cobbley	    -e 's|${DEBUG_PREFIX_MAP}||g' \
78eb8dc403SDave Cobbley	    -e "s,${S},,g" -e "s,${B},,g" -e "s,${STAGING_DIR_NATIVE},,g" \
79eb8dc403SDave Cobbley	    -e 's:${HOSTTOOLS_DIR}/::g' \
80*15ae2509SBrad Bishop	    -e 's:${UNINATIVE_LOADER}:${base_bindir}/false:g' \
81eb8dc403SDave Cobbley	     ${D}${PTEST_PATH}/Makefile
82eb8dc403SDave Cobbley}
83*15ae2509SBrad Bishop# The uninative loader is different on i386 & x86_64 hosts. Since it is only
84*15ae2509SBrad Bishop# being replaced with /bin/false anyway, it doesn't need to be part of the task
85*15ae2509SBrad Bishop# hash
86*15ae2509SBrad Bishopdo_install_ptest[vardepsexclude] += "UNINATIVE_LOADER"
87eb8dc403SDave Cobbley
88eb8dc403SDave Cobbleypkg_postinst_${PN} () {
89eb8dc403SDave Cobbley	grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
90eb8dc403SDave Cobbley}
91eb8dc403SDave Cobbley
92eb8dc403SDave Cobbleypkg_postrm_${PN} () {
93eb8dc403SDave Cobbley	printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
94eb8dc403SDave Cobbley}
95eb8dc403SDave Cobbley
96eb8dc403SDave CobbleyPACKAGES += "${PN}-bashbug"
97eb8dc403SDave CobbleyFILES_${PN} = "${bindir}/bash ${base_bindir}/bash.bash"
98eb8dc403SDave CobbleyFILES_${PN}-bashbug = "${bindir}/bashbug"
99eb8dc403SDave Cobbley
100eb8dc403SDave CobbleyPACKAGE_BEFORE_PN += "${PN}-loadable"
101eb8dc403SDave CobbleyRDEPENDS_${PN}-loadable += "${PN}"
102eb8dc403SDave CobbleyFILES_${PN}-loadable += "${libdir}/bash/*"
103eb8dc403SDave Cobbley
104eb8dc403SDave CobbleyRPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/bash', '', d)}"
105