39.4. bash-5.3
The Bourne-Again SHell
| Version | 5.3, release 1 |
| Shelf | base — The minimal userland and system daemons that every KDOS image boots with |
| Phase | 30_foundation (Build Foundation), 63 of 127 in build order |
| Licence | GPL-3.0-or-later |
| Homepage | https://www.gnu.org/software/bash/ |
| Build time | 0.6 SBU |
| Installed size | 4.2 MiB in 123 files |
| Recipe | ports/core/base/bash/kpkgbuild |
About
Bash is the GNU shell, and on KDOS it is also /bin/sh. kpkg sources every recipe’s build.sh with it, every configure script runs under it, and the boot and service scripts in /etc/init.d are run by it. It is the login shell of root and of the desktop account, kdos, and its interactive setup lives in /etc/bash.bashrc.
10_bootstrap cross-compiles bash before kpkg exists (Bash); this port rebuilds it natively in the first run of 30_foundation and takes over the files the bootstrap left. The release tarball is followed by the upstream patch series, bash<ver>-NNN, each a separate source of the recipe, and build.sh applies them in order before configuring.
Why it is in KDOS
The comment above the 24 ports from fortify-headers to musl-utils in script/phases/30_foundation/packages.txt is quoted in The build foundation.
Sources
bash-5.3.tar.gz(10.8 MiB)
sha2560d5cd86965f869a26cf64f4b71be7b96f90a3ba8b3d74e27e8e9d9d5550f31ba
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3.tar.gz
archive copy: sources-1/base--bash-5.3.tar.gzbash53-001
sha2561f608434364af86b9b45c8b0ea3fb3b165fb830d27697e6cdfc7ac17dee3287f
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-001bash53-002
sha256e385548a00130765ec7938a56fbdca52447ab41fabc95a25f19ade527e282001
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-002bash53-003
sha256f245d9c7dc3f5a20d84b53d249334747940936f09dc97e1dcb89fc3ab37d60ed
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-003bash53-004
sha2569591d245045529f32f0812f94180b9d9ce9023f5a765c039b852e5dfc99747d0
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-004bash53-005
sha256cca1ef52dbbf433bc98e33269b64b2c814028efe2538be1e2c9a377da90bc99d
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-005bash53-006
sha25629119addefed8eff91ae37fd51822c31780ee30d4a28376e96002706c995ff10
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-006bash53-007
sha256c0976bbfffa1453c7cfdd62058f206a318568ff2d690f5d4fa048793fa3eb299
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-007bash53-008
sha256097cd723cbfb8907674ac32214063a3fd85282657ec5b4e544d2c0f719653fb4
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-008bash53-009
sha256eee30fe78a4b0cb2fe20e010e00308899cfc613e0774ebb3c8557a1552f24f8c
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-009bash53-010
sha256cf76f1cce2ea300c18bff9f002d21f280cc931acd17c28518110b93fe6e72569
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-010bash53-011
sha2560298df8f5ea2a31d3be43ed7d269c5b3c7c342dd5b570bea7f64d66dcbbe7531
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-011bash53-012
sha256d71379b39bebaedaf123414414e77fb458a0a43b9ad3116594c6df7ca6754573
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-012bash53-013
sha256042f9cda967e24bf4211944697441e93d06ff42b4b998629a98a1b249279f200
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-013bash53-014
sha256bd4360b401d38507e358783dcad8536a99c6789f0d3a5bd0cfb8c4a34144696c
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-014bash53-015
sha25655b79ceee2fc27f6767eed697e939a7eb2fe2a28c01556bd75f18d581014f46e
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-015bash53-016
sha2569ea29b266b7d24cb34d0ff3f1c4631e4d527bfe2d1ef15d17cdb924bf31ef767
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-016bash53-017
sha256443b927b45c1558ca72052410f8b8f6e5152b617ed707061a2781d4375b0d1c3
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-017bash53-018
sha256ae715d76c50341d7d7095e9a8d2eeed1ca9546152c2ac7289206f90cf30ac697
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-018bash53-019
sha256a25c581e4d0057dea3833918438a930e2e86ee4c6dc17fe15267b7f04cbc4e3d
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-019bash53-020
sha256df217ed3a9122aa2286d9b67bbe348661b6a9db262b580c29150dae55d532896
upstream: https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.3-patches/bash53-020
Dependencies
Depends on: ncurses, readline.
Required by (21): aurorae, aview, bash-completion, distrobox, go, iptables, kde-dev-scripts, koreader, lesspipe, libiio, lynis, nb, notmuch, openjdk, openresolv, pass, qcad, tlp, v4l-utils, wireguard-tools, zziplib.
Differs from the bootstrap build. Bash builds this source too, in script/phases/10_bootstrap/080_bash.sh, before kpkg exists.
Only in the bootstrap build: --disable-nls, --host=$KDOS_TARGET.
Only in this build: -DSYS_BASHRC.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install bash'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/base/bash.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/base/bash
echo '0d5cd86965f869a26cf64f4b71be7b96f90a3ba8b3d74e27e8e9d9d5550f31ba bash-5.3.tar.gz' | sha256sum -c -
echo '1f608434364af86b9b45c8b0ea3fb3b165fb830d27697e6cdfc7ac17dee3287f bash53-001' | sha256sum -c -
echo 'e385548a00130765ec7938a56fbdca52447ab41fabc95a25f19ade527e282001 bash53-002' | sha256sum -c -
echo 'f245d9c7dc3f5a20d84b53d249334747940936f09dc97e1dcb89fc3ab37d60ed bash53-003' | sha256sum -c -
echo '9591d245045529f32f0812f94180b9d9ce9023f5a765c039b852e5dfc99747d0 bash53-004' | sha256sum -c -
echo 'cca1ef52dbbf433bc98e33269b64b2c814028efe2538be1e2c9a377da90bc99d bash53-005' | sha256sum -c -
echo '29119addefed8eff91ae37fd51822c31780ee30d4a28376e96002706c995ff10 bash53-006' | sha256sum -c -
echo 'c0976bbfffa1453c7cfdd62058f206a318568ff2d690f5d4fa048793fa3eb299 bash53-007' | sha256sum -c -
echo '097cd723cbfb8907674ac32214063a3fd85282657ec5b4e544d2c0f719653fb4 bash53-008' | sha256sum -c -
echo 'eee30fe78a4b0cb2fe20e010e00308899cfc613e0774ebb3c8557a1552f24f8c bash53-009' | sha256sum -c -
echo 'cf76f1cce2ea300c18bff9f002d21f280cc931acd17c28518110b93fe6e72569 bash53-010' | sha256sum -c -
echo '0298df8f5ea2a31d3be43ed7d269c5b3c7c342dd5b570bea7f64d66dcbbe7531 bash53-011' | sha256sum -c -
echo 'd71379b39bebaedaf123414414e77fb458a0a43b9ad3116594c6df7ca6754573 bash53-012' | sha256sum -c -
echo '042f9cda967e24bf4211944697441e93d06ff42b4b998629a98a1b249279f200 bash53-013' | sha256sum -c -
echo 'bd4360b401d38507e358783dcad8536a99c6789f0d3a5bd0cfb8c4a34144696c bash53-014' | sha256sum -c -
echo '55b79ceee2fc27f6767eed697e939a7eb2fe2a28c01556bd75f18d581014f46e bash53-015' | sha256sum -c -
echo '9ea29b266b7d24cb34d0ff3f1c4631e4d527bfe2d1ef15d17cdb924bf31ef767 bash53-016' | sha256sum -c -
echo '443b927b45c1558ca72052410f8b8f6e5152b617ed707061a2781d4375b0d1c3 bash53-017' | sha256sum -c -
echo 'ae715d76c50341d7d7095e9a8d2eeed1ca9546152c2ac7289206f90cf30ac697 bash53-018' | sha256sum -c -
echo 'a25c581e4d0057dea3833918438a930e2e86ee4c6dc17fe15267b7f04cbc4e3d bash53-019' | sha256sum -c -
echo 'df217ed3a9122aa2286d9b67bbe348661b6a9db262b580c29150dae55d532896 bash53-020' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/bash
SRC=$SRC_ROOT/bash-5.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf bash-5.3.tar.gz -C "$SRC" --strip-components=1
cp bash53-001 "$SRC"
cp bash53-002 "$SRC"
cp bash53-003 "$SRC"
cp bash53-004 "$SRC"
cp bash53-005 "$SRC"
cp bash53-006 "$SRC"
cp bash53-007 "$SRC"
cp bash53-008 "$SRC"
cp bash53-009 "$SRC"
cp bash53-010 "$SRC"
cp bash53-011 "$SRC"
cp bash53-012 "$SRC"
cp bash53-013 "$SRC"
cp bash53-014 "$SRC"
cp bash53-015 "$SRC"
cp bash53-016 "$SRC"
cp bash53-017 "$SRC"
cp bash53-018 "$SRC"
cp bash53-019 "$SRC"
cp bash53-020 "$SRC"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _patches, _pfx and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
for p in "$_pfx"-[0-9][0-9][0-9]; do
patch -p0 -i "$p"
done
export CFLAGS="$CFLAGS -DSYS_BASHRC='\"/etc/bash.bashrc\"'"
./configure \
--prefix=/usr \
--with-curses \
--enable-readline \
--without-bash-malloc \
--with-installed-readline
make
make DESTDIR=$PKG install
mkdir -p $PKG/bin
mv $PKG/usr/bin/bash $PKG/bin
ln -sf bash $PKG/bin/sh
The switches, and why each is set:
-DSYS_BASHRC— Compile in/etc/bash.bashrcas the system-wide startup file of an interactive shell. Bash reads it before~/.bashrconly when this is defined; upstream leaves the definition commented out inconfig-top.h. KDOS ships that file, with the history settings, the aliases and the OSC 133 prompt marks Konsole reads to jump between commands.--with-curses— Take the terminal-capability functions from ncurses rather than a separate termcap library.--enable-readline— Build the interactive line editor in. It is upstream’s default, stated.--with-installed-readline— Link the system readline instead of compiling the copy bash carries inlib/readline, so the shell and every other readline program share one library.--without-bash-malloc— Use musl’smallocinstead of the allocator bash ships inlib/malloc, which configure builds in on x86-64 unless told not to.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/bash, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf bash-5.3-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/bash, and runs the triggers its paths call for.
Contents
Installed programs: bash, bashbug, sh.
Installed directories: /usr/include/bash, /usr/lib/bash, /usr/share/doc/bash, /usr/share/licenses/bash.
Short descriptions
bash |
GNU Bourne-Again SHell |
bashbug |
report a bug in bash |
bash.pc |
Bash headers for bash loadable builtins |
Notes
make install puts bash in /usr/bin. build.sh moves it to /bin in the package and makes /bin/sh a link to it. On the installed system /bin is a link to usr/bin, so both land in /usr/bin, over the two files the bootstrap left there, and kpkg folds ./bin/bash to ./usr/bin/bash when it compares ownership, so no other package can claim either name under the other spelling (Who owns a file).
Every #!/bin/sh script on the image runs in bash, so a script that works here may still use something a strict POSIX shell refuses.