#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer		: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=bash
_basever=5.1
_patchlevel=016
pkgver=${_basever}.${_patchlevel}
pkgrel=01
pkgdesc='The GNU Bourne Again shell'
arch=(x86_64)
_url='https://www.gnu.org/software/bash/bash.html'
url="https://ftp.gnu.org/gnu"
backup=(etc/bash.bash{rc,_logout} etc/skel/.bash{rc,_profile,_logout})
depends=(readline libreadline.so glibc ncurses)
optdepends=('bash-completion: for tab completion')
provides=('sh')
source=($url/$pkgname/bash-$_basever.tar.gz{,.sig}
        dot.bashrc
        dot.bash_profile
        dot.bash_logout
        system.bashrc
        system.bash_logout)

if [[ $((10#${_patchlevel})) -gt 0 ]]; then
  for (( _p=1; _p<=$((10#${_patchlevel})); _p++ )); do
    source=(${source[@]} $url/$pkgname/$pkgname-$_basever-patches/bash${_basever//.}-$(printf "%03d" $_p){,.sig})
  done
fi

prepare() {
  cd $pkgname-$_basever

  for (( _p=1; _p<=$((10#${_patchlevel})); _p++ )); do
    echo "applying patch bash${_basever//.}-$(printf "%03d" $_p)"
    patch -p0 -i ../bash${_basever//.}-$(printf "%03d" $_p)
  done
}

build() {
  cd $pkgname-$_basever

  _bashconfig=(-DDEFAULT_PATH_VALUE=\'\"/usr/local/sbin:/usr/local/bin:/usr/bin\"\'
               -DSTANDARD_UTILS_PATH=\'\"/usr/bin\"\'
               -DSYS_BASHRC=\'\"/etc/bash.bashrc\"\'
               -DSYS_BASH_LOGOUT=\'\"/etc/bash.bash_logout\"\'
               -DNON_INTERACTIVE_LOGIN_SHELLS)
  export CFLAGS="${CFLAGS} ${_bashconfig[@]}"

  ./configure \
    --prefix=/usr \
    --with-curses \
    --enable-readline \
    --without-bash-malloc \
    --with-installed-readline
  make
}

check() {
  make -C $pkgname-$_basever check
}

package() {
  make -C $pkgname-$_basever DESTDIR="$pkgdir" install
  ln -s bash "$pkgdir/usr/bin/sh"

  # system-wide configuration files
  install -Dm644 system.bashrc "$pkgdir/etc/bash.bashrc"
  install -Dm644 system.bash_logout "$pkgdir/etc/bash.bash_logout"

  # user configuration file skeletons
  install -dm755 "$pkgdir/etc/skel/"
  install -m644 dot.bashrc "$pkgdir/etc/skel/.bashrc"
  install -m644 dot.bash_profile "$pkgdir/etc/skel/.bash_profile"
  install -m644 dot.bash_logout "$pkgdir/etc/skel/.bash_logout"
}

#---- license gpg-key sha256sums ----

license=(GPL)

validpgpkeys=('7C0135FB088AAF6C66C650B9BB5869F064EA74AB') # Chet Ramey

sha256sums=(cc012bc860406dcf42f64431bcd3d2fa7560c02915a601aba9cd597a39329baa # bash-5.1.tar.gz
	d532da06303b4127bcc09dd0175d2b04c949a0dfef0420a921698300828d593b # bash-5.1.tar.gz.sig
	3e22bf86ae6708df7a6bceb88c67a00118275f9c0b5268f453dd388af7c43b53 # dot.bashrc
	e149407c2bee17779caec70a7edd3d0000d172e7e4347429b80cb4d55bcec9c2 # dot.bash_profile
	4330edf340394d0dae50afb04ac2a621f106fe67fb634ec81c4bfb98be2a1eb5 # dot.bash_logout
	5fdc20c44bc9058f728d11111327f4dbb5598fec4d948dd5265211598667f9f0 # system.bashrc
	025bccfb374a3edce0ff8154d990689f30976b78f7a932dc9a6fcef81821811e # system.bash_logout
	ebb07b3dbadd98598f078125d0ae0d699295978a5cdaef6282fe19adef45b5fa # bash51-001
	8f8725a5c52f53d3ef185492e09eaacd92c791e24cad4c75bb5ea8a3b1d302b8 # bash51-001.sig
	15ea6121a801e48e658ceee712ea9b88d4ded022046a6147550790caf04f5dbe # bash51-002
	44053017c4a1c5242f8585019a8b44c9af6507b41369535e7040205d4573762c # bash51-002.sig
	22f2cc262f056b22966281babf4b0a2f84cb7dd2223422e5dcd013c3dcbab6b1 # bash51-003
	acaf4a21d10805c32beebca835c600add4119d33ce3dad01c201ef504b4d27f2 # bash51-003.sig
	9aaeb65664ef0d28c0067e47ba5652b518298b3b92d33327d84b98b28d873c86 # bash51-004
	51faca8a8799da8bf815d5488394b6d0c1e3d6ebe3956bfb729b0015e445368f # bash51-004.sig
	cccbb5e9e6763915d232d29c713007a62b06e65126e3dd2d1128a0dc5ef46da5 # bash51-005
	ed1a3d0165faacc89b3fd6aec2250bf01a584ee3e0a65ff031ebb70d661b0dba # bash51-005.sig
	75e17d937de862615c6375def40a7574462210dce88cf741f660e2cc29473d14 # bash51-006
	0914536dee00241945a6d4323982283d9a9b5e2a4356c2623b9a6d8e71595499 # bash51-006.sig
	acfcb8c7e9f73457c0fb12324afb613785e0c9cef3315c9bbab4be702f40393a # bash51-007
	b8f248ca4dcd42144ddd5e3a8ebb72a38313f201685a0c72b886987c6283a3d2 # bash51-007.sig
	f22cf3c51a28f084a25aef28950e8777489072628f972b12643b4534a17ed2d1 # bash51-008
	3a0591328d5853a5e3f31ba77bda56b4104a681aa49c825cfba11fa99430e4e3 # bash51-008.sig
	e45cda953ab4b4b4bde6dc34d0d8ca40d1cc502046eb28070c9ebcd47e33c3ee # bash51-009
	08ef22908e2dc942a94bcdf32f4e4bd4846601e0087aea6ff357f3a0d2fa508e # bash51-009.sig
	a2c8d7b2704eeceff7b1503b7ad9500ea1cb6e9393faebdb3acd2afdd7aeae2a # bash51-010
	d99ce7ff8caf724ad64484caeb4f7300cd79c0c773bcf7429e391538f8c7fc80 # bash51-010.sig
	58191f164934200746f48459a05bca34d1aec1180b08ca2deeee3bb29622027b # bash51-011
	842161b382c59fa4214f012f8df40bc7e504157fe2ed34652dc8aa1ec1a4fb29 # bash51-011.sig
	10f189c8367c4a15c7392e7bf70d0ff6953f78c9b312ed7622303a779273ab98 # bash51-012
	37cc1746a5ca0ca3c299cb130efd6062a71b300f95c11e3e8d5f092a28c85911 # bash51-012.sig
	c7acb66df435d284304c16ca83a5265f9edd9368612095b01a733d45c77ed5ad # bash51-013
	0ddca62d8df55ef4e9a408baaf13acbd422074798093515b8e76c16c05a63565 # bash51-013.sig
	6a4ee0c81b437b96279a792c1efcec4ba56f009195a318083db6b53b096f83d0 # bash51-014
	4ef42bb84993ebb3c44344ee2ee43824271627688401937f7812080fd5d0aa8a # bash51-014.sig
	1b37692ef1f6cc3dcec246773443276066e6b1379868f8c14e01f4dfd4df80f0 # bash51-015
	379a451a66271bae61d11c2c06f207292790b693ad19209ea267da4cee133b02 # bash51-015.sig
	8899144f76a5db1fb41a89ed881c9f19add95728dd71db324f772ef225c5384f # bash51-016
	4434cf0bdcfb49cb203373121122be9718f25b51eaf71d0dd3d31d1f9d621201) #  bash51-016.sig

