SPECS/bash/bash.spec
12dfb381
 Summary:        Bourne-Again SHell
 Name:           bash
57dc9e57
 Version:        4.4.18
 Release:        1%{?dist}
12dfb381
 License:        GPLv3
 URL:            http://www.gnu.org/software/bash/
 Group:          System Environment/Base
 Vendor:         VMware, Inc.
 Distribution:   Photon
57dc9e57
 Source0:        http://ftp.gnu.org/gnu/bash/%{name}-%{version}.tar.gz
 %define sha1    bash=6cf9b3c23930ba8a721fee177d1558e5b7cb6104
12dfb381
 Source1:        bash_completion
 Patch0:         bash-4.4.patch
 Provides:       /bin/sh
 Provides:       /bin/bash
87ebd3c1
 BuildRequires:  readline
 Requires:       readline
35a9b2f4
 Requires(post):    /bin/grep
f5cac196
 Requires(post):    /bin/cp
35a9b2f4
 Requires(postun):  /bin/grep
f5cac196
 Requires(postun):  /bin/mv
f4d17450
 %description
 The package contains the Bourne-Again SHell
 
12dfb381
 %package    devel
 Summary:    Header and development files for bash
 Requires:   %{name} = %{version}
 %description    devel
d42baaaf
 It contains the libraries and header files to create applications
 
f4d17450
 %package lang
 Summary: Additional language files for bash
 Group: System Environment/Base
d42baaaf
 Requires: bash >= 4.4
f4d17450
 %description lang
 These are the additional language files of bash.
 
 %prep
57dc9e57
 %setup -q -n bash-4.4.18
f4d17450
 %patch0 -p1
 %build
57dc9e57
 %configure \
12dfb381
     "CFLAGS=-fPIC" \
     --bindir=/bin \
     --htmldir=%{_defaultdocdir}/%{name}-%{version} \
     --without-bash-malloc \
57dc9e57
     --with-installed-readline
f4d17450
 make %{?_smp_mflags}
 %install
 make DESTDIR=%{buildroot} install
 ln -s bash %{buildroot}/bin/sh
 install -vdm 755 %{buildroot}/etc
5b8821c5
 install -vdm 755 %{buildroot}/etc/profile.d
 install -vdm 755 %{buildroot}/etc/skel
026151a2
 install -vdm 755 %{buildroot}/usr/share/bash-completion
 install -m 0644 %{SOURCE1} %{buildroot}/usr/share/bash-completion
d42baaaf
 rm %{buildroot}/usr/lib/bash/Makefile.inc
f4d17450
 
 # Create dircolors
5b8821c5
 cat > %{buildroot}/etc/profile.d/dircolors.sh << "EOF"
f4d17450
 # Setup for /bin/ls and /bin/grep to support color, the alias is in /etc/bashrc.
 if [ -f "/etc/dircolors" ] ; then
         eval $(dircolors -b /etc/dircolors)
 
         if [ -f "$HOME/.dircolors" ] ; then
                 eval $(dircolors -b $HOME/.dircolors)
         fi
 fi
 alias ls='ls --color=auto'
07b07b3f
 grep --help | grep color  >/dev/null 2>&1
 if [ $? -eq 0 ]; then
   alias grep='grep --color=auto'
 fi
f4d17450
 EOF
 
5b8821c5
 cat > %{buildroot}/etc/profile.d/extrapaths.sh << "EOF"
f4d17450
 if [ -d /usr/local/lib/pkgconfig ] ; then
         pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
 fi
 if [ -d /usr/local/bin ]; then
         pathprepend /usr/local/bin
 fi
 if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
         pathprepend /usr/local/sbin
 fi
 EOF
 
5b8821c5
 cat > %{buildroot}/etc/profile.d/readline.sh << "EOF"
f4d17450
 # Setup the INPUTRC environment variable.
 if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then
         INPUTRC=/etc/inputrc
 fi
 export INPUTRC
 EOF
 
5b8821c5
 cat > %{buildroot}/etc/profile.d/umask.sh << "EOF"
f4d17450
 # By default, the umask should be set.
 if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then
   umask 002
 else
   umask 022
 fi
 EOF
 
5b8821c5
 cat > %{buildroot}/etc/profile.d/i18n.sh << "EOF"
f4d17450
 # Begin /etc/profile.d/i18n.sh
 
 unset LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES \
       LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION
 
 if [ -n "$XDG_CONFIG_HOME" ] && [ -r "$XDG_CONFIG_HOME/locale.conf" ]; then
   . "$XDG_CONFIG_HOME/locale.conf"
 elif [ -r /etc/locale.conf ]; then
   . /etc/locale.conf
 fi
 
 export LANG="${LANG:-C}"
 [ -n "$LC_CTYPE" ]          && export LC_CTYPE
 [ -n "$LC_NUMERIC" ]        && export LC_NUMERIC
 [ -n "$LC_TIME" ]           && export LC_TIME
 [ -n "$LC_COLLATE" ]        && export LC_COLLATE
 [ -n "$LC_MONETARY" ]       && export LC_MONETARY
 [ -n "$LC_MESSAGES" ]       && export LC_MESSAGES
 [ -n "$LC_PAPER" ]          && export LC_PAPER
 [ -n "$LC_NAME" ]           && export LC_NAME
 [ -n "$LC_ADDRESS" ]        && export LC_ADDRESS
 [ -n "$LC_TELEPHONE" ]      && export LC_TELEPHONE
 [ -n "$LC_MEASUREMENT" ]    && export LC_MEASUREMENT
 [ -n "$LC_IDENTIFICATION" ] && export LC_IDENTIFICATION
 
 # End /etc/profile.d/i18n.sh
 EOF
 
026151a2
 # bash completion
 cat > %{buildroot}/etc/profile.d/bash_completion.sh << "EOF"
e693f330
 # check for interactive bash and only bash
 if [ -n "$BASH_VERSION" -a -n "$PS1" ]; then
 
026151a2
 # enable bash completion in interactive shells
 if ! shopt -oq posix; then
   if [ -f /usr/share/bash-completion/bash_completion ]; then
     . /usr/share/bash-completion/bash_completion
   fi
 fi
e693f330
 
 fi
026151a2
 EOF
 
3304b4fc
 cat > %{buildroot}/etc/bash.bashrc << "EOF"
 # Begin /etc/bash.bashrc
f4d17450
 # Written for Beyond Linux From Scratch
 # by James Robertson <jameswrobertson@earthlink.net>
 # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
 
 # System wide aliases and functions.
 
 # System wide environment variables and startup programs should go into
 # /etc/profile.  Personal environment variables and startup programs
 # should go into ~/.bash_profile.  Personal aliases and functions should
 # go into ~/.bashrc
 
 # Provides colored /bin/ls and /bin/grep commands.  Used in conjunction
 # with code in /etc/profile.
 
 alias ls='ls --color=auto'
07b07b3f
 grep --help | grep color  >/dev/null 2>&1
 if [ $? -eq 0 ]; then
   alias grep='grep --color=auto'
 fi
f4d17450
 
 # Provides prompt for non-login shells, specifically shells started
 # in the X environment. [Review the LFS archive thread titled
 # PS1 Environment Variable for a great case study behind this script
 # addendum.]
 
 NORMAL="\[\e[0m\]"
 RED="\[\e[1;31m\]"
 GREEN="\[\e[1;32m\]"
 if [[ $EUID == 0 ]] ; then
   PS1="$RED\u [ $NORMAL\w$RED ]# $NORMAL"
 else
   PS1="$GREEN\u [ $NORMAL\w$GREEN ]\$ $NORMAL"
 fi
 
 unset RED GREEN NORMAL
 
3304b4fc
 if test -n "$SSH_CONNECTION" -a -z "$PROFILEREAD"; then
      . /etc/profile > /dev/null 2>&1
 fi
 # End /etc/bash.bashrc
f4d17450
 EOF
 
5b8821c5
 
 cat > %{buildroot}/etc/skel/.bash_profile << "EOF"
f4d17450
 # Begin ~/.bash_profile
 # Written for Beyond Linux From Scratch
 # by James Robertson <jameswrobertson@earthlink.net>
 # updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
 
 # Personal environment variables and startup programs.
 
 # Personal aliases and functions should go in ~/.bashrc.  System wide
 # environment variables and startup programs are in /etc/profile.
 # System wide aliases and functions are in /etc/bashrc.
 
 if [ -f "$HOME/.bashrc" ] ; then
   source $HOME/.bashrc
 fi
 
 if [ -d "$HOME/bin" ] ; then
   pathprepend $HOME/bin
 fi
 
 # Having . in the PATH is dangerous
 #if [ $EUID -gt 99 ]; then
 #  pathappend .
 #fi
 
 # End ~/.bash_profile
 EOF
 
5b8821c5
 cat > %{buildroot}/etc/skel/.bashrc << "EOF"
f4d17450
 # Begin ~/.bashrc
 # Written for Beyond Linux From Scratch
 # by James Robertson <jameswrobertson@earthlink.net>
 
 # Personal aliases and functions.
 
 # Personal environment variables and startup programs should go in
 # ~/.bash_profile.  System wide environment variables and startup
 # programs are in /etc/profile.  System wide aliases and functions are
 # in /etc/bashrc.
 
3304b4fc
 if [ -f "/etc/bash.bashrc" ] ; then
   source /etc/bash.bashrc
f4d17450
 fi
 
 # End ~/.bashrc
 EOF
 
5b8821c5
 cat > %{buildroot}/etc/skel/.bash_logout << "EOF"
f4d17450
 # Begin ~/.bash_logout
 # Written for Beyond Linux From Scratch
 # by James Robertson <jameswrobertson@earthlink.net>
 
 # Personal items to perform on logout.
 
 # End ~/.bash_logout
 EOF
 
5b8821c5
 dircolors -p > %{buildroot}/etc/dircolors
f4d17450
 %find_lang %{name}
 rm -rf %{buildroot}/%{_infodir}
5b8821c5
 
aebccd16
 %check
 make  NON_ROOT_USERNAME=nobody %{?_smp_mflags} check
 
5b8821c5
 %post
f66608a4
 if [ $1 -eq 1 ] ; then
     if [ ! -f "/root/.bash_logout" ] ; then
         cp /etc/skel/.bash_logout /root/.bash_logout
     fi
36a4e937
     if [ ! -f /etc/shells ]; then
a77bf6fb
         echo "/bin/sh" >> /etc/shells
70a51c1b
         echo "/bin/bash" >> /etc/shells
a77bf6fb
         echo "%{_bindir}/sh" >> /etc/shells
36a4e937
         echo "%{_bindir}/bash" >> /etc/shells
     else
a77bf6fb
         grep -q '^/bin/sh$' /etc/shells || \
         echo "/bin/sh" >> /etc/shells
70a51c1b
         grep -q '^/bin/bash$' /etc/shells || \
         echo "/bin/bash" >> /etc/shells
a77bf6fb
         grep -q '^%{_bindir}/sh$' /etc/shells || \
         echo "%{_bindir}/sh" >> /etc/shells
36a4e937
         grep -q '^%{_bindir}/bash$' /etc/shells || \
         echo "%{_bindir}/bash" >> /etc/shells
     fi
f66608a4
 fi
36a4e937
 
beadc480
 %postun
f66608a4
 if [ $1 -eq 0 ] ; then
     if [ -f "/root/.bash_logout" ] ; then
         rm -f /root/.bash_logout
     fi
a77bf6fb
     if [ ! -x /bin/sh ]; then
         grep -v '^/bin/sh$'  /etc/shells | \
         grep -v '^/bin/sh$' > /etc/shells.rpm && \
         mv /etc/shells.rpm /etc/shells
     fi
70a51c1b
     if [ ! -x /bin/bash ]; then
         grep -v '^/bin/bash$'  /etc/shells | \
         grep -v '^/bin/bash$' > /etc/shells.rpm && \
         mv /etc/shells.rpm /etc/shells
     fi
a77bf6fb
     if [ ! -x %{_bindir}/sh ]; then
         grep -v '^%{_bindir}/sh$'  /etc/shells | \
         grep -v '^%{_bindir}/sh$' > /etc/shells.rpm && \
         mv /etc/shells.rpm /etc/shells
     fi
36a4e937
     if [ ! -x %{_bindir}/bash ]; then
         grep -v '^%{_bindir}/bash$'  /etc/shells | \
         grep -v '^%{_bindir}/bash$' > /etc/shells.rpm && \
         mv /etc/shells.rpm /etc/shells
     fi
f66608a4
 fi
36a4e937
 
f4d17450
 %files
 %defattr(-,root,root)
 /bin/*
d42baaaf
 %{_libdir}/%{name}/*
026151a2
 %{_sysconfdir}/
f4d17450
 %{_defaultdocdir}/%{name}-%{version}/*
 %{_defaultdocdir}/%{name}/*
 %{_mandir}/*/*
026151a2
 /usr/share/bash-completion/
f4d17450
 
d42baaaf
 %files devel
 %{_includedir}/%{name}/*
 %{_libdir}/pkgconfig/*
 
f4d17450
 %files lang -f %{name}.lang
 %defattr(-,root,root)
 
 %changelog
57dc9e57
 *   Mon Sep 24 2018 Sujay G <gsujay@vmware.com> 4.4.18-1
 -   Bump bash version to 4.4.18
e693f330
 *   Fri Jan 26 2018 Alexey Makhalov <amakhalov@vmware.com> 4.4.12-3
 -   Run bash_completion only for bash interactive shell
07b07b3f
 *   Mon Dec 11 2017 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 4.4.12-2
 -   conditionally apply grep color alias
12dfb381
 *   Mon Nov 13 2017 Xiaolin Li <xiaolinl@vmware.com> 4.4.12-1
 -   Upstream patch level 12 applied
879a6eba
 *   Mon Oct 02 2017 Kumar Kaushik <kaushikk@vmware.com> 4.4-6
 -   Adding security fix for CVE-2017-5932.
35a9b2f4
 *   Thu Jun 8 2017 Bo Gan <ganb@vmware.com> 4.4-5
 -   Fix dependency again
a77bf6fb
 *   Wed Jun 7 2017 Divya Thaluru <dthaluru@vmware.com>  4.4-4
 -   Added /usr/bin/sh and /bin/sh entries in /etc/shells
f5cac196
 *   Sun Jun 4 2017 Bo Gan <ganb@vmware.com> 4.4-3
 -   Fix dependency
70a51c1b
 *   Thu Feb 2 2017 Divya Thaluru <dthaluru@vmware.com> 4.4-2
 -   Modified bash entry in /etc/shells
d42baaaf
 *   Fri Jan 13 2017 Dheeraj Shetty <dheerajs@vmware.com> 4.4-1
 -   Upgraded version to 4.4
36a4e937
 *   Tue Jan 10 2017 Divya Thaluru <dthaluru@vmware.com> 4.3.30-7
 -   Added bash entry to /etc/shells
87ebd3c1
 *   Wed Nov 16 2016 Alexey Makhalov <amakhalov@vmware.com> 4.3.30-6
 -   Add readline requirements
026151a2
 *   Fri Aug 19 2016 Alexey Makhalov <amakhalov@vmware.com> 4.3.30-5
 -   Enable bash completion support
 *   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 4.3.30-4
 -   GA - Bump release of all rpms
f66608a4
 *   Tue May 3 2016 Divya Thaluru <dthaluru@vmware.com>  4.3.30-3
 -   Fixing spec file to handle rpm upgrade scenario correctly
 *   Thu Mar 10 2016 Divya Thaluru <dthaluru@vmware.com> 4.3.30-2
 -   Adding compile options to load bash.bashrc file and
     loading source file during non-inetractive non-login shell
 *   Tue Jan 12 2016 Xiaolin Li <xiaolinl@vmware.com> 4.3.30-1
 -   Updated to version 4.3.30
 *   Wed Aug 05 2015 Kumar Kaushik <kaushikk@vmware.com> 4.3-4
 -   Adding post unstall section.
026151a2
 *   Wed Jul 22 2015 Alexey Makhalov <amakhalov@vmware.com> 4.3-3
 -   Fix segfault in save_bash_input.
 *   Tue Jun 30 2015 Alexey Makhalov <amakhalov@vmware.com> 4.3-2
 -   /etc/profile.d permission fix. Pack /etc files into rpm
 *   Wed Oct 22 2014 Divya Thaluru <dthaluru@vmware.com> 4.3-1
 -   Initial version
f4d17450