blob: db326660ea9b693d6550d4385e016cdc40c97d20 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "An sh-compatible command language interpreter"
2HOMEPAGE = "http://tiswww.case.edu/php/chet/bash/bashtop.html"
3SECTION = "base/shell"
4
Patrick Williamsc0f7c042017-02-23 20:41:17 -06005DEPENDS = "ncurses bison-native virtual/libiconv"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006
7inherit autotools gettext texinfo update-alternatives ptest
8
Andrew Geisslerd1e89492021-02-12 15:35:20 -06009EXTRA_AUTORECONF += "--exclude=autoheader"
Brad Bishopd5ae7d92018-06-14 09:52:03 -070010EXTRA_OECONF = "--enable-job-control --without-bash-malloc bash_cv_wexitstatus_offset=8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011
12# If NON_INTERACTIVE_LOGIN_SHELLS is defined, all login shells read the
13# startup files, even if they are not interactive.
14# This is what other major distros do. And this is what we wanted. See bug#5359 and bug#7137.
15CFLAGS += "-DNON_INTERACTIVE_LOGIN_SHELLS"
16
Andrew Geisslerd1e89492021-02-12 15:35:20 -060017# This can vary depending upon the host
18CFLAGS += "-DHEREDOC_PIPESIZE=65536"
19
20# Disable bracketed paste mode by default (enabled by default in bash 5.1). It
21# causes a lot of garbage in non-interactive shells
22CFLAGS += "-DBRACKETED_PASTE_DEFAULT=0"
23
Brad Bishop6e60e8b2018-02-01 10:27:11 -050024ALTERNATIVE_${PN} = "bash sh"
25ALTERNATIVE_LINK_NAME[bash] = "${base_bindir}/bash"
26ALTERNATIVE_TARGET[bash] = "${base_bindir}/bash"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027ALTERNATIVE_LINK_NAME[sh] = "${base_bindir}/sh"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028ALTERNATIVE_TARGET[sh] = "${base_bindir}/bash.${BPN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029ALTERNATIVE_PRIORITY = "100"
30
31RDEPENDS_${PN} += "base-files"
32RDEPENDS_${PN}_class-nativesdk = ""
Brad Bishop15ae2502019-06-18 21:44:24 -040033RDEPENDS_${PN}-ptest += "make coreutils perl sed shadow util-linux-setpriv"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034
Brad Bishop15ae2502019-06-18 21:44:24 -040035RDEPENDS_${PN}-ptest_append_libc-glibc = " \
36 glibc-gconv-big5hkscs \
37 glibc-gconv-iso8859-1 \
38 glibc-utils \
39 locale-base-de-de \
40 locale-base-en-us \
41 locale-base-fr-fr \
42 locale-base-fr-fr.iso-8859-1 \
43 locale-base-zh-hk.big5-hkscs \
44 "
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050045
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046CACHED_CONFIGUREVARS += "headersdir=${includedir}/${PN}"
47
Andrew Geisslerd1e89492021-02-12 15:35:20 -060048do_configure_prepend () {
49 if [ ! -e ${S}/acinclude.m4 ]; then
50 cat ${S}/aclocal.m4 > ${S}/acinclude.m4
51 fi
52}
53
Brad Bishopc8f47122019-06-24 09:36:18 -040054do_compile_prepend() {
55 # Remove any leftover .build files. This ensures that bash always has the
56 # same version number and keeps builds reproducible
57 rm -f ${B}/.build
58}
59
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060do_compile_ptest () {
61 oe_runmake buildtest
62}
63
64do_install_append () {
65 # Move /usr/bin/bash to /bin/bash, if need
66 if [ "${base_bindir}" != "${bindir}" ]; then
67 mkdir -p ${D}${base_bindir}
68 mv ${D}${bindir}/bash ${D}${base_bindir}
69 fi
70}
71do_install_append_class-target () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -050072 # Clean buildhost references in bashbug
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050073 sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050074 -e "s,-I${WORKDIR}/\S* ,,g" \
75 -e 's|${DEBUG_PREFIX_MAP}||g' \
76 ${D}${bindir}/bashbug
77
78 # Clean buildhost references in bash.pc
79 sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
80 ${D}${libdir}/pkgconfig/bash.pc
81
82 # Clean buildhost references in Makefile.inc
83 sed -i -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
84 -e 's|${DEBUG_PREFIX_MAP}||g' \
85 -e 's:${HOSTTOOLS_DIR}/::g' \
86 -e 's:${BASE_WORKDIR}/${MULTIMACH_TARGET_SYS}::g' \
87 ${D}${libdir}/bash/Makefile.inc
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088}
89
90do_install_ptest () {
91 make INSTALL_TEST_DIR=${D}${PTEST_PATH}/tests install-test
92 cp ${B}/Makefile ${D}${PTEST_PATH}
Brad Bishop15ae2502019-06-18 21:44:24 -040093 install -D ${WORKDIR}/run-bash-ptests ${D}${PTEST_PATH}/run-bash-ptests
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050094 sed -i -e 's/^Makefile/_Makefile/' -e "s,--sysroot=${STAGING_DIR_TARGET},,g" \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050095 -e 's|${DEBUG_PREFIX_MAP}||g' \
96 -e "s,${S},,g" -e "s,${B},,g" -e "s,${STAGING_DIR_NATIVE},,g" \
97 -e 's:${HOSTTOOLS_DIR}/::g' \
Brad Bishop15ae2502019-06-18 21:44:24 -040098 -e 's:${UNINATIVE_LOADER}:${base_bindir}/false:g' \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050099 ${D}${PTEST_PATH}/Makefile
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100}
Brad Bishop15ae2502019-06-18 21:44:24 -0400101# The uninative loader is different on i386 & x86_64 hosts. Since it is only
102# being replaced with /bin/false anyway, it doesn't need to be part of the task
103# hash
104do_install_ptest[vardepsexclude] += "UNINATIVE_LOADER"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105
106pkg_postinst_${PN} () {
107 grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
108}
109
110pkg_postrm_${PN} () {
111 printf "$(grep -v "^${base_bindir}/bash$" $D${sysconfdir}/shells)\n" > $D${sysconfdir}/shells
112}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113
114PACKAGES += "${PN}-bashbug"
115FILES_${PN} = "${bindir}/bash ${base_bindir}/bash.bash"
116FILES_${PN}-bashbug = "${bindir}/bashbug"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500117
118PACKAGE_BEFORE_PN += "${PN}-loadable"
119RDEPENDS_${PN}-loadable += "${PN}"
120FILES_${PN}-loadable += "${libdir}/bash/*"
121
122RPROVIDES_${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/bin/sh /bin/bash', '', d)}"