[zsh] improve handling of /etc/shells

Dominic Hopf dmaphy at fedoraproject.org
Thu Jul 3 10:13:31 UTC 2014


commit 370e7152bca4d899d5f9a3e644a41ecad1ecaa97
Author: Dominic Hopf <dmaphy at fedoraproject.org>
Date:   Thu Jul 3 12:13:38 2014 +0200

    improve handling of /etc/shells

 zsh.spec |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/zsh.spec b/zsh.spec
index b4abd4d..25e0cbb 100644
--- a/zsh.spec
+++ b/zsh.spec
@@ -3,7 +3,7 @@
 Summary: Powerful interactive shell
 Name: zsh
 Version: 5.0.5
-Release: 4%{?dist}
+Release: 5%{?dist}
 License: MIT
 URL: http://zsh.sourceforge.net/
 Group: System Environment/Shells
@@ -128,10 +128,13 @@ sed -i "s!$RPM_BUILD_ROOT%{_datadir}/%{name}/%{version}/help!%{_datadir}/%{name}
 rm -rf $RPM_BUILD_ROOT
 
 %post
-if [ ! -f %{_sysconfdir}/shells ] ; then
-    echo "%{_bindir}/zsh" > %{_sysconfdir}/shells
-else
-    grep -q "^%{_bindir}/zsh$" %{_sysconfdir}/shells || echo "%{_bindir}/zsh" >> %{_sysconfdir}/shells
+if [ "$1" = 1 ]; then
+  if [ ! -f %{_sysconfdir}/shells ] ; then
+    echo "%{_bindir}/%{name}" > %{_sysconfdir}/shells
+    echo "/bin/%{name}" >> %{_sysconfdir}/shells
+  else
+    grep -q "^%{_bindir}/%{name}$" %{_sysconfdir}/shells || echo "%{_bindir}/%{name}" >> %{_sysconfdir}/shells
+    grep -q "^/bin/%{name}$" %{_sysconfdir}/shells || echo "/bin/%{name}" >> %{_sysconfdir}/shells
 fi
 
 if [ -f %{_infodir}/zsh.info.gz ]; then
@@ -140,7 +143,6 @@ if [ -f %{_infodir}/zsh.info.gz ]; then
   --entry="* zsh: (zsh).			An enhanced bourne shell."
 fi
 
-:
 
 %preun
 if [ "$1" = 0 ] ; then
@@ -150,18 +152,14 @@ if [ "$1" = 0 ] ; then
       --entry="* zsh: (zsh).			An enhanced bourne shell."
     fi
 fi
-:
 
 %postun
-if [ "$1" = 0 ] ; then
-    if [ -f %{_sysconfdir}/shells ] ; then
-        TmpFile=`%{_bindir}/mktemp /tmp/.zshrpmXXXXXX`
-        grep -v '^%{_bindir}/zsh$' %{_sysconfdir}/shells > $TmpFile
-        cp -f $TmpFile %{_sysconfdir}/shells
-        rm -f $TmpFile
-    fi
+if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then
+  sed -i '\!^%{_bindir}/%{name}$!d' %{_sysconfdir}/shells
+  sed -i '\!^/bin/%{name}$!d' %{_sysconfdir}/shells
 fi
 
+
 %files
 %defattr(-,root,root)
 %doc README LICENCE Etc/BUGS Etc/CONTRIBUTORS Etc/FAQ FEATURES MACHINES
@@ -179,6 +177,9 @@ fi
 %doc Doc/*.html
 
 %changelog
+* Thu Jul 03 2014 Dominic Hopf <dmaphy at fedoraproject.org> - 5.0.5-5
+- improve handling of /etc/shells
+
 * Wed Jul 02 2014 Dominic Hopf <dmaphy at fedoraproject.org> - 5.0.5-4
 - fix FTBFS issue (RHBZ#1106713)
 - remove individual _bindir setting; install to /usr/bin/ (RHBZ#1034060)


More information about the scm-commits mailing list