99c641
Summary:          MirBSD enhanced version of the Korn Shell
99c641
Name:             mksh
99c641
Version:          56c
99c641
Release:          5%{?dist}
99c641
# BSD (setmode.c), ISC (strlcpy.c), MirOS (the rest)
99c641
License:          MirOS and ISC and BSD
99c641
Group:            System Environment/Shells
99c641
URL:              https://www.mirbsd.org/mksh.htm
99c641
Source0:          https://www.mirbsd.org/MirOS/dist/mir/%{name}/%{name}-R%{version}.tgz
99c641
Source1:          dot-mkshrc
99c641
Source2:          rtchecks.expected
99c641
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
99c641
Conflicts:        filesystem < 3
99c641
Provides:         /bin/lksh, /bin/mksh
99c641
%endif
99c641
Requires(post):   grep, chkconfig
99c641
Requires(preun):  chkconfig
99c641
BuildRequires:    util-linux, ed
99c641
#for usage of alternatives
99c641
Conflicts:        ksh < 20120801-250
99c641
99c641
%description
99c641
mksh is the MirBSD enhanced version of the Public Domain Korn shell (pdksh),
99c641
a bourne-compatible shell which is largely similar to the original AT&T Korn
99c641
shell. It includes bug fixes and feature improvements in order to produce a
99c641
modern, robust shell good for interactive and especially script use, being a
99c641
bourne shell replacement, pdksh successor and an alternative to the C shell.
99c641
99c641
%prep
99c641
%setup -q -n %{name}
99c641
99c641
# we'll need this later
99c641
cat >rtchecks <<'EOF'
99c641
typeset -i sari=0
99c641
typeset -Ui uari=0
99c641
typeset -i x=0
99c641
print -r -- $((x++)):$sari=$uari. #0
99c641
let --sari --uari
99c641
print -r -- $((x++)):$sari=$uari. #1
99c641
sari=2147483647 uari=2147483647
99c641
print -r -- $((x++)):$sari=$uari. #2
99c641
let ++sari ++uari
99c641
print -r -- $((x++)):$sari=$uari. #3
99c641
let --sari --uari
99c641
let 'sari *= 2' 'uari *= 2'
99c641
let ++sari ++uari
99c641
print -r -- $((x++)):$sari=$uari. #4
99c641
let ++sari ++uari
99c641
print -r -- $((x++)):$sari=$uari. #5
99c641
sari=-2147483648 uari=-2147483648
99c641
print -r -- $((x++)):$sari=$uari. #6
99c641
let --sari --uari
99c641
print -r -- $((x++)):$sari=$uari. #7
99c641
(( sari = -5 >> 1 ))
99c641
((# uari = -5 >> 1 ))
99c641
print -r -- $((x++)):$sari=$uari. #8
99c641
(( sari = -2 ))
99c641
((# uari = sari ))
99c641
print -r -- $((x++)):$sari=$uari. #9
99c641
EOF
99c641
99c641
%build
99c641
# Work around RHBZ #922974 on Fedora 19 and later
99c641
%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
99c641
CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL" LDFLAGS="$RPM_LD_FLAGS" sh Build.sh -r
99c641
%else
99c641
CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL" LDFLAGS="$RPM_LD_FLAGS" sh Build.sh -r -c lto
99c641
%endif
99c641
cp test.sh test_mksh.sh
99c641
HAVE_PERSISTENT_HISTORY=0; export HAVE_PERSISTENT_HISTORY
99c641
# Work around RHBZ #922974 on Fedora 19 and later
99c641
%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
99c641
CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL" LDFLAGS="$RPM_LD_FLAGS" sh Build.sh -L -r
99c641
%else
99c641
CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL" LDFLAGS="$RPM_LD_FLAGS" sh Build.sh -L -r -c lto
99c641
%endif
99c641
cp -f test.sh test_lksh.sh
99c641
99c641
%install
99c641
rm -rf $RPM_BUILD_ROOT
99c641
mkdir -p $RPM_BUILD_ROOT{/bin,%{_bindir},%{_mandir}/man1}
99c641
install -D -m 755 %{name} $RPM_BUILD_ROOT%{_bindir}/%{name}
99c641
install -D -m 755 lksh $RPM_BUILD_ROOT%{_bindir}/lksh
99c641
install -D -m 644 %{name}.1 $RPM_BUILD_ROOT%{_mandir}/man1/%{name}.1
99c641
install -D -m 644 lksh.1 $RPM_BUILD_ROOT%{_mandir}/man1/lksh.1
99c641
install -D -p -m 644 dot.mkshrc $RPM_BUILD_ROOT%{_sysconfdir}/mkshrc
99c641
install -D -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/skel/.mkshrc
99c641
99c641
# fool rpmdiff about %ghost files
99c641
touch $RPM_BUILD_ROOT/bin/ksh
99c641
touch $RPM_BUILD_ROOT%{_mandir}/man1/ksh.1.gz
99c641
99c641
%check
99c641
./mksh rtchecks >rtchecks.got 2>&1
99c641
if ! cmp --quiet rtchecks.got %{SOURCE2}
99c641
then
99c641
  echo "rtchecks failed"
99c641
  diff -Naurp %{SOURCE2} rtchecks.got
99c641
  exit 1
99c641
fi
99c641
99c641
for tf in test_mksh.sh test_lksh.sh
99c641
do
99c641
  echo > test.wait
99c641
  script -qc "./$tf"' -v; x=$?; rm -f test.wait; exit $x'
99c641
  maxwait=0
99c641
  while test -e test.wait; do
99c641
    sleep 1
99c641
    maxwait=$(expr $maxwait + 1)
99c641
    test $maxwait -lt 900 || break
99c641
  done
99c641
done
99c641
99c641
%post
99c641
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
99c641
grep -q "^/bin/%{name}$" %{_sysconfdir}/shells 2>/dev/null || \
99c641
  echo "/bin/%{name}" >> %{_sysconfdir}/shells
99c641
%endif
99c641
grep -q "^%{_bindir}/%{name}$" %{_sysconfdir}/shells 2>/dev/null || \
99c641
  echo "%{_bindir}/%{name}" >> %{_sysconfdir}/shells
99c641
99c641
%{_sbindir}/alternatives --install /usr/bin/ksh ksh \
99c641
                /usr/bin/mksh 10 \
99c641
        --slave %{_mandir}/man1/ksh.1.gz ksh-man \
99c641
                %{_mandir}/man1/mksh.1.gz
99c641
99c641
%preun
99c641
if [ $1 = 0 ]; then
99c641
        %{_sbindir}/alternatives --remove ksh /usr/bin/mksh
99c641
fi
99c641
99c641
%postun
99c641
if [ ! -x %{_bindir}/%{name} ]; then
99c641
%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
99c641
  sed -e 's@^/bin/%{name}$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells
99c641
%endif
99c641
  sed -e 's@^%{_bindir}/%{name}$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells
99c641
fi
99c641
99c641
%files
99c641
%doc dot.mkshrc
99c641
%ghost /bin/ksh
99c641
%ghost %{_mandir}/man1/ksh.1.gz
99c641
%{_bindir}/%{name}
99c641
%{_bindir}/lksh
99c641
%config(noreplace) %{_sysconfdir}/mkshrc
99c641
%config(noreplace) %{_sysconfdir}/skel/.mkshrc
99c641
%{_mandir}/man1/%{name}.1*
99c641
%{_mandir}/man1/lksh.1*
99c641
99c641
%changelog
99c641
* Mon Oct 22 2018 Michal Hlavinka <mhlavink@redhat.com> - 56c-5
99c641
- fix alternative paths (#1636076)
99c641
99c641
* Mon Oct 15 2018 Michal Hlavinka <mhlavink@redhat.com> - 56c-4
99c641
- add alternatives switching with ksh (#1636076)
99c641
99c641
* Sun Feb 18 2018 Robert Scheck <robert@fedoraproject.org> 56c-3
99c641
- Build flags injection is only partially successful (#1543842)
99c641
 
99c641
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 56c-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
99c641
99c641
* Sun Jan 14 2018 Robert Scheck <robert@fedoraproject.org> 56c-1
99c641
- Upgrade to 56c
99c641
99c641
* Tue Aug 29 2017 Robert Scheck <robert@fedoraproject.org> 56b-1
99c641
- Upgrade to 56b
99c641
99c641
* Wed Aug 09 2017 Michal Hlavinka <mhlavink@redhat.com> 56-1
99c641
- Upgrade to 56 (#1479800)
99c641
- fixes wait exit codes of co-processes when run in interactive mode (#1479320)
99c641
99c641
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 55-3
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
99c641
99c641
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 55-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
99c641
99c641
* Thu Apr 13 2017 Robert Scheck <robert@fedoraproject.org> 55-1
99c641
- Upgrade to 55
99c641
99c641
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 54-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
99c641
99c641
* Sun Nov 13 2016 Robert Scheck <robert@fedoraproject.org> 54-1
99c641
- Upgrade to 54 (#1394477)
99c641
99c641
* Sun Aug 28 2016 Robert Scheck <robert@fedoraproject.org> 53a-1
99c641
- Upgrade to 53a (#1370764)
99c641
99c641
* Mon Mar 07 2016 Robert Scheck <robert@fedoraproject.org> 52c-1
99c641
- Upgrade to 52c
99c641
99c641
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 52b-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
99c641
99c641
* Thu Jan 21 2016 Robert Scheck <robert@fedoraproject.org> 52b-1
99c641
- Upgrade to 52b (#1300482)
99c641
99c641
* Sun Dec 13 2015 Robert Scheck <robert@fedoraproject.org> 52-1
99c641
- Upgrade to 52 (#1291069)
99c641
99c641
* Sat Jul 11 2015 Robert Scheck <robert@fedoraproject.org> 51-1
99c641
- Upgrade to 51 (#1242108)
99c641
99c641
* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 50f-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
99c641
99c641
* Mon Apr 20 2015 Robert Scheck <robert@fedoraproject.org> 50f-1
99c641
- Upgrade to 50f
99c641
99c641
* Thu Mar 19 2015 Robert Scheck <robert@fedoraproject.org> 50e-1
99c641
- Upgrade to 50e
99c641
- Apply https://fedoraproject.org/wiki/Features/UsrMove
99c641
99c641
* Wed Oct 08 2014 Robert Scheck <robert@fedoraproject.org> 50d-1
99c641
- Upgrade to 50d (#1150493)
99c641
99c641
* Fri Oct 03 2014 Robert Scheck <robert@fedoraproject.org> 50c-1
99c641
- Upgrade to 50c
99c641
99c641
* Thu Sep 11 2014 Robert Scheck <robert@fedoraproject.org> 50b-1
99c641
- Upgrade to 50b
99c641
99c641
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 50-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
99c641
99c641
* Thu Jul 03 2014 Robert Scheck <robert@fedoraproject.org> 50-1
99c641
- Upgrade to 50
99c641
99c641
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 49-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
99c641
99c641
* Tue Jan 14 2014 Robert Scheck <robert@fedoraproject.org> 49-1
99c641
- Upgrade to 49
99c641
99c641
* Sun Aug 25 2013 Robert Scheck <robert@fedoraproject.org> 48b-1
99c641
- Upgrade to 48b
99c641
99c641
* Sat Aug 03 2013 Robert Scheck <robert@fedoraproject.org> 47-1
99c641
- Upgrade to 47
99c641
99c641
* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 46-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
99c641
99c641
* Fri May 03 2013 Thorsten Glaser <tg@mirbsd.org> 46-1
99c641
- Upgrade mksh to R46
99c641
99c641
* Wed May 01 2013 Thorsten Glaser <tg@mirbsd.org> 45-1
99c641
- Upgrade mksh to R45 and the other files to the accompanying versions
99c641
- Drop workaround for GCC PR55009 (no longer needed)
99c641
- Use https for homepage
99c641
99c641
* Mon Mar 18 2013 Robert Scheck <robert@fedoraproject.org> 44-1
99c641
- Upgrade to 44 and work around bug in GCC 4.8 (#922974)
99c641
99c641
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 41-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
99c641
99c641
* Mon Dec 03 2012 Michal Hlavinka <mhlavink@redhat.com> - 41-1
99c641
- Upgrade to 41
99c641
99c641
* Fri Jul 20 2012 Michal Hlavinka <mhlavink@redhat.com> - 40i-0.20120630
99c641
- Upgrade to pre-release of 40i
99c641
- includes new legacy shell lksh for old scripts requiring pdksh or similar old
99c641
  ksh-88 shell, see man lksh for differences
99c641
99c641
* Fri Jul 20 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 40d-3
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
99c641
99c641
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 40d-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
99c641
99c641
* Sun Dec 11 2011 Robert Scheck <robert@fedoraproject.org> 40d-1
99c641
- Upgrade to 40d
99c641
99c641
* Tue Nov 22 2011 Robert Scheck <robert@fedoraproject.org> 40c-1
99c641
- Upgrade to 40c
99c641
99c641
* Thu Jul 28 2011 Robert Scheck <robert@fedoraproject.org> 40b-2
99c641
- Use new "Build.sh -r -c lto" rather "Build.sh -r -combine"
99c641
99c641
* Thu Jul 28 2011 Robert Scheck <robert@fedoraproject.org> 40b-1
99c641
- Upgrade to 40b
99c641
99c641
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 39c-5
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
99c641
99c641
* Tue Jan 04 2011 Michal Hlavinka <mhlavink@redhat.com> 39c-4
99c641
- fix crash when bad substitution is used
99c641
99c641
* Wed Jul 21 2010 Michal Hlavinka <mhlavink@redhat.com> 39c-3
99c641
- fix crash when alias contains alias
99c641
- fix crash when xtrace is enabled
99c641
99c641
* Sun Jul 11 2010 Robert Scheck <robert@fedoraproject.org> 39c-2
99c641
- Added default configuration /etc/mkshrc & /etc/skel/.mkshrc
99c641
  as default skel (like at bash; thanks to Michal Hlavinka)
99c641
- Corrected the license tag (thanks to Michal Hlavinka)
99c641
- Removed the arc4random.c file (upstream is phasing it out)
99c641
99c641
* Sat Feb 27 2010 Robert Scheck <robert@fedoraproject.org> 39c-1
99c641
- Upgrade to 39c and updated arc4random.c file
99c641
99c641
* Thu Aug 13 2009 Robert Scheck <robert@fedoraproject.org> 39-1
99c641
- Upgrade to 39 and updated arc4random.c file
99c641
99c641
* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 38b-2
99c641
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
99c641
99c641
* Sun May 31 2009 Robert Scheck <robert@fedoraproject.org> 38b-1
99c641
- Upgrade to 38b
99c641
99c641
* Sun May 31 2009 Robert Scheck <robert@fedoraproject.org> 38-1
99c641
- Upgrade to 38 and updated arc4random.c file
99c641
- Used -combine (-fwhole-program) rather the old -j switch
99c641
99c641
* Sun Apr 05 2009 Robert Scheck <robert@fedoraproject.org> 37b-1
99c641
- Upgrade to 37b
99c641
99c641
* Mon Feb 23 2009 Robert Scheck <robert@fedoraproject.org> 36b-2
99c641
- Rebuild against gcc 4.4 and rpm 4.6
99c641
99c641
* Sun Dec 14 2008 Robert Scheck <robert@fedoraproject.org> 36b-1
99c641
- Upgrade to 36b and updated arc4random.c file
99c641
99c641
* Tue Dec 02 2008 Robert Scheck <robert@fedoraproject.org> 36-2
99c641
- Upstream patch for command hang/high cpu workload (#474115)
99c641
99c641
* Sat Oct 25 2008 Robert Scheck <robert@fedoraproject.org> 36-1
99c641
- Upgrade to 36
99c641
99c641
* Sat Jul 19 2008 Robert Scheck <robert@fedoraproject.org> 35b-1
99c641
- Upgrade to 35b
99c641
99c641
* Sun Jul 13 2008 Robert Scheck <robert@fedoraproject.org> 35-1
99c641
- Upgrade to 35
99c641
99c641
* Sat Apr 12 2008 Robert Scheck <robert@fedoraproject.org> 33d-1
99c641
- Upgrade to 33d
99c641
99c641
* Fri Apr 04 2008 Robert Scheck <robert@fedoraproject.org> 33c-1
99c641
- Upgrade to 33c and updated arc4random.c file
99c641
99c641
* Mon Mar 03 2008 Robert Scheck <robert@fedoraproject.org> 33-1
99c641
- Upgrade to 33
99c641
99c641
* Sun Feb 10 2008 Robert Scheck <robert@fedoraproject.org> 32-2
99c641
- Rebuild against gcc 4.3
99c641
99c641
* Sat Nov 10 2007 Robert Scheck <robert@fedoraproject.org> 32-1
99c641
- Upgrade to 32
99c641
- Solved fork problems in %%check (thanks to Thorsten Glaser)
99c641
99c641
* Mon Oct 15 2007 Robert Scheck <robert@fedoraproject.org> 31d-1
99c641
- Upgrade to 31d
99c641
99c641
* Wed Sep 12 2007 Robert Scheck <robert@fedoraproject.org> 31c-1
99c641
- Upgrade to 31c
99c641
- Added a buildrequirement to ed, added arc4random.c file
99c641
99c641
* Tue Sep 11 2007 Robert Scheck <robert@fedoraproject.org> 31b-1
99c641
- Upgrade to 31b
99c641
- Use script to get %%check happy (thanks to Thorsten Glaser)
99c641
99c641
* Sat Sep 08 2007 Robert Scheck <robert@fedoraproject.org> 31-1
99c641
- Upgrade to 31
99c641
99c641
* Tue Aug 28 2007 Robert Scheck <robert@fedoraproject.org> 30-2
99c641
- Updated the license tag according to the guidelines
99c641
99c641
* Sat Jul 28 2007 Robert Scheck <robert@fedoraproject.org> 30-1
99c641
- Upgrade to 30
99c641
99c641
* Sat Jul 14 2007 Robert Scheck <robert@fedoraproject.org> 29g-1
99c641
- Upgrade to 29g
99c641
99c641
* Sun Jun 03 2007 Robert Scheck <robert@fedoraproject.org> 29f-1
99c641
- Upgrade to 29f
99c641
- Initial spec file for Fedora and Red Hat Enterprise Linux