From 1ef0f170653b8eda10cab910c2b5fc5b5f241df0 Mon Sep 17 00:00:00 2001 From: Colin Walters <walters> Date: Tue, 16 Aug 2016 17:12:58 -0400 Subject: [PATCH] Adapt post/postun scripts to use atomic file replacement This ensures tmux works with rpm-ostree. For more information, see: https://bugzilla.redhat.com/show_bug.cgi?id=1352154 --- tmux.spec | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tmux.spec b/tmux.spec index 449bd64..5dd84c6 100644 --- a/tmux.spec +++ b/tmux.spec @@ -1,6 +1,6 @@ Name: tmux Version: 2.2 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A terminal multiplexer Group: Applications/System @@ -38,18 +38,20 @@ install -Dpm 644 %{SOURCE1} %{buildroot}%{_datadir}/bash-completion/completions/ %post if [ "$1" = 1 ]; then if [ ! -f %{_sysconfdir}/shells ] ; then - echo "%{_bindir}/tmux" > %{_sysconfdir}/shells - echo "/bin/tmux" >> %{_sysconfdir}/shells - else - grep -q "^%{_bindir}/tmux$" %{_sysconfdir}/shells || echo "%{_bindir}/tmux" >> %{_sysconfdir}/shells - grep -q "^/bin/tmux$" %{_sysconfdir}/shells || echo "/bin/tmux" >> %{_sysconfdir}/shells + touch %{_sysconfdir}/shells fi + for binpath in %{_bindir} /bin; do + if ! grep -q "^${binpath}/tmux$" %{_sysconfdir}/shells; then + (cat %{_sysconfdir}/shells; echo "$binpath/tmux") > %{_sysconfdir}/shells.new + mv %{_sysconfdir}/shells{.new,} + fi + done fi %postun if [ "$1" = 0 ] && [ -f %{_sysconfdir}/shells ] ; then - sed -i '\!^%{_bindir}/tmux$!d' %{_sysconfdir}/shells - sed -i '\!^/bin/tmux$!d' %{_sysconfdir}/shells + sed -e '\!^%{_bindir}/tmux$!d' -e '\!^/bin/tmux$!d' < %{_sysconfdir}/shells > %{_sysconfdir}/shells.new + mv %{_sysconfdir}/shells{.new,} fi %files -- 2.7.4
Applied in latest rawhinde build.