From: Marcin Krol Date: Sun, 4 Aug 2013 17:07:32 +0000 (+0000) Subject: - from PLD X-Git-Url: https://git.tld-linux.org/?a=commitdiff_plain;h=5a2b33e1e24f11b9ead84554444f9210d1b85211;p=packages%2Fmksh.git - from PLD --- 5a2b33e1e24f11b9ead84554444f9210d1b85211 diff --git a/mksh-circumflex.patch b/mksh-circumflex.patch new file mode 100644 index 0000000..8aed985 --- /dev/null +++ b/mksh-circumflex.patch @@ -0,0 +1,45 @@ +diff -ur mksh-40.org//eval.c mksh-40/eval.c +--- mksh-40.org//eval.c 2011-06-12 16:45:57.000000000 +0200 ++++ mksh-40/eval.c 2011-07-07 18:27:58.891492090 +0200 +@@ -887,6 +887,7 @@ + switch (c) { + case '[': + case '!': ++ case NOT2: + case '-': + case ']': + /* +diff -ur mksh-40.org//misc.c mksh-40/misc.c +--- mksh-40.org//misc.c 2011-06-12 16:45:58.000000000 +0200 ++++ mksh-40/misc.c 2011-07-07 18:28:39.015826686 +0200 +@@ -843,7 +843,7 @@ + bool notp, found = false; + const unsigned char *orig_p = p; + +- if ((notp = tobool(ISMAGIC(*p) && *++p == '!'))) ++ if ((notp = tobool(ISMAGIC(*p) && (*++p == '!' || *p == NOT2)))) + p++; + do { + c = *p++; +diff -ur mksh-40.org//sh.h mksh-40/sh.h +--- mksh-40.org//sh.h 2011-06-12 16:59:09.000000000 +0200 ++++ mksh-40/sh.h 2011-07-07 18:29:16.346761511 +0200 +@@ -380,5 +380,6 @@ + #define MAGIC (7) /* prefix for *?[!{,} during expand */ + #define ISMAGIC(c) ((unsigned char)(c) == MAGIC) ++#define NOT2 '^' + + #define LINE 4096 /* input line size */ + +diff -ur mksh-40.org//tree.c mksh-40/tree.c +--- mksh-40.org//tree.c 2011-05-29 04:19:21.000000000 +0200 ++++ mksh-40/tree.c 2011-07-07 18:30:12.088149284 +0200 +@@ -289,7 +289,7 @@ + case CHAR: + c = *wp++; + if ((opmode & WDS_MAGIC) && +- (ISMAGIC(c) || c == '[' || c == '!' || ++ (ISMAGIC(c) || c == '[' || c == '!' || c == NOT2 || + c == '-' || c == ']' || c == '*' || c == '?')) + shf_putc(MAGIC, shf); + shf_putc(c, shf); diff --git a/mksh-cmdline-length.patch b/mksh-cmdline-length.patch new file mode 100644 index 0000000..842a245 --- /dev/null +++ b/mksh-cmdline-length.patch @@ -0,0 +1,11 @@ +--- mksh-40b/sh.h~ 2011-10-15 20:27:37.000000000 +0200 ++++ mksh-40b/sh.h 2011-10-18 17:56:07.152596641 +0200 +@@ -381,7 +381,7 @@ + #define NOT '!' /* might use ^ (ie, [!...] vs [^..]) */ + #define NOT2 '^' + +-#define LINE 4096 /* input line size */ ++#define LINE 16384 /* input line size */ + + EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */ + EXTERN const char initvsn[] I__("KSH_VERSION=@(#)MIRBSD KSH " MKSH_VERSION); diff --git a/mksh-mkshrc b/mksh-mkshrc new file mode 100644 index 0000000..1efd688 --- /dev/null +++ b/mksh-mkshrc @@ -0,0 +1,32 @@ +# For interactive shell + +# PROMPT +PS1='[${LOGNAME-$USER}@${HOSTNAME} $( +if [[ $PWD = "$HOME" ]]; then + echo "~" +elif [[ $PWD = "/${PWD##*/}" ]]; then + print -r -- "$PWD" +else + print -r -- "${PWD##*/}" +fi)]' +if (( USER_ID == 0 )); then + PS1+='# ' +else + PS1+='$ ' +fi + +# EDITING FUNCTIONS +set -o emacs +bind '^I'=complete-list >/dev/null 2>&1 + +# SYSTEM WIDE ALIASES ETC. +for i in /etc/shrc.d/*.sh; do + [[ -e $i ]] || continue + . "$i" +done +unset i + +HISTFILE=~/.history.mksh + +# vi:syntax=sh + diff --git a/mksh-mkshrc_support.patch b/mksh-mkshrc_support.patch new file mode 100644 index 0000000..a653979 --- /dev/null +++ b/mksh-mkshrc_support.patch @@ -0,0 +1,19 @@ +--- main.c~ 2011-07-07 18:15:26.961632040 +0100 ++++ main.c 2011-07-07 18:15:50.664694256 +0100 +@@ -532,10 +532,14 @@ + char *env_file; + + /* include $ENV */ +- env_file = substitute(substitute("${ENV:-" MKSHRC_PATH "}", 0), +- DOTILDE); ++ env_file = substitute(substitute("${ENV}", 0), DOTILDE); + if (*env_file != '\0') + include(env_file, 0, NULL, true); ++ else { ++ env_file = substitute(MKSHRC_PATH, DOTILDE); ++ include("/etc/mkshrc", 0, NULL, true); ++ include(env_file, 0, NULL, true); ++ } + } + + if (restricted) { diff --git a/mksh-no_stop_alias.patch b/mksh-no_stop_alias.patch new file mode 100644 index 0000000..e203654 --- /dev/null +++ b/mksh-no_stop_alias.patch @@ -0,0 +1,46 @@ +--- mksh-40.org/main.c 2011-07-07 17:21:37.608256172 +0100 ++++ mksh-40/main.c 2011-07-07 17:22:44.980829725 +0100 +@@ -73,7 +73,6 @@ + #if !defined(ANDROID) && !defined(MKSH_UNEMPLOYED) + /* not in Android for political reasons */ + /* not in ARGE mksh due to no job control */ +- "stop=kill -STOP", + "suspend=kill -STOP $$", + #endif + "autoload=typeset -fu", +--- mksh-40.org/mksh.1 2011-06-12 16:34:43.000000000 +0100 ++++ mksh-40/mksh.1 2011-07-07 17:23:08.177234851 +0100 +@@ -1092,7 +1092,6 @@ + nameref=\*(aqtypeset \-n\*(aq + nohup=\*(aqnohup \*(aq + r=\*(aqfc \-e \-\*(aq +-stop=\*(aqkill \-STOP\*(aq + suspend=\*(aqkill \-STOP $$\*(aq + type=\*(aqwhence \-v\*(aq + .Ed +--- mksh-40.orig/check.t 2011-07-07 17:43:03.450369958 +0100 ++++ mksh-40/check.t 2011-07-07 17:43:24.303467293 +0100 +@@ -5941,7 +5941,6 @@ + nohup='nohup ' + r='fc -e -' + source='PATH=$PATH:. command .' +- stop='kill -STOP' + suspend='kill -STOP $$' + type='whence -v' + --- +@@ -6010,7 +6009,6 @@ + nohup='nohup ' + r='fc -e -' + source='PATH=$PATH:. command .' +- stop='kill -STOP' + suspend='kill -STOP $$' + type='whence -v' + --- +@@ -6034,7 +6032,6 @@ + nohup='nohup ' + r='fc -e -' + source='PATH=$PATH:. command .' +- stop='kill -STOP' + suspend='kill -STOP $$' + type='whence -v' + --- diff --git a/mksh.spec b/mksh.spec new file mode 100644 index 0000000..5eff6c1 --- /dev/null +++ b/mksh.spec @@ -0,0 +1,222 @@ +# +# TODO: https://bugs.launchpad.net/mksh/+bug/1179287 +# +# Conditional build: +%bcond_without static # static version of mksh +%bcond_without tests # rtchecks and test.sh checks +# +# +Summary: MirBSD Korn Shell +Summary(pl.UTF-8): Powłoka Korna z MirBSD +Name: mksh +Version: 47 +Release: 1 +License: BSD +Group: Applications/Shells +Source0: http://www.mirbsd.org/MirOS/dist/mir/mksh/%{name}-R%{version}.tgz +# Source0-md5: 71c7cbcd78306897801b8b6691091e66 +Source1: %{name}-mkshrc +Patch0: %{name}-mkshrc_support.patch +Patch1: %{name}-circumflex.patch +Patch2: %{name}-no_stop_alias.patch +Patch3: %{name}-cmdline-length.patch +URL: https://www.mirbsd.org/mksh.htm +%if %{with tests} +BuildRequires: ed +BuildRequires: perl-base +%endif +%{?with_static:BuildRequires: glibc-static} +BuildRequires: rpmbuild(macros) >= 1.462 +# is needed for /etc directory existence +Requires(pre): FHS +Requires: setup >= 2.4.6-2 +Obsoletes: pdksh +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) + +%define _bindir /bin + +%description +mksh is the MirBSD enhanced version of the Public Domain Korn shell +(pdksh), a Bourne-compatible shell which is largely similar to the +original AT&T Korn shell. It includes bug fixes and feature +improvements in order to produce a modern, robust shell good for +interactive and especially script use. It has UTF-8 support in the +emacs command line editing mode; corresponds to OpenBSD 4.2-current +ksh sans GNU bash-like $PS1; the build environment requirements are +autoconfigured; throughout code simplification/bugfix/enhancement has +been done, and the shell has extended compatibility to other modern +shells. + +%description -l pl.UTF-8 +mksh to pochodząca z MirBSD rozszerzona wersja powłoki Public Domain +Korn Shell (pdksh) - kompatybilnej z powłoką Bourne'a, w większości +zbliżonej do oryginalnej powłoki Korna z AT&T. Zawiera poprawki błędów +i rozszerzenia mające na celu stworzenie współczesnej powłoki o +bogatych możliwościach do użytku interaktywnego i (zwłaszcza) w +skryptach. Ma obsługę UTF-8 w trybie edycji linii poleceń w stylu +emacsa; $PS1 odpowiada temu z ksh obecnym w OpenBSD 4.2-current; +środowisko budowania jest automatycznie konfigurowane; dzięki +wykonanym uproszczeniom kodu, poprawkom i rozszerzeniom powłoka ma +rozszerzoną kompatybilność z innymi współczesnymi powłokami. + +%package static +Summary: Statically linked the MirBSD enhanced version of pdksh +Summary(pl.UTF-8): Skonsolidowana statycznie powłoka mksh +Group: Applications/Shells +# requires base for /etc/mkshrc? +Requires: %{name} = %{version}-%{release} + +%description static +mksh is the MirBSD enhanced version of the Public Domain Korn shell +(pdksh), a Bourne-compatible shell which is largely similar to the +original AT&T Korn shell. + +This packege contains statically linked version of mksh. + +%description static -l pl.UTF-8 +mksh to pochodząca z MirBSD rozszerzona wersja powłoki Public Domain +Korn Shell (pdksh) - kompatybilnej z powłoką Bourne'a, w większości +zbliżonej do oryginalnej powłoki Korna z AT&T. + +W tym pakiecie jest mksh skonsolidowany statycznie. + +%prep +%setup -qcT +gzip -dc %{SOURCE0} | cpio -mid +mv mksh/* .; rmdir mksh + +%patch0 -p0 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 + +# sed rules instead of patch (needed update for every release) +sed -i -e 's|\(#define.*MKSH_VERSION.*\)"|\1 @DISTRO@"|g' sh.h +sed -i -e 's|\(@(#)MIRBSD KSH.*\)|\1 @DISTRO@|g' check.t + +# fill distro +sed -i -e 's#@DISTRO@#PLD/Linux 3.0#g' check.t sh.h +# sanity checks +grep PLD/Linux check.t || exit 1 +grep PLD/Linux sh.h || exit 1 + +# we'll need this later due to -DMKSH_GCC55009 +cat >rtchecks <<'EOF' +typeset -i sari=0 +typeset -Ui uari=0 +typeset -i x=0 +print -r -- $((x++)):$sari=$uari. +let --sari --uari +print -r -- $((x++)):$sari=$uari. +sari=2147483647 uari=2147483647 +print -r -- $((x++)):$sari=$uari. +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. +let --sari --uari +let 'sari *= 2' 'uari *= 2' +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. +let ++sari ++uari +print -r -- $((x++)):$sari=$uari. +sari=-2147483648 uari=-2147483648 +print -r -- $((x++)):$sari=$uari. +let --sari --uari +print -r -- $((x++)):$sari=$uari. +EOF + +cat >rtchecks.expected <<'EOF' +0:0=0. +1:-1=4294967295. +2:2147483647=2147483647. +3:-2147483648=2147483648. +4:-1=4294967295. +5:0=0. +6:-2147483648=2147483648. +7:2147483647=2147483647. +EOF + +%build +install -d out + +CC="%{__cc}" \ +CFLAGS="%{rpmcflags} -DMKSH_GCC55009" \ +LDFLAGS="%{rpmldflags}" \ +CPPFLAGS="%{rpmcppflags}" \ +sh ./Build.sh -Q -r -j -c lto + +# skip some tests if not on terminal +if ! tty -s; then + skip_tests="-C regress:no-ctty" +fi + +%if %{with tests} +./mksh rtchecks >rtchecks.got 2>&1 +if ! cmp --quiet rtchecks.got rtchecks.expected ; then + echo "rtchecks failed" + diff -Naurp rtchecks.expected rtchecks.got + exit 1 +fi +./test.sh -v $skip_tests +%endif +mv mksh out/mksh.dynamic + +%if %{with static} +CC="%{__cc}" \ +CFLAGS="%{rpmcflags} -DMKSH_GCC55009" \ +LDFLAGS="%{rpmldflags} -static" \ +CPPFLAGS="%{rpmcppflags}" \ +sh ./Build.sh -Q -r -j -c lto + +%if %{with tests} +./test.sh -v $skip_tests +./mksh rtchecks >rtchecks.got 2>&1 +if ! cmp --quiet rtchecks.got rtchecks.expected ; then + echo "rtchecks failed" + diff -Naurp %{SOURCE3} rtchecks.got + exit 1 +fi +%endif +mv mksh out/mksh.static +%endif + +%install +rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1} +install -p out/mksh.dynamic $RPM_BUILD_ROOT%{_bindir}/mksh +%{?with_static:install -p out/mksh.static $RPM_BUILD_ROOT%{_bindir}/mksh.static} + +cp -a mksh.1 $RPM_BUILD_ROOT%{_mandir}/man1/mksh.1 +echo ".so mksh.1" > $RPM_BUILD_ROOT%{_mandir}/man1/sh.1 + +install -D %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/mkshrc +ln -sf mksh $RPM_BUILD_ROOT%{_bindir}/sh + +# some pdksh scripts used that +ln -sf mksh $RPM_BUILD_ROOT%{_bindir}/ksh + +%clean +rm -rf $RPM_BUILD_ROOT + +%post -p %add_etc_shells -p /bin/sh /bin/ksh /bin/mksh +%preun -p %remove_etc_shells -p /bin/sh /bin/ksh /bin/mksh + +%posttrans -p %add_etc_shells -p /bin/sh /bin/ksh /bin/mksh + +%post static -p %add_etc_shells -p /bin/mksh.static +%preun static -p %remove_etc_shells -p /bin/mksh.static + +%files +%defattr(644,root,root,755) +%doc dot.mkshrc +%config(noreplace,missingok) %verify(not md5 mtime size) %{_sysconfdir}/mkshrc +%attr(755,root,root) %{_bindir}/mksh +%attr(755,root,root) %{_bindir}/ksh +%attr(755,root,root) %{_bindir}/sh +%{_mandir}/man1/mksh.1* +%{_mandir}/man1/sh.1* + +%if %{with static} +%files static +%defattr(644,root,root,755) +%attr(755,root,root) %{_bindir}/mksh.static +%endif