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