commit 66da2e3584ad1825509a4e371bb675e0317f85f5 Author: putao66 <1336374132@qq.com> Date: Tue Nov 26 10:42:32 2019 +0800 %build diff --git a/dot-mkshrc b/dot-mkshrc new file mode 100644 index 0000000..b5839c9 --- /dev/null +++ b/dot-mkshrc @@ -0,0 +1,8 @@ +# .mkshrc + +# Source global definitions +if [ -f /etc/mkshrc ]; then + . /etc/mkshrc +fi + +# User specific aliases and functions diff --git a/mksh-R56c.tgz b/mksh-R56c.tgz new file mode 100644 index 0000000..62bcded Binary files /dev/null and b/mksh-R56c.tgz differ diff --git a/mksh.spec b/mksh.spec new file mode 100644 index 0000000..002403e --- /dev/null +++ b/mksh.spec @@ -0,0 +1,120 @@ +Name: mksh +Version: 56c +Release: 5 +Summary: MirBSD enhanced version of the Korn Shell +License: MirOS and ISC and BSD +URL: https://www.mirbsd.org/mksh.htm +Source0: https://www.mirbsd.org/MirOS/dist/mir/%{name}/%{name}-R%{version}.tgz +Source1: dot-mkshrc +Source2: rtchecks.expected + +BuildRequires: gcc util-linux ed +Requires(post): grep +Requires(postun): sed +Provides: lksh mksh +Conflicts: filesystem < 3 + +%description +mksh is the MirBSD Korn Shell, an actively developed free implementation of the Korn Shell programming language +and a successor to the Public Domain Korn Shell (pdksh). It is developed as part of the MirOS Project as +native Bourne/POSIX/Korn shell for MirOS BSD, but also to be readily available under other UNIX-like operating systems. +It targets users who desire a compact, fast, reliable, secure shell not cut off modern extensions, with unicode support. + +%package help +Summary: Help documents for mksh + +%description help +The mksh-help package conatins manual pages and other related files for mksh. + +%prep +%autosetup -n %{name} -p1 + +cat >rtchecks <<'EOF' +typeset -i sari=0 +typeset -Ui uari=0 +typeset -i x=0 +print -r -- $((x++)):$sari=$uari. #0 +let --sari --uari +print -r -- $((x++)):$sari=$uari. #1 +sari=2147483647 uari=2147483647 +print -r -- $((x++)):$sari=$uari. #2 +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. #3 +let --sari --uari +let 'sari *= 2' 'uari *= 2' +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. #4 +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. #5 +sari=-2147483648 uari=-2147483648 +print -r -- $((x++)):$sari=$uari. #6 +let --sari --uari +print -r -- $((x++)):$sari=$uari. #7 +(( sari = -5 >> 1 )) +((# uari = -5 >> 1 )) +print -r -- $((x++)):$sari=$uari. #8 +(( sari = -2 )) +((# uari = sari )) +print -r -- $((x++)):$sari=$uari. #9 +EOF + +%build +CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL" LDFLAGS="$RPM_LD_FLAGS" sh Build.sh -r +cp test.sh test_mksh.sh +export HAVE_PERSISTENT_HISTORY=0 +CFLAGS="$RPM_OPT_FLAGS -DMKSH_DISABLE_EXPERIMENTAL" LDFLAGS="$RPM_LD_FLAGS" sh Build.sh -L -r +cp -f test.sh test_lksh.sh + +%install +install -D -m 755 mksh $RPM_BUILD_ROOT%{_bindir}/mksh +install -D -m 755 lksh $RPM_BUILD_ROOT%{_bindir}/lksh +install -D -m 644 mksh.1 $RPM_BUILD_ROOT%{_mandir}/man1/mksh.1 +install -D -m 644 lksh.1 $RPM_BUILD_ROOT%{_mandir}/man1/lksh.1 +install -D -p -m 644 dot.mkshrc $RPM_BUILD_ROOT%{_sysconfdir}/mkshrc +install -D -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/skel/.mkshrc + +%check +./mksh rtchecks >rtchecks.got 2>&1 +if ! cmp --quiet rtchecks.got %{SOURCE2} +then + echo "rtchecks failed" + diff -Naurp %{SOURCE2} rtchecks.got + exit 1 +fi + +for tf in test_mksh.sh test_lksh.sh +do + echo > test.wait + script -qc "./$tf"' -v; x=$?; rm -f test.wait; exit $x' + maxwait=0 + while test -e test.wait; do + sleep 1 + maxwait=$(expr $maxwait + 1) + test $maxwait -lt 900 || break + done +done + +%post +grep -q "^/bin/mksh$" %{_sysconfdir}/shells 2>/dev/null || \ + echo "/bin/mksh" >> %{_sysconfdir}/shells +grep -q "^%{_bindir}/mksh$" %{_sysconfdir}/shells 2>/dev/null || \ + echo "%{_bindir}/mksh" >> %{_sysconfdir}/shells + +%postun +if [ ! -x %{_bindir}/mksh ]; then + sed -e 's@^/bin/mksh$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells + sed -e 's@^%{_bindir}/mksh$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells +fi + +%files +%doc dot.mkshrc +%{_bindir}/* +%config(noreplace) %{_sysconfdir}/mkshrc +%config(noreplace) %{_sysconfdir}/skel/.mkshrc + +%files help +%{_mandir}/man1/* + +%changelog +* Wed Nov 20 2019 liujing - 56c-5 +- Package init diff --git a/rtchecks.expected b/rtchecks.expected new file mode 100644 index 0000000..56e47ca --- /dev/null +++ b/rtchecks.expected @@ -0,0 +1,10 @@ +0:0=0. +1:-1=4294967295. +2:2147483647=2147483647. +3:-2147483648=2147483648. +4:-1=4294967295. +5:0=0. +6:-2147483648=2147483648. +7:2147483647=2147483647. +8:-3=2147483645. +9:-2=4294967294.