Add alternatives switching for rksh

This commit is contained in:
Robert Scheck 2021-03-24 15:08:28 +01:00
parent 5be3ff8a31
commit 1ac0188848

View File

@ -1,7 +1,7 @@
Summary: MirBSD enhanced version of the Korn Shell
Name: mksh
Version: 59c
Release: 2%{?dist}
Release: 3%{?dist}
# BSD (setmode.c), ISC (strlcpy.c), MirOS (the rest)
License: MirOS and ISC and BSD
URL: https://www.mirbsd.org/mksh.htm
@ -12,6 +12,9 @@ Conflicts: filesystem < 3
Provides: /bin/ksh
Provides: /bin/lksh
Provides: /bin/mksh
%if 0%{?fedora} > 33 || 0%{?rhel} > 8
Provides: /bin/rksh
%endif
Provides: /bin/rlksh
Provides: /bin/rmksh
Requires(post): grep
@ -84,7 +87,11 @@ ln -s %{name} $RPM_BUILD_ROOT%{_bindir}/rmksh
ln -s lksh $RPM_BUILD_ROOT%{_bindir}/rlksh
ln -s %{name}.1 $RPM_BUILD_ROOT%{_mandir}/man1/rmksh.1
ln -s lksh.1 $RPM_BUILD_ROOT%{_mandir}/man1/rlksh.1
%if 0%{?fedora} > 33 || 0%{?rhel} > 8
touch $RPM_BUILD_ROOT{%{_bindir}/{ksh,rksh},%{_mandir}/man1/{ksh,rksh}.1}
%else
touch $RPM_BUILD_ROOT{%{_bindir}/ksh,%{_mandir}/man1/ksh.1}
%endif
%check
./mksh rtchecks >rtchecks.got 2>&1
@ -108,30 +115,45 @@ do
done
%post
grep -q "^/bin/%{name}$" %{_sysconfdir}/shells 2>/dev/null || \
echo "/bin/%{name}" >> %{_sysconfdir}/shells
grep -q "^%{_bindir}/%{name}$" %{_sysconfdir}/shells 2>/dev/null || \
echo "%{_bindir}/%{name}" >> %{_sysconfdir}/shells
for d in /bin %{_bindir}; do
%if 0%{?fedora} > 33 || 0%{?rhel} > 8
for s in ksh %{name} rksh rmksh; do
%else
for s in ksh %{name} rmksh; do
%endif
grep -q '^'"$d/$s"'$' %{_sysconfdir}/shells 2>/dev/null || echo "$d/$s" >> /etc/shells
done
done
%{_sbindir}/alternatives --install %{_bindir}/ksh ksh %{_bindir}/%{name} 10 \
--slave %{_mandir}/man1/ksh.1.gz ksh-man %{_mandir}/man1/%{name}.1.gz
%if 0%{?fedora} > 33 || 0%{?rhel} > 8
--slave %{_bindir}/rksh rksh %{_bindir}/%{name} \
%endif
--slave %{_mandir}/man1/ksh.1.gz ksh-man %{_mandir}/man1/%{name}.1.gz \
%if 0%{?fedora} > 33 || 0%{?rhel} > 8
--slave %{_mandir}/man1/rksh.1.gz rksh-man %{_mandir}/man1/%{name}.1.gz
%endif
%preun
if [ $1 = 0 ]; then
if [ $1 -eq 0 ]; then
%{_sbindir}/alternatives --remove ksh %{_bindir}/%{name}
fi
%postun
if [ ! -x %{_bindir}/%{name} ]; then
sed -e 's@^/bin/%{name}$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells
sed -e 's@^%{_bindir}/%{name}$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells
fi
for d in /bin %{_bindir}; do
for s in ksh %{name} rksh rmksh; do
[ ! -x "$d/$s" ] && sed -e 's@^'"$d/$s"'$@POSTUNREMOVE@' -e '/^POSTUNREMOVE$/d' -i %{_sysconfdir}/shells
done
done
%files
%doc dot.mkshrc FAQ.htm
%ghost %{_bindir}/ksh
%{_bindir}/lksh
%{_bindir}/%{name}
%if 0%{?fedora} > 33 || 0%{?rhel} > 8
%ghost %{_bindir}/rksh
%endif
%{_bindir}/rlksh
%{_bindir}/rmksh
%config(noreplace) %{_sysconfdir}/mkshrc
@ -139,10 +161,16 @@ fi
%ghost %{_mandir}/man1/ksh.1*
%{_mandir}/man1/lksh.1*
%{_mandir}/man1/%{name}.1*
%if 0%{?fedora} > 33 || 0%{?rhel} > 8
%ghost %{_mandir}/man1/rksh.1*
%endif
%{_mandir}/man1/rlksh.1*
%{_mandir}/man1/rmksh.1*
%changelog
* Wed Mar 24 2021 Robert Scheck <robert@fedoraproject.org> 59c-3
- Add alternatives switching for rksh
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 59c-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild