specfile: change /etc/shells only when (un)installing the package
Confirms now to: https://fedoraproject.org/wiki/Packaging:Scriptlets#Shells
This commit is contained in:
parent
40ec3882a1
commit
fa9ea15325
38
tcsh.spec
38
tcsh.spec
@ -14,6 +14,7 @@ Provides: /bin/tcsh
|
|||||||
Requires(post): grep
|
Requires(post): grep
|
||||||
Requires(postun): grep
|
Requires(postun): grep
|
||||||
Requires(postun): coreutils
|
Requires(postun): coreutils
|
||||||
|
Requires(postun): sed
|
||||||
BuildRequires: autoconf
|
BuildRequires: autoconf
|
||||||
BuildRequires: automake
|
BuildRequires: automake
|
||||||
BuildRequires: gettext-devel
|
BuildRequires: gettext-devel
|
||||||
@ -160,27 +161,30 @@ make check
|
|||||||
|
|
||||||
|
|
||||||
%post
|
%post
|
||||||
if [ ! -f /etc/shells ]; then
|
# Add login shell entries to /etc/shells only when installing the package
|
||||||
echo "%{_bindir}/tcsh" >> /etc/shells
|
# for the first time (see 'man 5 SHELLS' for more info):
|
||||||
echo "/bin/tcsh" >> /etc/shells
|
if [[ "$1" -eq 1 ]]; then
|
||||||
echo "%{_bindir}/csh" >> /etc/shells
|
if [[ ! -f %{_sysconfdir}/shells ]]; then
|
||||||
echo "/bin/csh" >> /etc/shells
|
echo "/bin/csh" >> %{_sysconfdir}/shells
|
||||||
else
|
echo "/bin/tcsh" >> %{_sysconfdir}/shells
|
||||||
grep -q '^%{_bindir}/tcsh$' /etc/shells || echo "%{_bindir}/tcsh" >> /etc/shells
|
echo "%{_bindir}/csh" >> %{_sysconfdir}/shells
|
||||||
grep -q '^/bin/tcsh$' /etc/shells || echo "/bin/tcsh" >> /etc/shells
|
echo "%{_bindir}/tcsh" >> %{_sysconfdir}/shells
|
||||||
grep -q '^%{_bindir}/csh$' /etc/shells || echo "%{_bindir}/csh" >> /etc/shells
|
else
|
||||||
grep -q '^/bin/csh$' /etc/shells || echo "/bin/csh" >> /etc/shells
|
grep -q "^/bin/csh$" %{_sysconfdir}/shells || echo "/bin/csh" >> %{_sysconfdir}/shells
|
||||||
|
grep -q "^/bin/tcsh$" %{_sysconfdir}/shells || echo "/bin/tcsh" >> %{_sysconfdir}/shells
|
||||||
|
grep -q "^%{_bindir}/csh$" %{_sysconfdir}/shells || echo "%{_bindir}/csh" >> %{_sysconfdir}/shells
|
||||||
|
grep -q "^%{_bindir}/tcsh$" %{_sysconfdir}/shells || echo "%{_bindir}/tcsh" >> %{_sysconfdir}/shells
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
if [ ! -x %{_bindir}/tcsh ]; then
|
# Remove the login shell lines from /etc/shells only when uninstalling:
|
||||||
grep -v '^%{_bindir}/tcsh$' /etc/shells | \
|
if [[ "$1" -eq 0 && -f %{_sysconfdir}/shells ]]; then
|
||||||
grep -v '^%{_bindir}/csh$' > /etc/shells.rpm && \
|
sed -i -e '\!^/bin/csh$!d' %{_sysconfdir}/shells
|
||||||
grep -v '^/bin/tcsh$' /etc/shells | \
|
sed -i -e '\!^/bin/tcsh$!d' %{_sysconfdir}/shells
|
||||||
grep -v '^%{_bindir}/csh$' | \
|
sed -i -e '\!^%{_bindir}/csh$!d' %{_sysconfdir}/shells
|
||||||
grep -v '^/bin/csh$' > /etc/shells.rpm && \
|
sed -i -e '\!^%{_bindir}/tcsh$!d' %{_sysconfdir}/shells
|
||||||
mv /etc/shells.rpm /etc/shells
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user