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