Step4: enhanced shell with bash.

Signed-off-by: Chen Wang <wangchen20@iscas.ac.cn>
This commit is contained in:
Chen Wang
2025-12-05 15:16:55 +08:00
committed by Chen Wang
parent a2489ba8f6
commit e5121ac531
12 changed files with 401 additions and 2 deletions

View File

@@ -0,0 +1,38 @@
From 4fa85c85b9a76afd3b19ed75bf17ccd2940f1f55 Mon Sep 17 00:00:00 2001
From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Date: Sun, 16 Feb 2020 16:18:48 +0100
Subject: [PATCH] input.h: add missing include on stdio.h
This will fix the following build failure on uclibc:
test -n "/usr/lfs/hdd_v1/rc-buildroot-test/scripts/instance-2/output/host/bin/arm-linux-ranlib" && /usr/lfs/hdd_v1/rc-buildroot-test/scripts/instance-2/output/host/bin/arm-linux-ranlib libsh.a
In file included from ./exec.def:71:
../input.h:76:3: error: unknown type name 'FILE'
FILE *file;
^~~~
Fixes:
- http://autobuild.buildroot.org/results/bfca306868df54c567215c45c8cdac838d02f567
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
[Upstream status: https://savannah.gnu.org/support/?110196]
---
input.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/input.h b/input.h
index 6aef1269..08b0fdea 100644
--- a/input.h
+++ b/input.h
@@ -21,6 +21,8 @@
#if !defined (_INPUT_H_)
#define _INPUT_H_
+#include <stdio.h>
+
#include "stdc.h"
/* Function pointers can be declared as (Function *)foo. */
--
2.24.1

View File

@@ -0,0 +1,63 @@
From 0217fc2816e47ee296472df71d1011f0eb2937e6 Mon Sep 17 00:00:00 2001
From: Vincent Fazio <vfazio@gmail.com>
Date: Fri, 27 Jan 2023 14:37:26 -0600
Subject: [PATCH] parse.y: fix compilation for non-multibyte builds
Builds configured with --disable-multibyte or when the toolchain does
not have WCHAR support would encounter a compile error due to an
undeclared reference to shell_input_line_property in shell_getc.
Add a HANDLE_MULTIBYTE guard to conditionally compile the block that
references shell_input_line_property in shell_getc as it's only declared
when HANDLE_MULTIBYTE is defined.
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
[Upstream status: https://savannah.gnu.org/patch/index.php?10309]
---
parse.y | 2 ++
y.tab.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/parse.y b/parse.y
index 1d12e639..8f1355c6 100644
--- a/parse.y
+++ b/parse.y
@@ -2640,6 +2640,7 @@ next_alias_char:
parser_state |= PST_ENDALIAS;
/* We need to do this to make sure last_shell_getc_is_singlebyte returns
true, since we are returning a single-byte space. */
+#if defined (HANDLE_MULTIBYTE)
if (shell_input_line_index == shell_input_line_len && last_shell_getc_is_singlebyte == 0)
{
#if 0
@@ -2653,6 +2654,7 @@ next_alias_char:
shell_input_line_property[shell_input_line_index - 1] = 1;
#endif
}
+#endif /* HANDLE_MULTIBYTE */
return ' '; /* END_ALIAS */
}
#endif
diff --git a/y.tab.c b/y.tab.c
index 50c5845b..799f730f 100644
--- a/y.tab.c
+++ b/y.tab.c
@@ -4955,6 +4955,7 @@ next_alias_char:
parser_state |= PST_ENDALIAS;
/* We need to do this to make sure last_shell_getc_is_singlebyte returns
true, since we are returning a single-byte space. */
+#if defined (HANDLE_MULTIBYTE)
if (shell_input_line_index == shell_input_line_len && last_shell_getc_is_singlebyte == 0)
{
#if 0
@@ -4968,6 +4969,7 @@ next_alias_char:
shell_input_line_property[shell_input_line_index - 1] = 1;
#endif
}
+#endif /* HANDLE_MULTIBYTE */
return ' '; /* END_ALIAS */
}
#endif
--
2.25.1

43
package/bash/make.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/usr/bin/bash
source $(dirname "$0")/../common.sh
PKGNAME=bash
PKGVERSION=5.2.37
PKGSOURCE_DIR=bash
PKGSOURCE=bash-5.2.37.tar.gz
PKGURL=http://mirrors.ustc.edu.cn/gnu/bash/bash-5.2.37.tar.gz
PKGBUILDNAME=${PKGNAME}
PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION}
echo "----> Building ${PKGBUILDNAME} ..."
stamp_downloaded
step_start extract
mkdir -p ${PKGBUILD_DIR}
gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf -
chmod -R +rw ${PKGBUILD_DIR}
step_end extract
step_start patch
TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch
step_end patch autotools
step_start configure
(cd ${PKGBUILD_DIR} && rm -rf config.cache && eval "${TARGET_CONFIGURE_OPTS} CXX=no ac_cv_lbl_unaligned_fail=yes ac_cv_func_mmap_fixed_mapped=yes ac_cv_func_memcmp_working=yes ac_cv_have_decl_malloc=yes gl_cv_func_malloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_calloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes lt_cv_sys_lib_search_path_spec=\"\" ac_cv_c_bigendian=no ac_cv_rl_prefix=\"${STAGING_DIR}\" ac_cv_rl_version=\"8.3\" bash_cv_getcwd_malloc=yes bash_cv_job_control_missing=present bash_cv_sys_named_pipes=present bash_cv_func_sigsetjmp=present bash_cv_printf_a_format=yes CONFIG_SITE=/dev/null ./configure --target=${GNU_TARGET_NAME} --host=${GNU_TARGET_NAME} --build=x86_64-pc-linux-gnu --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --localstatedir=/var --program-prefix=\"\" --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no --disable-dependency-tracking --enable-ipv6 --disable-nls --disable-static --enable-shared --bindir=/bin --with-installed-readline --without-bash-malloc")
step_end configure
step_start build
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}"
step_end build
step_start install-target
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} DESTDIR=${TARGET_DIR} install -C ${PKGBUILD_DIR}"
rm -f ${TARGET_DIR}/bin/bashbug
rm -rf ${TARGET_DIR}/usr/lib/bash
step_end install-target
stamp_installed
echo "<---- ${PKGBUILDNAME} build complete."

39
package/ncurses/make-host.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/usr/bin/bash
source $(dirname "$0")/../common.sh
PKGNAME=ncurses
PKGVERSION=6.5-20250720
PKGSOURCE_DIR=ncurses
PKGSOURCE=ncurses-6.5-20250720.tar.gz
PKGURL=https://github.com/ThomasDickey/ncurses-snapshots/archive/v6_5_20250720/ncurses-6.5-20250720.tar.gz
PKGBUILDNAME=host-${PKGNAME}
PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION}
echo "----> Building ${PKGBUILDNAME} ..."
stamp_downloaded
step_start extract
mkdir -p ${PKGBUILD_DIR}
gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf -
chmod -R +rw ${PKGBUILD_DIR}
step_end extract
stamp_patched autotools
step_start configure
(cd ${PKGBUILD_DIR} && rm -rf config.cache; eval "${HOST_CONFIGURE_OPTS} ac_cv_path_LDCONFIG=\"\" CONFIG_SITE=/dev/null ./configure --prefix=\"${HOST_DIR}\" --sysconfdir=\"${HOST_DIR}/etc\" --localstatedir=\"${HOST_DIR}/var\" --enable-shared --disable-static --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --disable-debug --with-xmlto=no --with-fop=no --disable-nls --disable-dependency-tracking --with-shared --without-gpm --without-manpages --without-cxx --without-cxx-binding --without-ada --with-default-terminfo-dir=/usr/share/terminfo --disable-db-install --without-normal")
step_end configure
step_start build
eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}"
step_end build
step_start install-host
eval "${HOST_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} install -C ${PKGBUILD_DIR}"
step_end install-host
stamp_installed
echo "<---- ${PKGBUILDNAME} build complete."

72
package/ncurses/make.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/bash
source $(dirname "$0")/../common.sh
PKGNAME=ncurses
PKGVERSION=6.5-20250720
PKGSOURCE_DIR=ncurses
PKGSOURCE=ncurses-6.5-20250720.tar.gz
PKGURL=https://github.com/ThomasDickey/ncurses-snapshots/archive/v6_5_20250720/ncurses-6.5-20250720.tar.gz
PKGBUILDNAME=${PKGNAME}
PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION}
echo "----> Building ${PKGBUILDNAME} ..."
stamp_downloaded
step_start extract
mkdir -p ${PKGBUILD_DIR}
gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf -
chmod -R +rw ${PKGBUILD_DIR}
step_end extract
stamp_patched autotools
step_start configure
(cd ${PKGBUILD_DIR} && rm -rf config.cache && eval "${TARGET_CONFIGURE_OPTS} CXX=no ac_cv_lbl_unaligned_fail=yes ac_cv_func_mmap_fixed_mapped=yes ac_cv_func_memcmp_working=yes ac_cv_have_decl_malloc=yes gl_cv_func_malloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_calloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes lt_cv_sys_lib_search_path_spec=\"\" ac_cv_c_bigendian=no CONFIG_SITE=/dev/null ./configure --target=${GNU_TARGET_NAME} --host=${GNU_TARGET_NAME} --build=x86_64-pc-linux-gnu --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --localstatedir=/var --program-prefix=\"\" --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no --disable-dependency-tracking --enable-ipv6 --disable-nls --disable-static --enable-shared --without-cxx --without-cxx-binding --without-ada --without-tests --disable-big-core --without-profile --disable-rpath --disable-rpath-hack --enable-echo --enable-const --enable-overwrite --enable-pc-files --disable-stripping --with-pkg-config-libdir=\"/usr/lib/pkgconfig\" --without-progs --without-manpages --with-shared --without-normal --without-gpm --disable-widec --without-debug")
step_end configure
step_start build
# ncurses breaks with parallel build, but takes quite a while to
# build single threaded. Work around it similar to how Gentoo does
eval "${TARGET_MAKE_ENV} /usr/bin/make -j1 -C ${PKGBUILD_DIR} DESTDIR=${STAGING_DIR} sources"
rm -rf ${PKGBUILD_DIR}/misc/pc-files
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR} DESTDIR=${STAGING_DIR}"
step_end build
step_start install-staging
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} DESTDIR=${STAGING_DIR} install -C ${PKGBUILD_DIR}"
step_end install-staging ncurses6-config
step_start install-target
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} DESTDIR=${TARGET_DIR} install -C ${PKGBUILD_DIR}"
rm -f -rf ${TARGET_DIR}/usr/share/terminfo ${TARGET_DIR}/usr/share/tabset
NCURSES_TERMINFO_FILES=" \
a/ansi \
d/dumb \
l/linux \
p/putty \
p/putty-256color \
p/putty-vt100 \
s/screen \
s/screen-256color \
v/vt100 \
v/vt100-putty \
v/vt102 \
v/vt200 \
v/vt220 \
x/xterm \
x/xterm+256color \
x/xterm-256color \
x/xterm-color \
x/xterm-xfree86"
for f in ${NCURSES_TERMINFO_FILES} ; do
/usr/bin/install -D -m 0644 ${STAGING_DIR}/usr/share/terminfo/${f} \
${TARGET_DIR}/usr/share/terminfo/${f}
done
rm -f -f ${TARGET_DIR}/usr/bin/ncurses6-config ;
step_end install-target
stamp_installed
echo "<---- ${PKGBUILDNAME} build complete."

View File

@@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Bernd Kuhls <bernd@kuhls.net>
Date: Sat, 5 Jul 2025 07:48:20 +0200
Subject: [PATCH] Fix build with non-wchar toolchains
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Commit a7f5650e6549e1b5c4e2e1fa30eee19de6bcbe7a added two functions to
mbutil.c but forgot to add defines for HANDLE_MULTIBYTE causing build
errors with toolchains without wchar support:
../mbutil.c: In function _rl_mb_strcaseeqn:
../mbutil.c:594:3: error: unknown type name mbstate_t
Upstream: https://lists.gnu.org/archive/html/bug-readline/2025-07/msg00002.html
Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
---
mbutil.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mbutil.c b/mbutil.c
index 5243fd7..c15f3aa 100644
--- a/mbutil.c
+++ b/mbutil.c
@@ -584,6 +584,7 @@ _rl_find_prev_mbchar (const char *string, int seed, int flags)
#endif
}
+#if defined (HANDLE_MULTIBYTE)
/* Compare the first N characters of S1 and S2 without regard to case. If
FLAGS&1, apply the mapping specified by completion-map-case and make
`-' and `_' equivalent. Returns 1 if the strings are equal. */
@@ -658,3 +659,4 @@ _rl_mb_charcasecmp (const char *s1, mbstate_t *ps1, const char *s2, mbstate_t *p
return 1;
return (wc1 == wc2);
}
+#endif /* HANDLE_MULTIBYTE */
--
2.39.5

44
package/readline/inputrc Normal file
View File

@@ -0,0 +1,44 @@
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info readline' for more information.
# Be 8 bit clean.
set input-meta on
set output-meta on
set bell-style visible
# To allow the use of 8bit-characters like the german umlauts, comment out
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.
# set convert-meta off
"\e0d": backward-word
"\e0c": forward-word
"\e[h": beginning-of-line
"\e[f": end-of-line
"\e[1~": beginning-of-line
"\e[4~": end-of-line
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
# Common standard keypad and cursor
# (codes courtsey Werner Fink, <werner@suse.de>)
#"\e[1~": history-search-backward
"\e[2~": yank
"\e[3~": delete-char
#"\e[4~": set-mark
"\e[5~": history-search-backward
"\e[6~": history-search-forward
# Normal keypad and cursor of xterm
"\e[F": end-of-line
"\e[H": beginning-of-line
# Application keypad and cursor of xterm
"\eOA": previous-history
"\eOC": forward-char
"\eOB": next-history
"\eOD": backward-char
"\eOF": end-of-line
"\eOH": beginning-of-line

46
package/readline/make.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/usr/bin/bash
source $(dirname "$0")/../common.sh
PKGNAME=readline
PKGVERSION=8.3
PKGSOURCE_DIR=readline
PKGSOURCE=readline-8.3.tar.gz
PKGURL=http://mirrors.ustc.edu.cn/gnu/readline/readline-8.3.tar.gz
PKGBUILDNAME=${PKGNAME}
PKGBUILD_DIR=${BUILD_DIR}/${PKGBUILDNAME}-${PKGVERSION}
echo "----> Building ${PKGBUILDNAME} ..."
stamp_downloaded
step_start extract
mkdir -p ${PKGBUILD_DIR}
gzip -d -c ${DL_DIR}/${PKGSOURCE_DIR}/${PKGSOURCE} | tar --strip-components=1 -C ${PKGBUILD_DIR} -xf -
chmod -R +rw ${PKGBUILD_DIR}
step_end extract
step_start patch
TAR="tar" PATH=${HOST_DIR}/bin:$PATH ${PROJECT_DIR}/support/scripts/apply-patches.sh ${PKGBUILD_DIR} ${PROJECT_DIR}/package/${PKGNAME} \*.patch
step_end patch autotools
step_start configure
(cd ${PKGBUILD_DIR} && rm -rf config.cache && eval "${TARGET_CONFIGURE_OPTS} CXX=no ac_cv_lbl_unaligned_fail=yes ac_cv_func_mmap_fixed_mapped=yes ac_cv_func_memcmp_working=yes ac_cv_have_decl_malloc=yes gl_cv_func_malloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_calloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes lt_cv_sys_lib_search_path_spec=\"\" ac_cv_c_bigendian=no bash_cv_func_sigsetjmp=yes bash_cv_wcwidth_broken=no CONFIG_SITE=/dev/null ./configure --target=${GNU_TARGET_NAME} --host=${GNU_TARGET_NAME} --build=x86_64-pc-linux-gnu --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --localstatedir=/var --program-prefix=\"\" --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no --disable-dependency-tracking --enable-ipv6 --disable-nls --disable-static --enable-shared --disable-install-examples --with-curses --with-shared-termcap-library --disable-bracketed-paste-default")
step_end configure
step_start build
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} -C ${PKGBUILD_DIR}"
step_end build
step_start install-staging
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} DESTDIR=${STAGING_DIR} install -C ${PKGBUILD_DIR}"
step_end install-staging
step_start install-target
eval "${TARGET_MAKE_ENV} /usr/bin/make -j${MAXNUM_CPUS} DESTDIR=${TARGET_DIR} install -C ${PKGBUILD_DIR}"
/usr/bin/install -D -m 644 ${PROJECT_DIR}/package/readline/inputrc ${TARGET_DIR}/etc/inputrc
step_end install-target
stamp_installed
echo "<---- ${PKGBUILDNAME} build complete."

View File

@@ -26,10 +26,13 @@ echo ">>> Finalizing target directory"
if grep -q CONFIG_ASH=y ${BUILD_DIR}/busybox-1.37.0/.config; then grep -qsE '^/bin/ash$' ${TARGET_DIR}/etc/shells || echo "/bin/ash" >> ${TARGET_DIR}/etc/shells; fi
if grep -q CONFIG_HUSH=y ${BUILD_DIR}/busybox-1.37.0/.config; then grep -qsE '^/bin/hush$' ${TARGET_DIR}/etc/shells || echo "/bin/hush" >> ${TARGET_DIR}/etc/shells; fi
grep -qsE '^/bin/sh$' ${TARGET_DIR}/etc/shells || echo "/bin/sh" >> ${TARGET_DIR}/etc/shells
grep -qsE '^/bin/bash$' ${TARGET_DIR}/etc/shells || echo "/bin/bash" >> ${TARGET_DIR}/etc/shells
ln -sf bash ${TARGET_DIR}/bin/sh
echo "buildlinux" > ${TARGET_DIR}/etc/hostname
/usr/bin/sed -i -e '$a \127.0.1.1\tbuildlinux' -e '/^127.0.1.1/d' ${TARGET_DIR}/etc/hosts
echo "Welcome to Build Linux System From Scratch" > ${TARGET_DIR}/etc/issue
/usr/bin/sed -i -e s,^root:[^:]*:,root::, ${TARGET_DIR}/etc/shadow
/usr/bin/sed -i -e '/^root:/s,[^/]*$,bash,' ${TARGET_DIR}/etc/passwd
if [ -x ${TARGET_DIR}/sbin/swapon -a -x ${TARGET_DIR}/sbin/swapoff ]; then
/usr/bin/sed -i -e '/^#.*\/sbin\/swap/s/^#\+[[:blank:]]*//' ${TARGET_DIR}/etc/inittab;
else
@@ -62,8 +65,6 @@ find ${TARGET_DIR}/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
find ${TARGET_DIR}/lib/ ${TARGET_DIR}/usr/lib/ ${TARGET_DIR}/usr/libexec/ \
\( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f
rm -rf ${TARGET_DIR}/usr/share/gdb
rm -rf ${TARGET_DIR}/usr/share/bash-completion
rm -rf ${TARGET_DIR}/etc/bash_completion.d
rm -rf ${TARGET_DIR}/usr/share/zsh
rm -rf ${TARGET_DIR}/usr/man ${TARGET_DIR}/usr/share/man
rm -rf ${TARGET_DIR}/usr/info ${TARGET_DIR}/usr/share/info