Name:     bash
Version:  5.0
Release:  6
Summary:  It is the Bourne Again Shell
License:  GPLv3
URL:      https://www.gnu.org/software/bash
Source0:  https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.gz

Source1: dot-bashrc
Source2: dot-bash_profile
Source3: dot-bash_logout

# PATCH-FIX-UPSTREAM
Patch1: bash-5.0-patch1.patch
Patch2: bash-5.0-patch2.patch
Patch3: bash-5.0-patch3.patch
Patch4: bash-5.0-patch4.patch
Patch5: bash-5.0-patch5.patch
Patch6: bash-5.0-patch6.patch
Patch7: bash-5.0-patch7.patch
Patch8: bash-5.0-patch8.patch
Patch9: bash-5.0-patch9.patch
Patch10: bash-5.0-patch10.patch
Patch11: bash-5.0-patch11.patch

Patch12: bash-2.02-security.patch
Patch13: bash-2.03-paths.patch
Patch14: bash-2.03-profile.patch
Patch15: bash-2.05a-interpreter.patch
Patch16: bash-2.05b-debuginfo.patch
Patch17: bash-2.05b-manso.patch
Patch18: bash-2.05b-pgrp_sync.patch
Patch19: bash-3.2-audit.patch
Patch20: bash-3.2-ssh_source_bash.patch
Patch21: bash-infotags.patch
Patch22: bash-requires.patch
Patch23: bash-setlocale.patch
Patch24: bash-tty-tests.patch

# rh484809
Patch25: bash-4.0-nobits.patch
Patch26: bash-4.1-examples.patch
Patch27: bash-4.1-broken_pipe.patch
Patch28: bash-4.2-rc2-logout.patch
Patch29: bash-4.2-coverity.patch
# rh799958
Patch30: bash-4.2-manpage_trap.patch
Patch31: bash-4.2-size_type.patch
# rh1112710
Patch32: bash-4.3-man-ulimit.patch
# rh1102815
Patch33: bash-4.3-noecho.patch
# fix bash leaks memory when LC_ALL set-rh1241533,rh1224855
Patch34: bash-4.3-memleak-lc_all.patch
Patch35: bash-4.4-no-loadable-builtins.patch

Patch9000:0001-bugfix-Forbidden-non-root-user-to-clear-history.patch

BuildRequires: gcc bison texinfo

Requires:      filesystem

Provides:      /bin/sh /bin/bash

%description
Bash is the GNU Project's shell. Bash is the Bourne Again SHell. Bash is an sh-compatible
shell that incorporates useful features from the Korn shell (ksh) and C shell (csh). It is
intended to conform to the IEEE POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers
functional improvements over sh for both programming and interactive use. In addition, most
sh scripts can be run by Bash without modification.

%package devel
Summary: Development headers for %{name}
Requires: %{name} = %{version}-%{release}
Requires: pkgconf-pkg-config

%description devel
This package contains development files for %{name}.

%package_help

%prep
%autosetup -n %{name}-%{version} -p1

%build
autoconf
%configure --with-bash-malloc=no --with-afs
%make_build "CPPFLAGS=-D_GNU_SOURCE -DRECYCLES_PIDS -DDEFAULT_PATH_VALUE='\"/usr/local/bin:/usr/bin\"' `getconf LFS_CFLAGS`"

%install
%make_install install-headers
ln -sf bash %{buildroot}%{_bindir}/sh
install -pD %SOURCE1 %{buildroot}/etc/skel/.bashrc
install -pD %SOURCE2 %{buildroot}/etc/skel/.bash_profile
install -pD %SOURCE3 %{buildroot}/etc/skel/.bash_logout

# bug #820192, need to add execable alternatives for regular built-ins
for ea in alias bg cd command fc fg getopts hash jobs read type ulimit umask unalias wait
do
  cat <<EOF > "%{buildroot}"/%{_bindir}/"$ea"
#!/bin/sh
builtin $ea "\$@"
EOF
chmod +x "%{buildroot}"/%{_bindir}/"$ea"
done

%find_lang %{name}

%check
make check

%files -f %{name}.lang
%defattr(-,root,root)
%license COPYING
%config(noreplace) /etc/skel/.%{name}*
%{_bindir}/{sh,bash,alias,bg,cd,command,fc,fg,wait,bashbug}
%{_bindir}/{hash,getopts,jobs,read,type,ulimit,umask,unalias}

%files devel
%defattr(-,root,root)
%{_includedir}/%{name}
%{_libdir}/pkgconfig/*.pc

%files help
%defattr(-,root,root)
%doc NOTES
%doc doc/*.ps doc/*.0 doc/*.html doc/*.txt
%doc %{_docdir}/%{name}/*
%{_infodir}/%{name}.info*
%{_mandir}/man1/*.gz
%exclude %{_infodir}/dir

%changelog
* Thu Oct 24 2019 shenyangyang<shenyangyang4@huawei.com> 5.0-6
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:add build requires of bison and texinfo

* Fri Oct 11 2019 shenyangyang<shenyangyang4@huawei.com> - 5.0-5
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:move the man files

* Mon Sep 30 2019 shenyangyang<shenyangyang4@huawei.com> - 5.0-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:modify requires

* Sat Sep 21 2019 shenyangyang<shenyangyang4@huawei.com> - 5.0-3
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:revise description

* Wed Sep 4 2019 shenyangyang<shenyangyang4@huawei.com> - 5.0-2
- Type:enhancement
- ID:NA
- SUG:restart
- DESC:remove man to main package

* Mon Sep 2 2019 shenyangyang<shenyangyang4@huawei.com> - 5.0-1
- Type:enhancement
- ID:NA
- SUG:restart
- DESC:strenthen spec

* Sat Mar 16 2019 hanzhijun<hanzhijun1@huawei.com> - 4.4.23-7
- Type:bugfix
- ID:NA
- SUG:restart
- DESC:fix pathname expansion of directory

* Fri Jan 25 2019 Xiaoqi Guo<guoxiaoqi2@huawei.com> - 4.4.23-6
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:1000 Forbidden non root user to clear history

* Mon Oct 08 2018 licunlong <licunlong@huawei.com> - 4.4.23-5
- Package Initialization
