]> TLD Linux GIT Repositories - packages/mksh.git/blob - mksh.spec
2565c5e0f65959c057f9543bd8b2a66aae3a3b1e
[packages/mksh.git] / mksh.spec
1 #
2 # Conditional build:
3 %bcond_without  static  # static version of mksh
4 %bcond_without  tests   # rtchecks and test.sh checks
5
6 Summary:        MirBSD Korn Shell
7 Summary(pl.UTF-8):      Powłoka Korna z MirBSD
8 Name:           mksh
9 Version:        54
10 Release:        1
11 License:        BSD
12 Group:          Applications/Shells
13 Source0:        http://www.mirbsd.org/MirOS/dist/mir/mksh/%{name}-R%{version}.tgz
14 # Source0-md5:  be0a6fb93b4a5f927bcc1893bb6692f8
15 Source1:        %{name}-mkshrc
16 Patch0:         %{name}-mkshrc_support.patch
17 Patch1:         %{name}-circumflex.patch
18 URL:            https://www.mirbsd.org/mksh.htm
19 %if %{with tests}
20 BuildRequires:  ed
21 BuildRequires:  perl-base
22 %endif
23 %{?with_static:BuildRequires:   glibc-static}
24 BuildRequires:  rpmbuild(macros) >= 1.670
25 # is needed for /etc directory existence
26 Requires(pre):  FHS
27 Requires:       setup >= 2.4.6-2
28 Obsoletes:      pdksh
29 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
30
31 %define         _bindir                 /bin
32
33 %description
34 mksh is the MirBSD enhanced version of the Public Domain Korn shell
35 (pdksh), a Bourne-compatible shell which is largely similar to the
36 original AT&T Korn shell. It includes bug fixes and feature
37 improvements in order to produce a modern, robust shell good for
38 interactive and especially script use. It has UTF-8 support in the
39 emacs command line editing mode; corresponds to OpenBSD 4.2-current
40 ksh sans GNU bash-like $PS1; the build environment requirements are
41 autoconfigured; throughout code simplification/bugfix/enhancement has
42 been done, and the shell has extended compatibility to other modern
43 shells.
44
45 %description -l pl.UTF-8
46 mksh to pochodząca z MirBSD rozszerzona wersja powłoki Public Domain
47 Korn Shell (pdksh) - kompatybilnej z powłoką Bourne'a, w większości
48 zbliżonej do oryginalnej powłoki Korna z AT&T. Zawiera poprawki błędów
49 i rozszerzenia mające na celu stworzenie współczesnej powłoki o
50 bogatych możliwościach do użytku interaktywnego i (zwłaszcza) w
51 skryptach. Ma obsługę UTF-8 w trybie edycji linii poleceń w stylu
52 emacsa; $PS1 odpowiada temu z ksh obecnym w OpenBSD 4.2-current;
53 środowisko budowania jest automatycznie konfigurowane; dzięki
54 wykonanym uproszczeniom kodu, poprawkom i rozszerzeniom powłoka ma
55 rozszerzoną kompatybilność z innymi współczesnymi powłokami.
56
57 %package static
58 Summary:        Statically linked the MirBSD enhanced version of pdksh
59 Summary(pl.UTF-8):      Skonsolidowana statycznie powłoka mksh
60 Group:          Applications/Shells
61 # requires base for /etc/mkshrc?
62 Requires:       %{name} = %{version}-%{release}
63
64 %description static
65 mksh is the MirBSD enhanced version of the Public Domain Korn shell
66 (pdksh), a Bourne-compatible shell which is largely similar to the
67 original AT&T Korn shell.
68
69 This packege contains statically linked version of mksh.
70
71 %description static -l pl.UTF-8
72 mksh to pochodząca z MirBSD rozszerzona wersja powłoki Public Domain
73 Korn Shell (pdksh) - kompatybilnej z powłoką Bourne'a, w większości
74 zbliżonej do oryginalnej powłoki Korna z AT&T.
75
76 W tym pakiecie jest mksh skonsolidowany statycznie.
77
78 %prep
79 %setup -qc
80 mv mksh/* .; rmdir mksh
81
82 %patch0 -p1
83 %patch1 -p1
84
85 # sed rules instead of patch (needed update for every release)
86 sed -i -e 's|\(#define.*MKSH_VERSION.*\)"|\1 @DISTRO@"|g' sh.h
87 sed -i -e 's|\(@(#)MIRBSD KSH.*\)|\1 @DISTRO@|g' check.t
88
89 # fill distro
90 sed -i -e 's#@DISTRO@#TLD/Linux#g' check.t sh.h
91 # sanity checks
92 grep TLD/Linux check.t || exit 1
93 grep TLD/Linux sh.h || exit 1
94
95 # we'll need this later due to -DMKSH_GCC55009
96 cat >rtchecks <<'EOF'
97 typeset -i sari=0
98 typeset -Ui uari=0
99 typeset -i x=0
100 print -r -- $((x++)):$sari=$uari.
101 let --sari --uari
102 print -r -- $((x++)):$sari=$uari.
103 sari=2147483647 uari=2147483647
104 print -r -- $((x++)):$sari=$uari.
105 let ++sari ++uari
106 print -r -- $((x++)):$sari=$uari.
107 let --sari --uari
108 let 'sari *= 2' 'uari *= 2'
109 let ++sari ++uari
110 print -r -- $((x++)):$sari=$uari.
111 let ++sari ++uari
112 print -r -- $((x++)):$sari=$uari.
113 sari=-2147483648 uari=-2147483648
114 print -r -- $((x++)):$sari=$uari.
115 let --sari --uari
116 print -r -- $((x++)):$sari=$uari.
117 EOF
118
119 cat >rtchecks.expected <<'EOF'
120 0:0=0.
121 1:-1=4294967295.
122 2:2147483647=2147483647.
123 3:-2147483648=2147483648.
124 4:-1=4294967295.
125 5:0=0.
126 6:-2147483648=2147483648.
127 7:2147483647=2147483647.
128 EOF
129
130 %build
131 install -d out
132
133 CC="%{__cc}" \
134 CFLAGS="%{rpmcflags} -DMKSH_GCC55009" \
135 LDFLAGS="%{rpmldflags}" \
136 CPPFLAGS="%{rpmcppflags}" \
137 sh ./Build.sh -Q -r -j -c lto
138
139 # skip some tests if not on terminal
140 if ! tty -s; then
141         skip_tests="-C regress:no-ctty"
142 fi
143
144 %if %{with tests}
145 ./mksh rtchecks >rtchecks.got 2>&1
146 if ! cmp --quiet rtchecks.got rtchecks.expected ; then
147         echo "rtchecks failed"
148         diff -Naurp rtchecks.expected rtchecks.got
149         exit 1
150 fi
151 ./test.sh -v $skip_tests
152 %endif
153 mv mksh out/mksh.dynamic
154
155 %if %{with static}
156 CC="%{__cc}" \
157 CFLAGS="%{rpmcflags} -DMKSH_GCC55009" \
158 LDFLAGS="%{rpmldflags} -static" \
159 CPPFLAGS="%{rpmcppflags}" \
160 sh ./Build.sh -Q -r -j -c lto
161
162 %if %{with tests}
163 ./test.sh -v $skip_tests
164 ./mksh rtchecks >rtchecks.got 2>&1
165 if ! cmp --quiet rtchecks.got rtchecks.expected ; then
166         echo "rtchecks failed"
167         diff -Naurp %{SOURCE3} rtchecks.got
168         exit 1
169 fi
170 %endif
171 mv mksh out/mksh.static
172 %endif
173
174 %install
175 rm -rf $RPM_BUILD_ROOT
176 install -d $RPM_BUILD_ROOT{%{_bindir},%{_mandir}/man1}
177 install -p out/mksh.dynamic $RPM_BUILD_ROOT%{_bindir}/mksh
178 %{?with_static:install -p out/mksh.static $RPM_BUILD_ROOT%{_bindir}/mksh.static}
179
180 cp -a mksh.1 $RPM_BUILD_ROOT%{_mandir}/man1/mksh.1
181 echo ".so mksh.1" > $RPM_BUILD_ROOT%{_mandir}/man1/sh.1
182
183 install -D %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/mkshrc
184 ln -sf mksh $RPM_BUILD_ROOT%{_bindir}/sh
185
186 # some pdksh scripts used that
187 ln -sf mksh $RPM_BUILD_ROOT%{_bindir}/ksh
188
189 %clean
190 rm -rf $RPM_BUILD_ROOT
191
192 %post   -p %add_etc_shells -p /bin/sh /bin/ksh /bin/mksh
193 %preun  -p %remove_etc_shells -p /bin/sh /bin/ksh /bin/mksh
194
195 %post   static -p %add_etc_shells -p /bin/mksh.static
196 %preun  static -p %remove_etc_shells -p /bin/mksh.static
197
198 %triggerpostun -p <lua> -- pdksh
199 if arg[2] ~= 0 then
200 %lua_add_etc_shells /bin/sh /bin/ksh /bin/mksh
201 end
202
203 %files
204 %defattr(644,root,root,755)
205 %doc dot.mkshrc
206 %config(noreplace,missingok) %verify(not md5 mtime size) %{_sysconfdir}/mkshrc
207 %attr(755,root,root) %{_bindir}/mksh
208 %attr(755,root,root) %{_bindir}/ksh
209 %attr(755,root,root) %{_bindir}/sh
210 %{_mandir}/man1/mksh.1*
211 %{_mandir}/man1/sh.1*
212
213 %if %{with static}
214 %files static
215 %defattr(644,root,root,755)
216 %attr(755,root,root) %{_bindir}/mksh.static
217 %endif